代码之家  ›  专栏  ›  技术社区  ›  Sathyajith Bhat ron tornambe

如何在Oracle中调试PL/SQL集合的值?

  •  2
  • Sathyajith Bhat ron tornambe  · 技术社区  · 15 年前

    DBMS_SQL.DESCRIBE_COLUMNS2 那是,直到现在我都不知道。

    的输出变量之一 DBMS_SQL.descripe_列2 过程是一个集合,我想检查返回到其中的值-我如何观察/观察/检查该值?

    我使用Allround Automations的PL/SQL开发人员,但也可以使用Oracle的SQL开发人员作为工具。


    尝试像这样遍历集合;

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

    但那会导致 PLS-00306: wrong number or types of arguments in call to 'PUT_LINE' .

    M_Rec_Tab声明为 Dbms_Sql.Desc_Tab2

    Dbms_Sql.Desc_Tab2 声明为 desc_tab2 is table of desc_rec2 index by binary_integer

    我在Oracle 10g R2(10.2.0.1.0)上

    1 回复  |  直到 15 年前
        1
  •  4
  •   Craig    15 年前

    你就快到了。。。再往前走一步。desc_tab2的定义是:

    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);
    

    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;