Thread: Problem with postgreSQL triggers

Problem with postgreSQL triggers

From
Sébastien BOUTELOUP
Date:
Hello,
I have some trouble with postgresql triggers: 
I just want to execute an sql query (insert) in a trigger and I don't manage to
write the corresponding procedure.
Is it possible to use the traditionnal structure:               create trigger <trigger name>              before
deleteon <table name>              for each row              BEGIN              query;              END;    ?
 
Otherwise, how can I deal with the "execute procedure <procedure name>"
statement?
Thanks

-----------------------------------------
S�bastien BOUTELOUP
stagiaire � l'UFR DGES
�l�ve ing�nieur 2�me ann�e ENSIMAG

t�l: 04.76.51.49.61


Re: [SQL] Problem with postgreSQL triggers

From
"Emils Klotins"
Date:
> to use the traditionnal structure: 
>                create trigger <trigger name>
>                before delete on <table name>
>                for each row
>                BEGIN
>                query;
>                END;    ?
> Otherwise, how can I deal with the "execute procedure <procedure
> name>" statement? Thanks
As from postgresql.org website:

CREATE TRIGGER name { BEFORE | AFTER } { event [OR 
...] } ON table FOR EACH { ROW | STATEMENT } 
EXECUTE PROCEDURE ( arguments ) 
you should apparently create a procedure/function much of the same 
as with: 
CREATE FUNCTION name ( [ ftype [, ...] ] ) RETURNS rtype 
AS definition LANGUAGE 'langname' 

BEGIN/END I think would be restricted to transactions. And therefore 
would be considered reserved words?

Just my idea. Haven't used triggers in Pg yet myself. You might see 
under contributed things / refint (referential integrity) package 
somewhere, there should be lots of triggers I assume.



Emils Klotins       e-mail: emils@mail.usis.bkc.lv
Systems Manager     URL: http://www.usis.bkc.lv/
USIS Riga           7 Smilsu Str., Riga LV1050, LATVIA