The GET_LINES procedure gets one or more lines of text from the message buffer and stores the text in a collection. Each line of text must be terminated by an end-of-line character sequence.
EXECUTE privilege on the DBMS_OUTPUT module.
Use the GET_LINES procedure to get lines of text from the message buffer and store the text in an array. The text in the array can be inserted into a table and queried.
CALL DBMS_OUTPUT.ENABLE( NULL )@
CREATE PROCEDURE proc1()
BEGIN
CALL DBMS_OUTPUT.PUT_LINE( 'PROC1 put this line in the message buffer.' );
CALL DBMS_OUTPUT.PUT_LINE( 'PROC1 put this line in the message buffer.' );
END@
CREATE PROCEDURE proc2()
BEGIN
CALL DBMS_OUTPUT.PUT_LINE( 'PROC2 put this line in the message buffer.' );
END@
CREATE TABLE messages ( msg VARCHAR(100) )@
CREATE PROCEDURE proc3()
BEGIN
DECLARE lines DBMS_OUTPUT.CHARARR;
DECLARE numlines INT;
DECLARE i INT;
CALL DBMS_OUTPUT.GET_LINES( lines, numlines );
SET i = 1;
WHILE i <= numlines DO
INSERT INTO messages VALUES ( lines[i] );
SET i = i + 1;
END WHILE;
END@
CALL proc1@
CALL proc3@
CALL DBMS_OUTPUT.DISABLE@
CALL proc2@
CALL proc3@
SELECT * FROM messages@
This example results in the following output:MSG
------------------------------------------
PROC1 put this line in the message buffer.
PROC1 put this line in the message buffer
2 record(s) selected.