Re: Using Sqlda/Sqlca Structures with Describe
Posted in 1998
djnick@my-dejanews.com wrote:
>
> For ESQL Developers:
>
> This is the first time posting and need an answer fairly quickly.
> Is there a way using the Sqlda or Sqlca structures with dynamic SQL
> (multiple fetch) to retrieve the table name for that statement. The
> SQLDA structures will return each column with the column name, but if
> a join is being done how does one go about getting the table for the
> returned column without parsing out the statement themselves. Is there
> no way to do this. Thanks.
Consider this, DJ.
The column name in the sqlda structure is the display column name you
see in dbaccess/isql when you run a query. Even when you specify the
table.column name in the query, you will get only the column name in the
display. Often, this will will result in several identical column names
in the display eg. when you "select customer.cust_num, order.cust_num",
you will get two columns with the heading "cust_num".
Now, if your column names are short enough, you can try this:
select customer.cust_num c_cust_num, order.cust_num o_cust_num
from (etc)..
If you are playing with dynamic SQL you had better know how to use
display names.
Now the sqlda structures will contain the "column" names c_cust_num and
o_cust_num. Code your C program to infer from your little prefix
whether the cust_num value came from the customer table or the order
table.
Extra work? Sure! But not too convoluted. Give it a shot, let us know
how it worked.
--
-- Jake (Retrospectively realizes there is no future in hindsight)
+------------------------------------------------------------+
| The expedient performance of a task with excessive concern |
| regarding its duration-to-completion engenders a virtual |
| certainty of diminished benefit therefrom. |
| -- Benjamin Franklin (but he said it in 3 words) |
+------------------------------------------------------------+