From: | "Geoff" <geoff(at)metalogicplc(dot)com> |
---|---|
To: | "Pgsql-Admin (E-mail)" <pgsql-admin(at)postgresql(dot)org> |
Subject: | Function Problem |
Date: | 2002-12-11 12:38:50 |
Message-ID: | FDCF842C8B1DD311833C0090277C04B518C27B@augusta.planmatics.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
I've got this function which works off a trigger.
The trigger is calling the function ok, but I get this error.
<error>
NOTICE: plpgsql: ERROR during compile of mon_sum_update near line 43
ERROR: parse error at or near ""
Now line 43 is this either the return null or end statement at the end of
the function...
RETURN NULL;
END
Can anyone see what I've done wrong in there?
TIA
Geoff
Here is my trigger and function.
trigger
======
CREATE TRIGGER doc_status_trig AFTER UPDATE ON document_status FOR EACH ROW
EXECUTE PROCEDURE mon_sum_update()
function
======
CREATE FUNCTION mon_sum_upd () RETURN OPAQUE AS '
BEGIN
-- Ensure we have a record that is valid .
IF ( ! NEW.direction && NEW.direction && NEW.msgtype && NEW.status )
THEN
RETURN NULL;
-- Ensure the record exists in the monitor_summary table.
IF ( ! EXISTS SELECT * FROM monitor_summary WHERE unit = NEW.unit and
msgtype = NEW.msgtype and direction = NEW.direction and status =
NEW.status )
THEN
INSERT INTO monitor_summary ( version, cdate, mdate, direction, unit,
msgtype, status ) VALUES ( 1, 'now', 'now', 'NEW.direction', 'NEW.unit',
'NEW.msgtype', 'NEW.status' );
-- Ensure OLD and NEW status's are different.
IF ( NEW.status == OLD.status )
THEN
RETURN NULL;
-- Update the OLD status record. ( -1 )
UPDATE monitor_summary
SET
total = total - 1
WHERE
direction = OLD.direction AND unit = OLD.unit AND msgtype = OLD.msgtype AND
status = OLD.status ;
-- Update the NEW status record. ( +1 )
UPDATE monitor_summary
SET
total = total + 1
WHERE
direction = OLD.direction AND unit = OLD.unit AND msgtype = OLD.msgtype AND
status = NEW.status ;
RETURN NULL;
END
' LANGUAGE 'plpgsql' ;
I'm using pgAdminII to insert this function, and it goes in ok..
- Geoff Ellis
- +44(0)2476678484
.-----------------------------------------------------------------.
/ .-. This message is intended only for the person or .-. \
| / \ entity to which it is addressed and may contain / \ |
| |\_. | confidential and/or privileged material. Any | ._/| |
|\| | /| review, retransmission, dissemination or other |\ | |/|
| `---' | use of, or taking of any action in reliance upon, | `---' |
| | this information by persons or entities other than | |
| | the intended recipient is prohibited. If you get | |
| | this message in error please contact the sender | |
| | by return e-mail and delete the message from your | |
| | computer. Any opinions contained in this message | |
| | are those of the author and are not given or | |
| | endorsed by Metalogic PLC unless otherwise clearly | |
| | indicated in this message and the authority of the | |
| | author to bind Metalogic is duly verified. | |
| | | |
| | Metalogic PLC accepts no liability for any errors | |
| | or omissions in the context of this message which | |
| | arise as a result of internet transmission. | |
| |-----------------------------------------------------| |
\ | | /
\ / \ /
`---' `---'
From | Date | Subject | |
---|---|---|---|
Next Message | Jakub Ouhrabka | 2002-12-11 12:56:40 | Re: Function Problem |
Previous Message | Rajesh Kumar Mallah. | 2002-12-11 06:50:40 | Re: ALTER DOMAIN patch .... |