Hi,
I would like to add the following support for a trigger.
This implementation enables to create a trigger efficiently
in single command.
It had been discussed before. The link is as shown below.
https://www.postgresql.org/message-id/CAA-aLv4m%3Df9cc1zcUzM49pE8%2B2NpytUDraTgfBmkTOkMN_wO2w%40mail.gmail.com
Currently, PostgreSQL requires two steps to create a trigger.
1. to create a function.
2. to define a trigger with action specified via already created function.
Supporting 'AS' clause in CREATE TRIGGER syntax will enable the option of
defining the trigger in single command.
As a bonus, it will be compatible with oracle.
Also, the optional clause 'OR REPLACE' is required as below.
https://www.postgresql.org/message-id/CAA-aLv6KYgVt2CwaRdcnptzWVngEm72Cp4mUFnF-MfeH0gS91g%40mail.gmail.com
Currently, to change the definition of a trigger, trigger needs to
be dropped first before creating it again with new definition.
To change the definition of a function in CREATE TRIGGER syntax,
trigger needs to be dropped first before creating it again with new definition, too!
So, we need to add the optional clause 'OR REPLACE'.
Adding the optional clauses 'AS' and 'OR REPLACE' in CREATE TRIGGER syntax gives
the comfort of defining the trigger or redefining the trigger definition
which contains the function definition in single command.
Here is the syntax based on the previous discussion.
CREATE [ OR REPLACE ] [ CONSTRAINT ] TRIGGER name { BEFORE | AFTER | INSTEAD OF } { event [ OR ... ] } ON
table_name [ FROM referenced_table_name ] [ NOT DEFERRABLE | [ DEFERRABLE ] { INITIALLY IMMEDIATE | INITIALLY
DEFERRED} ] [ FOR [ EACH ] { ROW | STATEMENT } ] [ WHEN ( condition ) ] { EXECUTE PROCEDURE function_name (
arguments) | AS 'trigger function definition' [ LANGUAGE lang_name ] [ SET configuration_parameter { TO value
|= value | FROM CURRENT }] }
If you have your opinion on this concept, please give me it.
Regards,
Okano Naoki
Fujitsu