Re: DESCRIBE IN PRO*C?

From: Mike Ressler <ressler_at_bart.calgary.ingr.com>
Date: 30 Sep 1994 17:09:19 GMT
Message-ID: <36hgnv$a7p_at_zimbra.calgary.ingr.com>


In article <CwsxA3.Eou_at_rahul.net> Mike Stuart <mstuart_at_rahul.net> writes:
>Hi There,
>
>I'm new to pro*c and I don't have any books on it, but I've been
>working with some "oracle provided" online example code. I'm trying
>to use the describe command to query table definitions via
>EXEC SQL
> DESCRIBE table_name
>
>I receive an "Invalid Command" compile error.
>
>None of the oracle examples use the describe command, but I assume it
>can be done. Does anybody out ther know the syntax for this?
>
>
>Thanx in advance,
>
> Mike Stuart ( mstuart_at_rahul.net )
>--
>Mike Stuart <mstuart_at_rahul.net>

You can select from a table called accessible_columns. It looks like this:

SQL> desc accessible_columns;

 Name                            Null?    Type
 ------------------------------- -------- ----
 OWNER                           NOT NULL VARCHAR2(30)
 TABLE_NAME                      NOT NULL VARCHAR2(30)
 COLUMN_NAME                     NOT NULL VARCHAR2(30)
 DATA_TYPE                                VARCHAR2(9)
 DATA_LENGTH                     NOT NULL NUMBER
 DATA_PRECISION                           NUMBER
 DATA_SCALE                               NUMBER
 NULLABLE                                 VARCHAR2(1)
 COLUMN_ID                       NOT NULL NUMBER
 DEFAULT_LENGTH                           NUMBER
 DATA_DEFAULT                             LONG


Pick out the columns you want to select, and declare a cursor to select them out.

ex) exec sql declare my_tables cursor for

      select table_name, column_name
      from accessible_columns;


I assume you know how to open, fetch and close cursors.

M. Ressler Received on Fri Sep 30 1994 - 18:09:19 CET

Original text of this message