assigning result of SELECT in TRIGGER

From: Randall Perry <rgp(at)systame(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: assigning result of SELECT in TRIGGER
Date: 2001-08-17 02:01:08
Message-ID: B7A1F323.EC1A%rgp@systame.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Upon inserting a record into the confirm table I get this error in psql:

ERROR: parser: parse error at or near "SELECT"

What am I doing wrong. Is there a proper way to get a value from a related
table.

The function and trigger defs are:

CREATE FUNCTION chk_status () RETURNS OPAQUE AS '
DECLARE
status BOOLEAN;
BEGIN
status := SELECT status FROM log WHERE log.log_no = NEW.log_no;
IF NOT status THEN
RAISE EXCEPTION ''The log entry you are trying to confirm
was not successfully forwarded and does not need confirmation'';
END IF;
END;
' LANGUAGE 'plpgsql';

CREATE TRIGGER chk_status BEFORE INSERT ON confirm FOR EACH ROW EXECUTE
PROCEDURE chk_status();

--
Randy Perry
sysTame
Mac Consulting/Sales

phn 561.589.6449
mobile email help(at)systame(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-08-17 02:13:22 Re: USING HASH considered harmful?
Previous Message Bruce Momjian 2001-08-17 01:59:02 Re: USING HASH considered harmful?