Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> How to find column's corresponding table name (OCI)

How to find column's corresponding table name (OCI)

From: David S. Johnson <dsjohnso_at_ingr.com>
Date: 1997/09/16
Message-ID: <01bcc2e3$b1d71980$53be8781@DAVIDJ>#1/1

I am developing an OCI application which can accept SQL queries posed by the user. Using odescr, I am able to obtain the column names and types that were included in the column list. Is there a way to get the table names as well?

For a very simple example,

SELECT ename, emp.deptno, dname

    FROM emp, dept
    WHERE emp.deptno = dept.deptno

I am hoping to avoid parsing the SQL myself since I will be receiving much more complex queries. In reality, my user is some sort of scripting language like Visual Basic which is driving my OLE automated object which uses OCI. The SQL I will be receiving will be more like the following SQL statement except that I have no guarantee that the column names will be preceded by the table names:

SELECT /*+ cost ordered

           index (str3_std_area_sdogeom STR3_STD_area_GEOMNDX) 
           index (str3_std_area         STR3_STD_area_GDOIDX) */ 
       str3_std_area."AREA",
       str3_std_area."PERIMETER",
       str3_std_area."STR3_STD_",
       str3_std_area."STR3_STD_ID",
       str3_std_area."STAND_NO",
       str3_std_area."GDO_GID",
       str3_std_area_sdogeom."SDO_GID",
       str3_std_area_sdogeom."SDO_ESEQ",
       str3_std_area_sdogeom."SDO_ETYPE",
       str3_std_area_sdogeom."SDO_SEQ",
       str3_std_area_sdogeom."SDO_X1",
       str3_std_area_sdogeom."SDO_Y1",
       str3_std_area_sdogeom."SDO_X2",
       str3_std_area_sdogeom."SDO_Y2",
       str3_std_area_sdogeom."SDO_X3",
       str3_std_area_sdogeom."SDO_Y3",
       str3_std_area_sdogeom."SDO_X4",
       str3_std_area_sdogeom."SDO_Y4",
       str3_std_area_sdogeom."SDO_X5",
       str3_std_area_sdogeom."SDO_Y5",
       str3_std_area_sdogeom."SDO_X6",
       str3_std_area_sdogeom."SDO_Y6",
       str3_std_area_sdogeom."SDO_X7",
       str3_std_area_sdogeom."SDO_Y7",
       str3_std_area_sdogeom."SDO_X8",
       str3_std_area_sdogeom."SDO_Y8"
FROM (SELECT DISTINCT gid_a gid1 
      FROM (SELECT /*+ index (a STR3_STD_area_INDEX_CODE) 
                       index (b ROAD_500_INDEX_CODE) 
                       use_nl (a b) */ 
                   DISTINCT a.sdo_gid gid_a, 
                            b.sdo_gid gid_b 
            FROM str3_std_area_sdoindex a, 
                 road_500_sdoindex b 
            WHERE a.sdo_code = b.sdo_code) 
      WHERE sdo_geom.relate('str3_std_area',gid_a,'ANYINTERACT', 
                            'road_500',gid_b) <> 'FALSE'), 
      str3_std_area, 
      str3_std_area_sdogeom 

WHERE gdo_gid = gid1
  AND sdo_gid = gid1
order by sdo_gid, sdo_eseq, sdo_seq; Received on Tue Sep 16 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US