Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Doing "DESC" in Pro*C
Pauil Perkins wrote:
> I've seen that you can do a DESCRIBE on a prepared DSQL statement, but this
> (I think) enumerates the types of the columns contained in the statement -
> i.e. requires prior knowledge of the table.
Paul,
You're very close to it! The DESCRIBE is an excellent solution - you
need no prior knowledge of the table if your statement is simply a
'SELECT * FROM <table_name>' - the 'select *' will be 'expended' by
Oracle and you will get your list.
Another (and probably easier, if you are not too familiar with dynamic
SQL) is to query the dictionary tables such as USER_TAB_COLUMNS or
DBA_TAB_COLUMNS (never too sure about the name), or, if you feel more
adventurous (and if your program is run by a DBA), a join on sys.user$,
sys.obj$ and sys.col$. If you want to describe a huge number of tables,
the easier way may also happen to be the best one, as the dynamic
'select *' means a new cursor and new parsing for each table, whereas in
the second case you just have to bind the various ownername/tablenames
to the same query.
--
Regards,
Stéphane Faroult
Oriole Corporation