I'm trying to automate a routine that imports data from a Shapefile to SDE. The old data in the SDE layer needs to be wiped away each time, so I am using the 'init' option in the shp2sde command. Since Shapefiles notoriously truncate field names, I am trying to use the '-a' option that loads a file map of the names and other info.
shp2sde -o init -l pittarib.polyfeature,shape -f polyfeature -a file=poly_feat_attr.txt -r poly_feat_rej -v -i esri_sde_devtest -s testserver -u pittarib -p mypassword
Doing a lyrinfo command on the shapefile yields this information:
OBJECTID OBJECTID SE_INTEGER 0 -
SDE_FEATUR SDE_FEATURE_DATE SE_DATE 0 -
TEST_LINE_ TEST_LINE_PART_COUNT SE_INTEGER 5 -
TEST_POINT TEST_POINT_PART_COUNT SE_INTEGER 5 -
TEST_THREE TEST_THREE_POINT_COUNT SE_INTEGER 5 -
SDE_POLY_P SDE_POLY_PART_COUNT SE_INTEGER 5 -
SDE_CLOSEP SDE_CLOSEPOLY_ERR_FL SE_STRING 1 -
SDE_MULTIP SDE_MULTIPART_SHP_FL SE_STRING 1 -
SDE_INTERS SDE_INTERSECT_ERR_FL SE_STRING 1 -
AREA AREA SE_DOUBLE 27 8
LEN LEN SE_DOUBLE 27 8
OBJECT_ID_ OBJECT_ID_FK SE_INTEGER 0 -
OBJECTID N 10 - SE_INTEGER 0 -
SDE_FEATUR D 8 - SE_DATE 0 -
TEST_LINE_ N 5 - SE_INTEGER 5 -
TEST_POINT N 5 - SE_INTEGER 5 -
TEST_THREE N 5 - SE_INTEGER 5 -
SDE_POLY_P N 5 - SE_INTEGER 5 -
SDE_CLOSEP C 1 - SE_STRING 1 -
SDE_MULTIP C 1 - SE_STRING 1 -
SDE_INTERS C 1 - SE_STRING 1 -
AREA N 19 8 SE_DOUBLE 27 8
LEN N 19 8 SE_DOUBLE 27 8
OBJECT_ID_ N 10 - SE_INTEGER 0 -
SDE column definition string:
OBJECTID integer, SDE_FEATUR date, TEST_LINE_ integer(5), TEST_POINT
integer(5), TEST_THREE integer(5), SDE_POLY_P integer(5), SDE_CLOSEP
string(1), SDE_MULTIP string(1), SDE_INTERS string(1), AREA double(27,8),
LEN double(27,8), OBJECT_ID_ integer
The attribute info on the SDE Layer in ArcCatalog yields this information:
OBJECT_ID_FK / Data type: Integer / Width: 4 / Precision: 10 / Scale: 0
SDE_FEATURE_DATE / Data type: Date / Width: 36 / Precision: 0 / Scale: 0
TEST_LINE_PART_COUNT / Data type: SmallInteger / Width: 2 / Precision: 3 / Scale: 0
TEST_POINT_PART_COUNT / Data type: SmallInteger / Width: 2 / Precision: 3 / Scale: 0
TEST_THREE_POINT_COUNT / Data type: SmallInteger / Width: 2 / Precision: 3 / Scale: 0
SDE_CLOSEPOLY_ERR_FL / Data type: String / Width: 1 / Precision: 0 / Scale: 0
OBJECTID / Alias: OBJECTID / Data type: OID / Width: 4 / Precision: 0 / Scale: 0
SDE_POLY_PART_COUNT / Data type: SmallInteger / Width: 2 / Precision: 3 / Scale: 0
Shape / Data type: Geometry / Width: 0 / Precision: 0 / Scale: 0
SDE_MULTIPART_SHP_FL / Data type: String / Width: 1 / Precision: 0 / Scale: 0
PITTARIB.POLYFEATURE_SDE.AREA / Data type: Double / Width: 8 / Precision: 38 / Scale: 8
SDE_INTERSECT_ERR_FL / Data type: String / Width: 1 / Precision: 0 / Scale: 0
PITTARIB.POLYFEATURE_SDE.LEN / Data type: Double / Width: 8 / Precision: 38 /Scale: 8
SHAPE / Data type: Geometry / Width: 4 / Precision: 0 / Scale: 0
SHAPE.AREA / Data type: Double / Width: 0 / Precision: 0 / Scale: 0
SHAPE.LEN / Data type: Double / Width: 0 / Precision: 0 / Scale: 0
Based on the format from the online help, I'm guessing the attribute file should be in this form:
<shpCol> [sdeCol] [type] [size] [nDecs] [NOT_NULL]
So, the SHP > SDE fields/info in the text file are as follows:
OBJECTID OBJECTID SE_INTEGER 4 0
OBJECT_ID_ OBJECT_ID_FK SE_INTEGER 8 0
SDE_FEATUR SDE_FEATURE_DATE SE_DATE 36 0
TEST_LINE_ TEST_LINE_PART_COUNT SE_INTEGER 2 0
TEST_POINT TEST_POINT_PART_COUNT SE_INTEGER 2 0
TEST_THREE TEST_THREE_POINT_COUNT SE_INTEGER 2 0
SDE_POLY_P SDE_POLY_PART_COUNT SE_INTEGER 2 -
SDE_CLOSEP SDE_CLOSEPOLY_ERR_FL SE_STRING 1 -
SDE_MULTIP SDE_MULTIPART_SHP_FL SE_STRING 1 -
SDE_INTERS SDE_INTERSECT_ERR_FL SE_STRING 1 -
AREA AREA SE_DOUBLE 27 15 -
LEN LEN SE_DOUBLE 27 15 -
Upon loading, the program returns a fatal error and I have to exit out. Do I have this in the wrong format? Should I use 'N' instead of SE_INTEGER, for example, as the load type? Do I need to use the SDE Layer field information (width, decimals, etc) instead of what I got from the Shapefile?