Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: column name as a part of the result set
Daniel Morgan <damorgan_at_x.washington.edu> wrote i
> > You can use dynamic SQL and do a DESCRIBE on the cursor to fetch the
> > column names/labels into a dynamic array... and then process it from
> > there (i.e. iterate through column array per row for columns with the
> > same name and then comparing the row's values to see if it is
> > different or not).
> >
> > I'm sure I've seen DESCRIBE supported in PL/SQL (it is an often used
> > Pro*C/OCI function).
> >
> > --
> > Billy
>
> Not according to tahiti.oracle.com though I will gladly stand corrected.
Found it.
Daniel, have a look at example 8 for DBMS_SQL (Oracle9i Supplied PL/SQL Packages and Types Reference)
Something like:
begin
c := dbms_sql.open_cursor;
dbms_sql.parse(c, 'select * from scott.bonus', dbms_sql);
d := dbms_sql.execute(c);
dbms_sql.describe_columns(c, col_cnt, rec_tab);
..etc.
This DESCRIBE function of DBMS_SQL quite likely use the same one we'll use in Pro*C (example 10 of Pro*C I think does this also using dynamic SQL and bind vars).
-- BillyReceived on Thu Feb 19 2004 - 23:21:43 CST