Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with a Trigger Statement

Status
Not open for further replies.

NateUNI

MIS
Jan 3, 2002
132
US
I want the following trigger to update a related table when ever a record is inserted/updated. I have the following trigger:

CREATE TRIGGER update_status
AFTER INSERT OR UPDATE
ON public."Bug Status"
FOR EACH ROW
EXECUTE PROCEDURE public.update_status();

Which Calls this function:

CREATE OR REPLACE FUNCTION public.update_status()
RETURNS trigger AS
'
BEGIN
UPDATE public."BugTracking" SET status = NEW.status WHERE "BugTracking"."Tracking Number" = NEW."Tracking Number"
END;
'
LANGUAGE 'plpgsql' VOLATILE;


When I go to insert a record I receive the following error:

ERROR: syntax error at or near ""
CONTEXT: compile of PL/pgSQL function "update_status" near line 4

Any one know where I am going wrong?? Thanks!
 
I see two problems

1. you should put ; at the end of the update statement
2. you should do return NEW; before the END;

(first one will repair the syntax error, the second will repair the next apearing error
ERROR: control reached end of trigger procedure without RETURN
)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top