大虾,ORACLE触发器报错了

来源:百度知道 编辑:UC知道 时间:2024/06/28 04:03:47
create table practive(col1 char(10) primary key,col2 char(10))
我建一个trigger,想实现在col1列里自动插入序号0001、0002、0003……
trigger脚本如下:
create or replace trigger tri_practice
before insert on practice
declare
v_xh char(10);
v_cho int;
begin
select to_number(max(col1))+1 into v_cho from practice;
if(length(v_cho)==1)
v_xh:='000'+v_cho;
els if(length(v_cho)==2)
v_xh:='00'+v_cho;
els if(length(v_cho)==3)
v_xh:='0'+v_cho;
insert into practice(col1) values(v_xh);
end;
报错了,不知道怎样解决,百度又没什么分给大家了。好心人帮帮我这菜鸟!

能不错吗,表名都不一样。建的表名是practive,触发器插入的表名是pratice

before insert on practice
select to_number(max(col1))+1 into v_cho from practice; 这两句改一下应该就OK了