2010-04-23 15 views
5

Mam skrypt psql oraz SQL, który wygląda tak:Czy istnieje sposób na przywrócenie i zamknięcie skryptu psql w przypadku błędu?

-- first set of statements 
begin 
sql statement; 
sql statement; 
sql statement; 
exception 
    when others then 
    rollback 
    write some output 
    (here I want to exit the entire script and not continue on to the next set of statements) 
end 
/
-- another set of statements 
begin 
sql statement; 
sql statement; 
sql statement; 
exception 
    when others then 
    rollback 
    write some output 
    (here I want to exit the entire script and not continue) 
end 
/
... and so on 

Czy to możliwe, aby zakończyć skrypt i zatrzymać przetwarzanie resztę skryptu?

Odpowiedz

8

umieścić następujące wiersze na początku pliku:

WHENEVER OSERROR EXIT ROLLBACK 
WHENEVER SQLERROR EXIT ROLLBACK 

... i upewnij się, że masz RAISE; na końcu swoich procedur obsługi wyjątków.

+0

myślę, że to jest to. Dziękuję Ci! – dtc

1

Hmmm ... PL/SQL ma GOTO, dzięki czemu można przeskoczyć do etykiety umieszczonej na samym końcu skryptu.
np

GOTO the_end; 
[rest of script here] 
<<the_end>> 
Powiązane problemy