Re: Obtain underlying table of a select list item per OCI

From: news.verizon.net <kennedyii_at_verizon.net>
Date: Mon, 02 Jun 2008 13:38:41 GMT
Message-ID: <BJS0k.2155$v%.27@trndny04>

"Mathias Waack" <M.Waack_at_gmx.de> wrote in message news:4NR0k.512$9W3.42551_at_se2-cb104-9.zrh1.ch.colt.net...
> Hi,
>
> assume a situation where we have two tables:
>
> create table t1 (c1 number, c2 varchar2(10));
> create table t2 (c1 number, c2 date);
>
> and a select like this:
>
> select t1.c1, t2.c1 from t1, t2;
>
> This statements comes as an opaque string into an OCI routine which tries
> to
> analyze the query. Its easy to obtain column names, datatypes aso from the
> query, but OCI returns only the short column names. Thus the select list
> from the query above becomes (c1,c1). Is there a way to distinguish both
> columns within OCI?
>
> I'm currently extending an application which generates queries which joins
> tables containing columns with the same name. Would be nice to find out,
> which column comes from which table.
>
> Mathias
>

This is called a natural join and is a very bad idea. It is relying on the same column names in different tables being keys to a join. There are a lot of circumstances where this is not true. So while you can use a natural join it is not advisable to do so.

In the above alias the columns. Then they will have different names. Jim Received on Mon Jun 02 2008 - 08:38:41 CDT

Original text of this message