From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | rod(at)iol(dot)ie |
Cc: | Dennis Ryan <dennis(at)kabonkulator(dot)com>, "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Function Syntax Help |
Date: | 2014-06-26 16:39:50 |
Message-ID: | CAFj8pRA23ttSBD-xBkaA2tKf+BXyGxpUcQdM0OxABydtso+EXg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2014-06-26 18:26 GMT+02:00 Raymond O'Donnell <rod(at)iol(dot)ie>:
> On 25/06/2014 23:19, Dennis Ryan wrote:
> > 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.*);
>
> The problem is the semi-colon after (NEW.*). There isn't one inside a
> CASE construct.
>
no, using INSERT inside SQL CASE is not possible (with or without
semicolon), but inside PL/pgSQL it is ok. But PL/pgSQL statement uses END
CASE like others END .. END IF, END LOOP,
Regards
Pavel
>
> Ray.
>
>
> > END;
> > RETURN NULL;
> > END;
> > $$ LANGUAGE plpgsql;
> >
> >
> > ERROR: syntax error at or near ";"
> > LINE 7: END;
>
>
> --
> Raymond O'Donnell :: Galway :: Ireland
> rod(at)iol(dot)ie
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | Karthik Iyer | 2014-06-26 17:37:02 | Re: DATA corruption after promoting slave to master |
Previous Message | Raymond O'Donnell | 2014-06-26 16:38:54 | Re: Function Syntax Help |