Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: list of variables inside a variable of type record

Re: list of variables inside a variable of type record

From: Jusung Yang <JusungYang_at_yahoo.com>
Date: 23 Jan 2003 11:38:42 -0800
Message-ID: <130ba93a.0301231138.7fc37573@posting.google.com>


Not sure there is an easy way of getting the column name. One thing you could do is to open a dummy cursor to select 1 row from the table and then use DBMS_SQL.DESCRIBE_COLUMNS to get the all the meta data about the columns, including name. For example:

SQL> desc test1

 Name                                      Null?    Type
 ----------------------------------------- -------- ---------------
 C1                                                 VARCHAR2(2)
 C2                                                 NUMBER(1)
 SUMC2                                              NUMBER(5)

SQL> SQL> declare
  2 rec_tab dbms_sql.desc_tab;
  3 col_cnt integer;
  4 i_cur integer:=dbms_sql.open_cursor;   5 x varchar2(200):='select * from test1 where rownum <2';   6 begin

  7  DBMS_SQL.PARSE(i_cur,x,dbms_sql.native);
  8  dbms_sql.describe_columns(i_cur,col_cnt,rec_tab);
  9  for i in rec_tab.first..rec_tab.last loop
 10     dbms_output.put_line(rec_tab(i).col_name);
 11 end loop;
 12 end;
 13 /
C1
C2
SUMC2 PL/SQL procedure successfully completed.

kamal80_at_virgilio.it (Kamal) wrote in message news:<4e766a02.0301230304.71d7edd7_at_posting.google.com>...
> Hi everybody.
>
> Does anyone know how to have a list of the variable inside a record
> declared like this:
>
> rec1 table_name%rowtype;
>
>
> I could retrieve the field name from the dictionary views like
> user_tab_columns or similar, but what can i do if "table_name" is a
> synonym? Maybe pointing to a db link? And if the db link points to
> another synonym pointing to another db link etc etc? Is there a
> straight way to know all the fields inside this record variable?
>
> TIA
>
> Kamal
Received on Thu Jan 23 2003 - 13:38:42 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US