Execute immediate dbms_output.put_line
10,369
declare
v_str varchar2(200);
begin
v_str := q'!begin dbms_output.put_line('Hello world'); end;!';
Execute immediate v_str;
end;
/
works...
Author by
David Kakauridze
Updated on June 27, 2022Comments
-
David Kakauridze almost 2 years
I have code like this:
set serveroutput on declare v_str varchar2(200); begin v_str := q'!dbms_output.put_line('Hello world');!'; Execute immediate v_str; end;
Oracle SQL Developer says that there's invalid SQL Statement, what's the problem?
-
kmkaplan over 11 yearsUse
show err
to print detail on the error. -
Jeffrey Kemp over 11 yearsIs there a particular reason why you need to call dbms_output with dynamic PL/SQL?
-
-
Ben over 11 yearsBasically, the answer is that
dbms_output
is a procedure and so can only be executed within a PL/SQL block. -
Alex Poole over 11 years@Ben - really a reply to a comment on your deleted answer, but still relevant here; the
q
syntax is in the documentation under text literals.