• <bdo id='Bbmew'></bdo><ul id='Bbmew'></ul>

    <tfoot id='Bbmew'></tfoot>

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

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

  • <i id='Bbmew'><tr id='Bbmew'><dt id='Bbmew'><q id='Bbmew'><span id='Bbmew'><b id='Bbmew'><form id='Bbmew'><ins id='Bbmew'></ins><ul id='Bbmew'></ul><sub id='Bbmew'></sub></form><legend id='Bbmew'></legend><bdo id='Bbmew'><pre id='Bbmew'><center id='Bbmew'></center></pre></bdo></b><th id='Bbmew'></th></span></q></dt></tr></i><div id='Bbmew'><tfoot id='Bbmew'></tfoot><dl id='Bbmew'><fieldset id='Bbmew'></fieldset></dl></div>
      1. 如何将 DBMS_OUTPUT.PUT_LINE 的输出重定向到文件?

        How to redirect the output of DBMS_OUTPUT.PUT_LINE to a file?(如何将 DBMS_OUTPUT.PUT_LINE 的输出重定向到文件?)

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

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

              <tfoot id='Na1Jg'></tfoot>

            • <legend id='Na1Jg'><style id='Na1Jg'><dir id='Na1Jg'><q id='Na1Jg'></q></dir></style></legend>
                • <bdo id='Na1Jg'></bdo><ul id='Na1Jg'></ul>
                • 本文介绍了如何将 DBMS_OUTPUT.PUT_LINE 的输出重定向到文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要在 pl/sql 中调试以计算程序的次数,我想使用:

                  I need to debug in pl/sql to figure times of procedures, I want to use:

                  SELECT systimestamp FROM dual INTO time_db;
                  DBMS_OUTPUT.PUT_LINE('time before procedure ' || time_db);
                  

                  但我不明白输出的去向以及如何将其重定向到包含我想要收集的所有数据的日志文件?

                  but I don't understand where the output goes to and how can I redirect it to a log file that will contain all the data I want to collect?

                  推荐答案

                  DBMS_OUTPUT 不是最好的调试工具,因为大多数环境本身并不使用它.但是,如果您想捕获 DBMS_OUTPUT 的输出,您只需使用 DBMS_OUTPUT.get_line 过程.

                  DBMS_OUTPUT is not the best tool to debug, since most environments don't use it natively. If you want to capture the output of DBMS_OUTPUT however, you would simply use the DBMS_OUTPUT.get_line procedure.

                  这是一个小例子:

                  SQL> create directory tmp as '/tmp/';
                  
                  Directory created
                  
                  SQL> CREATE OR REPLACE PROCEDURE write_log AS
                    2     l_line VARCHAR2(255);
                    3     l_done NUMBER;
                    4     l_file utl_file.file_type;
                    5  BEGIN
                    6     l_file := utl_file.fopen('TMP', 'foo.log', 'A');
                    7     LOOP
                    8        EXIT WHEN l_done = 1;
                    9        dbms_output.get_line(l_line, l_done);
                   10        utl_file.put_line(l_file, l_line);
                   11     END LOOP;
                   12     utl_file.fflush(l_file);
                   13     utl_file.fclose(l_file);
                   14  END write_log;
                   15  /
                  
                  Procedure created
                  
                  SQL> BEGIN
                    2     dbms_output.enable(100000);
                    3     -- write something to DBMS_OUTPUT
                    4     dbms_output.put_line('this is a test');
                    5     -- write the content of the buffer to a file
                    6     write_log;
                    7  END;
                    8  /
                  
                  PL/SQL procedure successfully completed
                  
                  SQL> host cat /tmp/foo.log
                  
                  this is a test
                  

                  这篇关于如何将 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 中的重置序列)
                  No more data to read from socket(没有更多的数据要从套接字读取)
                  • <i id='YuJQL'><tr id='YuJQL'><dt id='YuJQL'><q id='YuJQL'><span id='YuJQL'><b id='YuJQL'><form id='YuJQL'><ins id='YuJQL'></ins><ul id='YuJQL'></ul><sub id='YuJQL'></sub></form><legend id='YuJQL'></legend><bdo id='YuJQL'><pre id='YuJQL'><center id='YuJQL'></center></pre></bdo></b><th id='YuJQL'></th></span></q></dt></tr></i><div id='YuJQL'><tfoot id='YuJQL'></tfoot><dl id='YuJQL'><fieldset id='YuJQL'></fieldset></dl></div>

                        <bdo id='YuJQL'></bdo><ul id='YuJQL'></ul>

                        • <legend id='YuJQL'><style id='YuJQL'><dir id='YuJQL'><q id='YuJQL'></q></dir></style></legend>

                            <tbody id='YuJQL'></tbody>
                          <tfoot id='YuJQL'></tfoot>

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