Re: need information on extracting column names from pro*c

From: Tim Smith <tssmith_at_netcom.com>
Date: 6 May 92 01:36:43 GMT
Message-ID: <7gdk8_f.tssmith_at_netcom.com>


In article <1992May5.183719.21738_at_ms.uky.edu> skaul_at_ms.uky.edu (Sanjay Kaul) writes:
>I'm trying to retrieve the table names and field (column) names
>from within a c program that interfaces to an oracle database.
>
>If I have a table name and know nothing else about the table,
>how can I find out the names and attributes of the columns from
>within a c program?

You can use dynamic SQL. With full dynamic SQL, using the SQL Descriptor structure (SQLDA), there is a DESCRIBE statement. It fills in members of the SQLDA struct with the column names, length of names, datatypes, precision and scale, and whether NULLs are allowed.

For example, if you have a query such as

SELECT * from my_table

using the DESCRIBE statement on this query fills arrays in the SQLDA with the column name, etc. of each select-list item in the query (i.e., each column in the table).

It's a bit complicated to go over in depth here. Get hold of a V1.3 or later Pro*C Supplement to the ORACLE Precompilers Guide, and look at either Chapter 4 (V1.3) or 5 (V1.4 or later), and that will give you all the details.

--Tim (tssmith_at_netcom.com) Received on Wed May 06 1992 - 03:36:43 CEST

Original text of this message