I have a select statement that I wanna print in a stored procedure. The only way is to create a cursor in the SP, which holds the result of the select, and then iterate through the lines and print each line using dbms_output.put_line?
SQL> create or replace procedure p (p_c out sys_refcursor) as 2 begin 3 open p_c for 4 with test_data as 5 ( 6 select 1 n, 'a' s from dual union all 7 select 2 n, 'b' s from dual union all 8 select 5 n, 'x' s from dual 9 ) 10 select n, s from test_data; 11 end; 12 / Procedure created. SQL> var c refcursor SQL> exec p(:c) PL/SQL procedure successfully completed. SQL> print c N S ---------- - 1 a 2 b 5 x