0
votes

I want to execute this script in PL/SQL but it keeps getting error

set serveroutput on;
set echo on;
declare 
  v_code varchar2(250);
  v_errm varchar2(250);
begin
  @@"1.sql";
  @@"2.sql";
  @@"II_load_438865311678_Reg.sql"; 
exception
when others then
  v_code := sqlcode;
  v_errm := substr(sqlerrm, 1, 64);
  DBMS_OUTPUT.PUT_LINE('ERROR! - '||DBMS_UTILITY.FORMAT_ERROR_STACK|| DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
  rollback;
end;
/

What is wrong with this.

Error: ORA-06550: line 5, colunm 3: (...) ORA-06550: line 6, colunm 3: (...) ORA-06550: line 7, colunm 3: PLS-00103: Encountered the symbol "@" when expecting one of the following: ( begin case declare end exception exit for goto if loop mod null pragma raise return select update while with... and 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action:

1
@ is not a SQL (or PL/SQL) command. It's a SQL*Plus command and can only be used at the SQL*Plus command prompt. Not inside PL/SQL (because that is run on the server not on the client)a_horse_with_no_name
what is the solution to correct this?John John
Either created stored procedures with the other scripts that can then be run by this block, or implement error handling in each of the other scripts. I would lean towards the second, unless this call structure is a firm requirement.Chris Hep
the other 3 files are only inserts. I only want to create a simple script just to call in a automatic form.John John

1 Answers

0
votes

You only use the PL/SQL code to show the error. That is not necessary; SQL*Plus will already show you any SQL error. Use whenever sqlerror to trigger the rollback.

whenever sqlerror continue rollback
@@"1.sql"
@@"2.sql"
@@"II_load_438865311678_Reg.sql"