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 -> Re: Retreiving Column/Table Names from a Query Using OCI

Re: Retreiving Column/Table Names from a Query Using OCI

From: Flavius Vespasianus <nl_at_nl.com>
Date: Tue, 02 Jul 2002 12:51:01 GMT
Message-ID: <VkhU8.712$2k5.300@newsread1.prod.itd.earthlink.net>


Daniel Morgan <dmorgan_at_exesolutions.com> wrote in news:3D20E051.6D0DC841_at_exesolutions.com:

> Flavius Vespasianus wrote:
>

>> I have an application that I am trying to switch from "BDE to ODBC to
>> oracle"  to OCI directly.
>>
>> The problem I have having is that the application uses dynamic
>> queries. 
>>
>> If I have a query like
>>
>> SELECT * from A, B WHERE A.X = B.X
>>
>> I need to know in the result set which columns come from A and which
>> come from B. Unfortunately, when I use the examples in the OCI
>> manual, only the column name gets returns.
>>
>> How can I get the table name for a column in a result set?

>
> You could solve this problem in a number of ways. The one I would
> recommend is to write good SQL.
>
> Rewrite your queries to:
>
> SELECT a.field_name, a.field_name, b.field_name
> FROM table_a a, table_b b
> WHERE a.x = b.x
>

Unfortunately, that is impossible with this application.

> But I don't see what you are doing as dynamic queries ... they look
> completely static to me. If you want dynamic queries look at native
> dynamic SQL and the DBMS_SQL built-in package.

This was a very simple example. About 80% of the code in this this overengineered  application is devoted to building queries on the fly and interpreting the results. In order to do this it needs the table name in the results. Received on Tue Jul 02 2002 - 07:51:01 CDT

Original text of this message

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