oracle怎么添加try catch,Try Catch Like Exception Handling In Pl/Sql

In a procedure, I want to do logic unit 1, doesn't matter if it fails, execute logic unit 2

this seems like a typical try-catch scenario. but how can I do it in pl/sql?

create or replace
PACKAGE BUILD_PKG
ASPROCEDURE reset_seq_and_truncate_tbl(
  p_seq_name 
IN VARCHAR2,
  p_table_name
IN VARCHAR2 );END BUILD_PKG;/create or replace
PACKAGE BODY BUILD_PKG
ASBEGINPROCEDURE reset_seq_and_truncate_tbl(
  p_seq_name 
IN VARCHAR2,
  p_table_name
IN VARCHAR2 )IS
  l_val NUMBER
;BEGINBEGINEXECUTE immediate 'truncate table ' || p_table_name;
  EXCEPTION
WHEN OTHERS THEN dbms_output.put_line(SQLCODE);END;BEGINEXECUTE immediate 'alter sequence ' || p_seq_name || ' increment by 1 minvalue 0';
  EXCEPTION
WHEN OTHERS THEN dbms_output.put_line(SQLCODE);END; END reset_seq_and_truncate_tbl;END BUILD_PKG;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值