I want to use DBMS_OUTPUT.PUT_LINE
, but the number of rows exceeds just 1. There is nothing in the table which increments sequentially, so I can't use a loop. Is there some way to print out each row in the table?
To do this we use a procedure called dbms_output. put_line to place the results in a buffer that SQL*Plus will retrieve and display. SQL*Plus must be told to retrieve data from this buffer in order to display the results. The SQL*Plus command 'set serveroutput on' causes SQL*Plus to retrieve and display the buffer.
Execute a PL/SQL anonymous block using SQL*Plus Second, turn on the server output using the SET SERVEROUTPUT ON command so that the DBMS_OUTPUT. PUT_LINE procedure will display text on the screen. Third, type the code of the block and enter a forward slash ( / ) to instruct SQL*Plus to execute the block.
try with something like this.
SET SERVEROUTPUT ON
BEGIN
-- A PL/SQL cursor
FOR cursor1 IN (SELECT * FROM table1)
LOOP
DBMS_OUTPUT.PUT_LINE('Column 1 = ' || cursor1.column1 ||
', Column 2 = ' || cursor1.column2);
END LOOP;
END;
/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With