Subject | R: [firebird-support] Triggers( after delete ) not working |
---|---|
Author | Marco Lauria |
Post date | 2004-04-27T20:11:15Z |
The beviour is correct infact in DELETE condition the new.* values are set to NULL by design
(you can read it in the docs directory of your firebird installation).
In DELETING only old.* have values while new.* are set to NULL in INSERTING only new.* have values
While old.* are set to NULL in UPDATING both new.* and old.* are filled.
Regards
Marco
Da: Arn [mailto:arn@...]
Inviato: martedì 27 aprile 2004 20.55
A: firebird-support@yahoogroups.com
Oggetto: [firebird-support] Triggers( after delete ) not working
Hi All.
I have this trigger:
CREATE TRIGGER ASSUNZIONI_AIUD0 FOR ASSUNZIONI
ACTIVE AFTER INSERT OR UPDATE OR DELETE POSITION 0
AS
declare data_assunzione date;
begin
-- select first date from a table
select first 1 data_assunzione from assunzioni
where coll_nominativo = new.coll_nominativo
order by data_assunzione desc
into :data_assunzione;
-- write the date in another table
update personale set data_assunzione = :data_assunzione where mycode =
new.coll_nominativo;
/* coll_nominativo is the foreign key */
end
It works ONLY After Insert and after update.
In after DELETE it fails:
So I had change it into:
CREATE TRIGGER ASSUNZIONI_AIUD0 FOR ASSUNZIONI
ACTIVE AFTER INSERT OR UPDATE OR DELETE POSITION 0
AS
declare data_assunzione date;
begin
if ( ( inserting ) or ( updating ) ) then begin /* 1 */
select first 1 data_assunzione from assunzioni
where coll_nominativo = new.coll_nominativo
order by data_assunzione desc
into :data_assunzione;
--
update personale set data_assunzione = :data_assunzione where mycode =
new.coll_nominativo;
end /* 1 */
if ( deleting ) then begin /* 1 */
select first 1 data_assunzione from assunzioni
where coll_nominativo = old.coll_nominativo
order by data_assunzione desc
into :data_assunzione;
--
update personale set data_assunzione = :data_assunzione where mycode =
old.coll_nominativo;
end /* 1 */
end
The last works fine.
I think there is a problem in.
Anyone has hints?
TIA
Ciao
Arnaldo
________________________________
Yahoo! Groups Links
* To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/
* To unsubscribe from this group, send an email to:
firebird-support-unsubscribe@yahoogroups.com <mailto:firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe>
* Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> .
[Non-text portions of this message have been removed]
(you can read it in the docs directory of your firebird installation).
In DELETING only old.* have values while new.* are set to NULL in INSERTING only new.* have values
While old.* are set to NULL in UPDATING both new.* and old.* are filled.
Regards
Marco
Da: Arn [mailto:arn@...]
Inviato: martedì 27 aprile 2004 20.55
A: firebird-support@yahoogroups.com
Oggetto: [firebird-support] Triggers( after delete ) not working
Hi All.
I have this trigger:
CREATE TRIGGER ASSUNZIONI_AIUD0 FOR ASSUNZIONI
ACTIVE AFTER INSERT OR UPDATE OR DELETE POSITION 0
AS
declare data_assunzione date;
begin
-- select first date from a table
select first 1 data_assunzione from assunzioni
where coll_nominativo = new.coll_nominativo
order by data_assunzione desc
into :data_assunzione;
-- write the date in another table
update personale set data_assunzione = :data_assunzione where mycode =
new.coll_nominativo;
/* coll_nominativo is the foreign key */
end
It works ONLY After Insert and after update.
In after DELETE it fails:
So I had change it into:
CREATE TRIGGER ASSUNZIONI_AIUD0 FOR ASSUNZIONI
ACTIVE AFTER INSERT OR UPDATE OR DELETE POSITION 0
AS
declare data_assunzione date;
begin
if ( ( inserting ) or ( updating ) ) then begin /* 1 */
select first 1 data_assunzione from assunzioni
where coll_nominativo = new.coll_nominativo
order by data_assunzione desc
into :data_assunzione;
--
update personale set data_assunzione = :data_assunzione where mycode =
new.coll_nominativo;
end /* 1 */
if ( deleting ) then begin /* 1 */
select first 1 data_assunzione from assunzioni
where coll_nominativo = old.coll_nominativo
order by data_assunzione desc
into :data_assunzione;
--
update personale set data_assunzione = :data_assunzione where mycode =
old.coll_nominativo;
end /* 1 */
end
The last works fine.
I think there is a problem in.
Anyone has hints?
TIA
Ciao
Arnaldo
________________________________
Yahoo! Groups Links
* To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/
* To unsubscribe from this group, send an email to:
firebird-support-unsubscribe@yahoogroups.com <mailto:firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe>
* Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> .
[Non-text portions of this message have been removed]