set serveroutput on;
DECLARE
message varchar2(20):= 'Hello, World!';
BEGIN dbms_output.put_line(message);
END;
/
As others have indicated "set server output on" is a SQL*Plus command. If you need that functionality in plsql the you're looking for is DBMS_OUTPUT.ENABLE. Your above block becomes:
declare
message varchar2(20) := 'Hello World';
begin
dbms_output.enable;
dbms_output.put_line(message);
end ;
If use SQL*plus then this code works fine.
[oracle@krw-sql-ora12-01 ~]$ sqlplus scott/tiger
SQL*Plus: Release 11.2.0.3.0 Production on Fri Feb 22 08:07:25 2019
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> set serveroutput on;
SQL> DECLARE
2 message varchar2(20):= 'Hello, World!';
3 BEGIN dbms_output.put_line(message);
4 END;
5 /
Hello, World!
PL/SQL procedure successfully completed.
SQL>
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