http://www.postgresql.org/
CREATE FUNCTION do_set_authorized() RETURNS TRIGGER AS $$
BEGIN
Function_Set_Authorized( OLD.id );
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER your_trigger_name_001 BEFORE UPDATE
ON your_table_name FOR EACH ROW
EXECUTE PROCEDURE do_set_authorized();
Main Topics
Browse All Topics





by: cminearPosted on 2009-09-11 at 12:22:33ID: 25312662
PostgreSQL provides the record OLD for UPDATE and DELETE triggers, and NEW for INSERT and UPDATE triggers. See the bottom of http://www.postgresql.org/ docs/8.4/i nteractive /trigger- d efinition. html
The below code should provide a simple example of the function. You would create your trigger to use 'do_set_authorized', and that function will perform the 'Function_Set_Authorized'.
If 'Function_Set_Authorized' is already a trigger function, then just use 'NEW.id' (or 'OLD.id' if id will never change for a given record) where you need to use in it 'Function_Set_Authorized'.
Select allOpen in new window