Friday, March 10, 2023

Yet another curious syntax with little documentation: SELECT FROM RELATIONAL("schema"."table")

Have you ever seen this syntax?

SELECT * FROM RELATIONAL("SCOTT"."EMP");

For tables containing only primitive data types it returns the same results as it would the normal query:

SELECT * FROM "SCOTT"."EMP"; 

For tables containing object data types, however, it splits object's underlying attributes into separate columns:

CREATE TABLE GEOM_TABLE(
ID NUMBER,
GEOM SDO_GEOMETRY
);

INSERT INTO GEOM_TABLE(ID, GEOM)
VALUES(1, SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(1680337.2, 4973436.1, 1680337.3, 4973436.2, 1680337.2, 4973436.9, 1680337.2, 4973436.1)));

 
SELECT * FROM RELATIONAL("GEOM_TABLE"); -- I omitted the schema

ID GEOM SYS_NC00003$ SYS_NC00004$ SYS_NC00005$ SYS_NC00006$ SYS_NC00007$ SYS_NC00008$ SYS_NC00009$
1 02 2003         MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 1) MDSYS.SDO_ORDINATE_ARRAY(1680337.2, 4973436.1, 1680337.3, 4973436.2, 1680337.2, 4973436.9, 1680337.2, 4973436.1)

I didn't investigate what that 02 means in the GEOM column.

As far as I could see there is no official document describing this syntax, however it must be there since ages because I found it in queries created by an old java based framework in 2009.

No comments:

yes you can!

Two great ways to help us out with a minimal effort. Click on the Google Plus +1 button above or...
We appreciate your support!

latest articles