Re: Obtain underlying table of a select list item per OCI
Date: Mon, 02 Jun 2008 13:38:41 GMT
"Mathias Waack" <M.Waack_at_gmx.de> wrote in message
> 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
> 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.
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