2

I am trying to save a long integer value to an Oracle field. I have created a field of long integer type using ArcCatalog in a standalone table. The below code breaks at row.set_Value(idx, val) . Error message is:

"The value type is incompatible with the field type.[EMP_ID]"

It looked such a trivial problem but now I am stuck. Any ideas how to resolve this?

IMxDocument doc = ArcMap.Application.Document as IMxDocument;
IMap map = doc.FocusMap;
IFeatureLayer layer = map.get_Layer(0) as IFeatureLayer;
IFeatureClass fc = layer.FeatureClass;
IWorkspace ws = (fc as IDataset).Workspace;

IFeatureWorkspace fws = ws as IFeatureWorkspace;
ITable tbl = fws.OpenTable("TestTable");
int idx = tbl.FindField("EMP_ID");
IRow row = tbl.CreateRow();
long val = 123412341234;
row.set_Value(idx, val);
row.Store();
  • Please Edit the question to contain the DESCRIBE tablename output from SQL*Plus. – Vince Aug 31 '17 at 10:16
  • Note that "long" might be an 8-byte long long with some compiler switches, but int isn't likely to be anything other than a 4-byte type. – Vince Aug 31 '17 at 12:02
3

Long is not that long according to ESRI. They say it translates to number(10), while you need a number(12) or more. The workaround is to create a double(12,0) column in ArcCatalog, with a scale of 0 (no decimals). You can read it as .net long in your code. This doc is also useful.

From experience, I have found default values chosen by ESRI to be sub-optimal.

  • yes JGH, long is not long enough for ESRI. – vinayan Sep 12 '17 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.