- 论坛徽章:
- 0
|
原帖由 A-Liang 于 2006-9-13 09:14 发表
目前想把oracle的trigger设计成这样:
1. 向数据库的table中插入record后触发
2. 将插入的record读出来,发送给监听程序。
3. 如果commit前,插入多条record, 也希望触发trigger多次,而不是一次。
现 ...
你oracle版本?
创建after insert的trigger,:new是不能使用的。你创建的是before insert。对于insert trigger来说,old 伪变量本来就不存在。
我们可以做个测试:
CREATE OR REPLACE TRIGGER INSERTTRIGGER_SAMP_TEST
AFTER INSERT
ON SAMP_TEST
FOR EACH ROW
DECLARE
msg_send VARCHAR2(512);
BEGIN
--msg_send := :new.SAMP_REC1 || '#' || :new.SAMP_REC2|| '#' || :new.SAMP_REC3;\
DBMS_OUTPUT.PUT_LINE ('insert table once ...');
msg_send := 'insert table once ...';
DBMS_ALERT.SIGNAL('InsertRecordAlertSamp', msg_send);
END;
/
然后在sqlplus执行insert操作测试,先set serveroutput on
结果?如果还是只触发一次,将DBMS_ALERT.SIGNAL('InsertRecordAlertSamp', msg_send);注释掉,再测试。 |
|