<small id='1grR1'></small><noframes id='1grR1'>

      1. <tfoot id='1grR1'></tfoot>
        <i id='1grR1'><tr id='1grR1'><dt id='1grR1'><q id='1grR1'><span id='1grR1'><b id='1grR1'><form id='1grR1'><ins id='1grR1'></ins><ul id='1grR1'></ul><sub id='1grR1'></sub></form><legend id='1grR1'></legend><bdo id='1grR1'><pre id='1grR1'><center id='1grR1'></center></pre></bdo></b><th id='1grR1'></th></span></q></dt></tr></i><div id='1grR1'><tfoot id='1grR1'></tfoot><dl id='1grR1'><fieldset id='1grR1'></fieldset></dl></div>
        <legend id='1grR1'><style id='1grR1'><dir id='1grR1'><q id='1grR1'></q></dir></style></legend>
          <bdo id='1grR1'></bdo><ul id='1grR1'></ul>
      2. Oracle PL/SQL TABLE 类型的 TO_CHAR

        TO_CHAR of an Oracle PL/SQL TABLE type(Oracle PL/SQL TABLE 类型的 TO_CHAR)
      3. <tfoot id='x1PDT'></tfoot>
            <bdo id='x1PDT'></bdo><ul id='x1PDT'></ul>

            <small id='x1PDT'></small><noframes id='x1PDT'>

          • <i id='x1PDT'><tr id='x1PDT'><dt id='x1PDT'><q id='x1PDT'><span id='x1PDT'><b id='x1PDT'><form id='x1PDT'><ins id='x1PDT'></ins><ul id='x1PDT'></ul><sub id='x1PDT'></sub></form><legend id='x1PDT'></legend><bdo id='x1PDT'><pre id='x1PDT'><center id='x1PDT'></center></pre></bdo></b><th id='x1PDT'></th></span></q></dt></tr></i><div id='x1PDT'><tfoot id='x1PDT'></tfoot><dl id='x1PDT'><fieldset id='x1PDT'></fieldset></dl></div>

              <tbody id='x1PDT'></tbody>

                  <legend id='x1PDT'><style id='x1PDT'><dir id='x1PDT'><q id='x1PDT'></q></dir></style></legend>

                • 本文介绍了Oracle PL/SQL TABLE 类型的 TO_CHAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  出于调试目的,我希望能够TO_CHAR"一个 Oracle PL/SQL 内存表.这是我想做的一个简化示例:

                  For debugging purposes, I'd like to be able to "TO_CHAR" an Oracle PL/SQL in-memory table. Here's a simplified example, of what I'd like to do:

                  DECLARE
                    TYPE T IS TABLE OF MY_TABLE%ROWTYPE INDEX BY PLS_INTEGER;
                    V T;
                  
                  BEGIN
                    -- ..
                  
                    -- Here, I'd like to dbms_output V's contents, which of course doesn't compile
                    FOR i IN V.FIRST .. V.LAST LOOP
                      dbms_output.put_line(V(i));
                    END LOOP;
                  
                    -- I want to omit doing this:
                    FOR i IN V.FIRST .. V.LAST LOOP
                      dbms_output.put_line(V(i).ID || ',' || V(i).AMOUNT ...);
                    END LOOP;
                  
                  END;
                  

                  这能实现吗,简单的?之所以这么问,是因为懒得一遍遍写这段调试代码,想用在任何表类型上.

                  Can this be achieved, simply? The reason I ask is because I'm too lazy to write this debugging code again and again, and I'd like to use it with any table type.

                  推荐答案

                  好的,抱歉这还没有完成,但是为了跟进@Lukas,这是我目前所拥有的:

                  ok, sorry this isn't complete, but to followup with @Lukas, here's what I have so far:

                  首先,我没有尝试创建 anydata/anytype 类型,而是尝试使用从游标中提取的 XML...很奇怪,但它是通用的:

                  First, instead of trying to create anydata/anytype types, I tried using XML extracted from a cursor...weird, but its generic:

                  CREATE OR REPLACE procedure printCur(in_cursor IN sys_refcursor) IS
                  begin
                  
                      FOR c IN (SELECT ROWNUM rn,
                                      t2.COLUMN_VALUE.getrootelement () NAME,
                                      EXTRACTVALUE (t2.COLUMN_VALUE, 'node()') VALUE
                                 FROM TABLE (XMLSEQUENCE (in_cursor)) t,
                                      TABLE (XMLSEQUENCE (EXTRACT (COLUMN_VALUE, '/ROW/node()'))) t2
                                 order by 1)
                  
                     LOOP
                        DBMS_OUTPUT.put_line (c.NAME || ': ' || c.VALUE);
                     END LOOP;
                  
                  exception
                      when others then raise;
                  end;
                  /
                  

                  现在,要调用它,您需要一个游标,所以我尝试在 pl/sql 中转换为游标,例如:

                  Now, to call it, you need a cursor, so I tried casting to cursor in pl/sql, something like:

                  open v_cur for select * from table(cast(v_tab as tab_type));
                  

                  但是根据 v_tab 的定义方式,这可能会或可能不会导致 pl/sql 转换问题(在嵌套表 def 中使用 %rowtype 似乎会产生问题).

                  But depending on how v_tab is defined, this may or may not cause issues in pl/sql cast (using %rowtype in nested table def seems to give issues).

                  无论如何,您可以在此基础上进行构建或根据需要对其进行改进.(并可能使用 xmltable...)

                  Anyway, you can build on this or refine it as you like. (and possibly use xmltable...)

                  希望有帮助

                  这篇关于Oracle PL/SQL TABLE 类型的 TO_CHAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to redirect the output of DBMS_OUTPUT.PUT_LINE to a file?(如何将 DBMS_OUTPUT.PUT_LINE 的输出重定向到文件?)
                  How do I get column datatype in Oracle with PL-SQL with low privileges?(如何使用低权限的 PL-SQL 在 Oracle 中获取列数据类型?)
                  Get a list of all functions and procedures in an Oracle database(获取 Oracle 数据库中所有函数和过程的列表)
                  Why cannot I create triggers on objects owned by SYS?(为什么我不能在 SYS 拥有的对象上创建触发器?)
                  Returning result even for elements in IN list that don#39;t exist in table(即使对于表中不存在的 IN 列表中的元素也返回结果)
                  Reset Sequence in oracle 11g(oracle 11g 中的重置序列)
                  <tfoot id='BAUJF'></tfoot>

                    <small id='BAUJF'></small><noframes id='BAUJF'>

                    1. <legend id='BAUJF'><style id='BAUJF'><dir id='BAUJF'><q id='BAUJF'></q></dir></style></legend>
                        <bdo id='BAUJF'></bdo><ul id='BAUJF'></ul>
                        <i id='BAUJF'><tr id='BAUJF'><dt id='BAUJF'><q id='BAUJF'><span id='BAUJF'><b id='BAUJF'><form id='BAUJF'><ins id='BAUJF'></ins><ul id='BAUJF'></ul><sub id='BAUJF'></sub></form><legend id='BAUJF'></legend><bdo id='BAUJF'><pre id='BAUJF'><center id='BAUJF'></center></pre></bdo></b><th id='BAUJF'></th></span></q></dt></tr></i><div id='BAUJF'><tfoot id='BAUJF'></tfoot><dl id='BAUJF'><fieldset id='BAUJF'></fieldset></dl></div>
                          <tbody id='BAUJF'></tbody>