Execute sql file in Exception statement

by csuazo   Last Updated June 22, 2018 17:06 PM

Hi I'm trying to execute an SQL File in a Exception Statement when I'm executing an Spool file.

I have something like this:

column dt new_value _dt 
select to_char(sysdate,'yyyymmdd_hh24mi') dt from dual; 
set line 10000;
set pagesize 50000;
set serveroutput on;

spool .\backup\TEST_TABLE.sql

select dbms_metadata.get_ddl(object_type, object_name)
from user_objects
where object_type in ('FUNCTION')
and object_name = 'TEST_TABLE';

Spool Off

spool .\!Run_&_dt..txt

BEGIN
    raise_application_error( -20001, 'This is a custom error' );
EXCEPTION 
    WHEN OTHERS THEN
        Prompt ./backup/backup.sql
        @ ./backup/backup.sql
END;

Spool Off

And I get the next error:

>> BEGIN
     raise_application_error( -20001, 'This is a custom error' );
EXCEPTION 
    WHEN OTHERS THEN
        Prompt ./backup/backup.sql
        @ ./backup/backup.sql
END;


Spool Off
Error at line 18
ORA-06550: line 6, column 11:
PLS-00103: Encountered the symbol "/" when expecting one of the following:

    <an identifier> <a double-quoted delimited-identifier>
    current delete exists prior
ORA-06550: line 6, column 49:
PLS-00103: Encountered the symbol "SQL" when expecting one of the following:

    <an identifier> <a double-quoted delimited-identifier>
    current delete exists prior

I don't have any idea, thanks in advance.

Best regards.



Related Questions



How to get value of 1 immeadiate next row only

Updated August 18, 2017 04:06 AM


Update specific rows in a column

Updated August 16, 2017 02:06 AM

How to format String with a pattern

Updated August 27, 2017 08:06 AM