Is there any way to flush output from PL/SQL in Oracle?

后端 未结 6 1062
情深已故
情深已故 2020-11-29 06:02

I have an SQL script that is called from within a shell script and takes a long time to run. It currently contains dbms_output.put_line statements at various po

6条回答
  •  有刺的猬
    2020-11-29 06:43

    Not really. The way DBMS_OUTPUT works is this: Your PL/SQL block executes on the database server with no interaction with the client. So when you call PUT_LINE, it is just putting that text into a buffer in memory on the server. When your PL/SQL block completes, control is returned to the client (I'm assuming SQLPlus in this case); at that point the client gets the text out of the buffer by calling GET_LINE, and displays it.

    So the only way you can make the output appear in the log file more frequently is to break up a large PL/SQL block into multiple smaller blocks, so control is returned to the client more often. This may not be practical depending on what your code is doing.

    Other alternatives are to use UTL_FILE to write to a text file, which can be flushed whenever you like, or use an autonomous-transaction procedure to insert debug statements into a database table and commit after each one.

提交回复
热议问题