Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pl /sql set ORA-00922: missing or invalid option on set serveroutput on;

set serveroutput on;

DECLARE 
 message varchar2(20):= 'Hello, World!';

BEGIN dbms_output.put_line(message); 
END; 
/
like image 202
shabana Afzal Avatar asked Nov 15 '25 01:11

shabana Afzal


2 Answers

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 ; 
like image 98
Belayer Avatar answered Nov 17 '25 22:11

Belayer


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>
like image 25
Dmitry Demin Avatar answered Nov 17 '25 21:11

Dmitry Demin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!