--功能说明:当宾馆插入数据,或修改宾馆名称时,触发器自动生成宾馆名称的拼音名称.
--但现在此功能不功作,不知是否NEW.HOTEL_NO 这里有问题呢.create or replace trigger TRG_TEST_HOTEL_PINYIN
after insert or update on TEST_HOTEL for each row
begin
if inserting then
update TEST_HOTEL set n_hotel_pinyin=get_pinyin(:new.hotel_name)
where hotel_no= :new.hotel_no;
commit;
else -- if updating
update TEST_HOTEL set n_hotel_pinyin=get_pinyin(:new.hotel_name)
where hotel_no= :old.hotel_no;
commit;
end if;
exception
when others then
htp.print('error='||SQLERRM);
end;
--但现在此功能不功作,不知是否NEW.HOTEL_NO 这里有问题呢.create or replace trigger TRG_TEST_HOTEL_PINYIN
after insert or update on TEST_HOTEL for each row
begin
if inserting then
update TEST_HOTEL set n_hotel_pinyin=get_pinyin(:new.hotel_name)
where hotel_no= :new.hotel_no;
commit;
else -- if updating
update TEST_HOTEL set n_hotel_pinyin=get_pinyin(:new.hotel_name)
where hotel_no= :old.hotel_no;
commit;
end if;
exception
when others then
htp.print('error='||SQLERRM);
end;
create or replace trigger TRG_TEST_HOTEL_PINYIN
before insert or update
REFERENCING OLD AS OLD NEW AS NEW
on TEST_HOTEL for each row
begin
:new.n_hotel_pinyin=get_pinyin(:new.hotel_name);
exception
when others then
htp.print('error=' ¦ ¦SQLERRM);
end;
'REFERENCING OLD AS OLD NEW AS NEW ' 这句代码已去掉了.修改如下:测试通过.
create or replace trigger TRG_TEST_HOTEL_PINYIN
BEFORE insert or update
on TEST_HOTEL for each row
begin
:new.n_hotel_pinyin:=get_pinyin(:new.hotel_name);
exception
when others then
htp.print('error='||SQLERRM);
end;