Select to view content in your preferred language

[RESOLVED] GDB in Oracle: Error calling SDE.St_GeomFromWKB from OCI

1553
1
10-03-2017 01:07 AM
DenisVitsko
New Contributor
-- The anonymous sql-block with St_GeomFromWKB is working good
DECLARE
    :GEOM BLOB; 
BEGIN  
:GEOM := HEXTORAW('010200000004000000b6f3fdd497961341c74b37097b2042418941606596961341819543bb822042416f1283c05f971341ac1c5a149d20424175931884829613410ad7a350b6204241');     
UPDATE "SDE"."MYTABLE" SET "SHAPE" = SDE.ST_GeomFromWKB(:GEOM, 3405) 
WHERE "OBJECTID" = 1;
END;
SELECT SDE.St_AsText(SHAPE) AS SHAPE FROM "SDE"."MYTABLE" WHERE "OBJECTID" = 1

This SQL is executed in Oracle SQL Developer with good result.

When my application called this function I'm got the error (using OCI):

ORA-03001: unimplemented feature
ORA-06512: at "SDE.ST_GEOMETRY_SHAPELIB_PKG", line 237
ORA-06512: at "SDE.ST_GEOMETRY_OPERATORS", line 162

The BLOB value which application send as WKB is properly. 

I'm check it several methods:

- used it as parameter for constructor of SDO_GEOMETRY;

- add the blob field to the table and save BLOB in this field, then convert this value to St_Geometry.

The convertion from BLOB field with WKB value to the St_Geometry also propertly works in Oracle SQL Developer only. 

UPDATE "SDE"."MYTABLE" SET "SHAPE" = SDE.ST_GeomFromWKB("SHAPE_BLOB", 3405) WHERE "OBJECT"=1;

The execution this command from my external application using OCI is finished with such error:

ORA-03001: unimplemented feature
ORA-06512: at "SDE.ST_GEOMETRY_SHAPELIB_PKG", line 237
ORA-06512: at "SDE.ST_GEOMETRY_OPERATORS", line 162

The message

ORA-06512: at "SDE.ST_GEOMETRY_SHAPELIB_PKG", line 237

is meaning that error while call the funlction geomfromshape() from library "st_shapelib.dll"

Some others functions from "st_shapelib.dll" are successful calling from my application using OCI.
For example the function SDE.ST_AsBinary which calling from OCI application is works properly.

Why SDE.St_GeomFromWKB not working when its calling from OCI application?

Thanks for any ideas!

PS. Additional information.

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

The library st_shapelib.dll is added to Oracle Database propertly.

SELECT * FROM USER_LIBRARIES;

return

ST_SHAPELIB | c:\app\panuser\product\11.2.0\dbhome_1\BIN\st_shapelib.dll | Y | VALID

Checking "invalid" objects

select object_name, object_type from user_objects where status = 'INVALID'

returns no records.

0 Kudos
1 Reply
DenisVitsko
New Contributor

The library st_shapelib.dll does not allow to use your own transaction. 

I was forced to remove from my OCI-programme this code snippet:

// Allocate Transaction Handle

OCIHandleAlloc((dvoid *)pOCIEnviron, (dvoid **)&pOCITrans, OCI_HTYPE_TRANS, 0, 0);

// detach the transaction

OCITransDetach(pOCISvcCtx, pOCIError, 0);

// Append transaction to service context

OCIAttrSet((dvoid *)pOCISvcCtx, OCI_HTYPE_SVCCTX, (dvoid *)pOCITrans, 0, OCI_ATTR_TRANS, pOCIError);

XID gxid;

// global transaction id = [1000, 123, 1]

gxid.formatID = 1000; // format id = 1000

gxid.gtrid_length = 3; // gtrid = 123

gxid.data[0] = 1;

gxid.data[1] = 2;

gxid.data[2] = 3;

gxid.bqual_length = 1; // bqual = 1

gxid.data[3] = 1;

OCIAttrSet((dvoid *)pOCITrans, OCI_HTYPE_TRANS, (dvoid *)&gxid, sizeof(XID), OCI_ATTR_XID, pOCIError);

OCIAttrSet ((dvoid *) pOCITrans, OCI_HTYPE_TRANS, (text *) MY_TRANSACTION_NAME, wcslen (MY_TRANSACTION_NAME), OCI_ATTR_TRANS_NAME, pOCIError);

// Start transaction with timeout 90 sec

OCITransStart(pOCISvcCtx, pOCIError, 90, OCI_TRANS_NEW);

After that function ST_GeomFromWKB has begun to work properly.

So, I concluded that when you using "st_shapelib.dll" library in your OCI-application you may use OCITransStart, OCITransCommit and OCITransRollback with default transaction only and can not make your own transaction. Otherwise some SDE functions such as St_GeomFromWKB will not work properly.

0 Kudos