开发者

How can I debug the value of a PL/SQL collection in Oracle?

I'm debugging a procedure which ... returns certain values. The procedure seems to use DBMS_SQL.DESCRIBE_COLUMNS2 which was, till now unknown to me.

One of the out variables of the DBMS_SQL.DESCRIBE_COLUMNS2 procedure is a collection, and I want to examine that value is being returned into that - how can I observe/watch/examine this value 开发者_Go百科?

I use Allround Automations' PL/SQL Developer, but also have Oracle's SQL Developer as the tools with which I can use.


Tried iterating through the collection like so;

For Val In 1..M_Rec_Tab.Count Loop
 Dbms_Output.Put_Line( M_Rec_Tab(Val) );
end loop;

But that throws a PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'.

M_Rec_Tab is declared as Dbms_Sql.Desc_Tab2 type.

Dbms_Sql.Desc_Tab2 declared as desc_tab2 is table of desc_rec2 index by binary_integer

I'm on Oracle 10g R2 ( 10.2.0.1.0 )


You were almost there... Just one more step. The definition of desc_tab2 is:

TYPE desc_rec2 IS RECORD (
   col_type            binary_integer := 0,
   col_max_len         binary_integer := 0,
   col_name            varchar2(32767) := '',
   col_name_len        binary_integer := 0,
   col_schema_name     varchar2(32)   := '',
   col_schema_name_len binary_integer := 0,
   col_precision       binary_integer := 0,
   col_scale           binary_integer := 0,
   col_charsetid       binary_integer := 0,
   col_charsetform     binary_integer := 0,
   col_null_ok         boolean        := TRUE);

So you can loop over the collection and output the values of each field in the record:

For Val In 1..M_Rec_Tab.Count Loop   
 Dbms_Output.Put_Line( '----- Record #'||Val||' -----' );   
 Dbms_Output.Put_Line( 'Column Type: '||M_Rec_Tab(Val).col_type );   
 Dbms_Output.Put_Line( 'Max Length: '||M_Rec_Tab(Val).col_max_len );
...
 Dbms_Output.Put_Line( 'Charset Form: '||M_Rec_Tab(Val).col_charsetform );
 Dbms_Output.Put_Line( 'Nulls Allowed: '|| case when M_Rec_Tab(Val).col_null_ok then 'Y' else 'N' end );
end loop; 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜