请帮着看一下这条语句有没有问题
我写一个触发器,编译成功了,但在往表中填写数据时,总是报下面这条语句出错,但我不清楚什么地方有问题
select dwmc into DNAME2 from dw where dwdm = substr(:new.dwdm,1,10);
下面是整个的触发器
create or replace trigger trg_dw
before INSERT OR UPDATE OR DELETE ON dw
FOR EACH ROW
DECLARE
DNAME VARCHAR2(50);
DNAME1 VARCHAR2(50);
DNAME2 VARCHAR2(50);
BEGIN
IF INSERTING THEN
IF LENGTH(:new.dwdm)=10 THEN
DNAME := '公司-> '||:new.dwmc;
ELSIF LENGTH(:new.dwdm)=15 THEN
select dwmc into DNAME2 from dw where dwdm = substr(:new.dwdm,1,10);
DNAME := '公司-> '||DNAME2|| '-> '||:new.dwmc;
ELSE
DNAME :=:new.dwmc;
END IF;
DNAME1 := '0 '||SUBSTR(:new.dwdm,2,LENGTH(:new.dwdm));
INSERT INTO um (ocode,oname,oorder,displayname) VALUES(:new.dwdm,:new.dwmc,DNAME1,DNAME);
ELSIF UPDATING THEN
IF LENGTH(:new.dwdm)=10 THEN
DNAME := '公司-> '||:new.dwmc;
ELSIF LENGTH(:new.dwdm)=15 THEN
select dwmc into DNAME2 from dw where dwdm = substr(:new.dwdm,1,10);
DNAME := '公司-> '||DNAME2|| '-> '||:new.dwmc;
ELSE
DNAME :=:new.dwmc;
END IF;
DNAME1 := '0 '||SUBSTR(:new.dwdm,2,LENGTH(:new.dwdm));
UPDATE um SET ocode=:new.dwdm,oname=:new.dwmc,oorder=DNAME1,displayname=DNAME where ocode=:old.dwdm;
ELSIF DELETING THEN
DELETE FROM um WHERE ocode=:old.dwdm;
END IF;
END;
------解决方案--------------------你把那条语句里面的:new.dwdm用一个变量过渡一下