Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

When to flush output from dbms _ output in sql?


Asked by Keily Scott on Dec 09, 2021 SQL



Messages sent using DBMS_OUTPUT are not actually sent until the sending subprogram or trigger completes. There is no mechanism to flush output during the execution of a procedure. This means you cannot read the messages as the program executes.
Likewise,
The DBMS_OUTPUT package is especially useful for displaying PL/SQL debugging information. Messages sent using DBMS_OUTPUT are not actually sent until the sending subprogram or trigger completes. There is no mechanism to flush output during the execution of a procedure.
Consequently, the buffer of DBMS_OUTPUT is read when the procedure DBMS_OUTPUT.get_line is called. If your client application is SQL*Plus, it means it will only get flushed once the procedure finishes. You can apply the method described in this SO to write the DBMS_OUTPUT buffer to a file.
Indeed,
PL/SQL has DBMS_OUTPUT package that is used to send messages from procedures, packages, and triggers. This package is used to display output to a screen. DBMS_OUTPUT.PUT_LINE procedure is used to place a line in the buffer or display output to a screen.
In respect to this,
The output cannot be retrieved until the PL/SQL program unit from which it was buffered returns to its caller. For example, SQL*Plus does not display DBMS_OUTPUT messages until the PL/SQL program completes. There is no mechanism for flushing the DBMS_OUTPUT buffers within the PL/SQL program.