OiO.lk Blog SQL sqlplus: how to execute a query spanning multiple lines
SQL

sqlplus: how to execute a query spanning multiple lines


I am using Oracle 19c. I can get the following to work:

variable max_id number;

exec select 41 into :max_id from dual;
    
begin
dbms_output.put_line(:max_id);
dbms_output.put_line(:max_id+1);
end;

But splitting the select across multiple lines produces an invalid SQL statement error at the new line:

variable max_id number;

exec select 41
into :max_id from dual;  -- invalid SQL statement error points here
    
begin
dbms_output.put_line(:max_id);
dbms_output.put_line(:max_id+1);
end;

How would I get exec to work with a multiline query?



You need to sign in to view this answers

Exit mobile version