Function Syntax Help

From: Dennis Ryan <dennis(at)kabonkulator(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Function Syntax Help
Date: 2014-06-25 22:19:43
Message-ID: E05576F4-502F-4AA8-AEF2-E402231D6B9F@kabonkulator.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I having trouble with correct syntax to get this trigger function to compile. I have tried every combination of removing the ‘;’ characters but the function will not compile. Can someone tell me what I am doing wrong, I am stumped. I will be adding addition when clauses the case statement once I get this simplified version to compile.

I am using 9.3.4, both postgres and psql.

CREATE OR REPLACE FUNCTION sn_dm_b.pm_insert_trigger()
RETURNS TRIGGER AS $$
BEGIN
CASE
WHEN NEW.period = 201001
THEN INSERT INTO sn_dm_b.pm201001 VALUES (NEW.*);
END;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;

ERROR: syntax error at or near ";"
LINE 7: END;

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John Lumby 2014-06-25 23:01:26 Re: Extended Prefetching using Asynchronous IO - proposal and patch
Previous Message Andres Freund 2014-06-25 21:17:53 Re: Extended Prefetching using Asynchronous IO - proposal and patch