给你举个插入的例子吧:(例子中INSERT时的异常是插入的列值过大,表中的第一个字段定义varchar2(2),实际插入的是'1234567890',超长了) create or replace procedure test_yixl_pro as err_msg varchar2(255); begin begin insert into test_yixl values('1234567890', '1'); exception when others then err_msg := substr(SQLERRM, 1, 200); dbms_output.put_line(err_msg); end; end; 执行的结果就是: ORA-12899: value too large for column "APPS"."TEST_YIXL"."REC" (actual: 10, maximum: 9)
没太看明白。似乎是异常处理的 例子:declare v_emp emp%rowtype; begin select * into v_emp from emp where empno = &v_empno; exception -- 异常处理 when no_data_found then -- oracle异常 dbms_output.put_line('未找到数据!'); when others then dbms_output.put_line('!!!!!!'); end;
create or replace procedure test_yixl_pro
as
err_msg varchar2(255);
begin
begin
insert into test_yixl values('1234567890', '1');
exception when others then
err_msg := substr(SQLERRM, 1, 200);
dbms_output.put_line(err_msg);
end;
end;
执行的结果就是:
ORA-12899: value too large for column "APPS"."TEST_YIXL"."REC" (actual: 10, maximum: 9)
例子:declare
v_emp emp%rowtype;
begin
select * into v_emp from emp where empno = &v_empno;
exception -- 异常处理
when no_data_found then -- oracle异常
dbms_output.put_line('未找到数据!');
when others then
dbms_output.put_line('!!!!!!');
end;