From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Shaun Thomas <sthomas(at)optionshouse(dot)com> |
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:37:00 |
Message-ID: | CAFj8pRA2EAkEJyLrx-FBVN=JV4M6NsJKgihTzcArDQ1Aa_5RPw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2014-06-26 18:28 GMT+02:00 Shaun Thomas <sthomas(at)optionshouse(dot)com>:
> On 06/25/2014 05:19 PM, Dennis Ryan wrote:
>
> CASE
>> WHEN NEW.period = 201001
>> THEN INSERT INTO sn_dm_b.pm201001 VALUES (NEW.*);
>> END;
>>
>
> You can't just have a bare CASE statement in plpgsql. Try this:
>
>
> CREATE OR REPLACE FUNCTION sn_dm_b.pm_insert_trigger()
> RETURNS TRIGGER AS $$
> BEGIN
> IF NEW.period = 201001 THEN
>
> INSERT INTO sn_dm_b.pm201001 VALUES (NEW.*);
> END IF;
>
> RETURN NULL;
> END;
> $$ LANGUAGE plpgsql;
>
or use a plpgsql case
http://www.postgresql.org/docs/9.3/static/plpgsql-control-structures.html#PLPGSQL-CONDITIONALS
Regards
Pavel
>
> --
> Shaun Thomas
> OptionsHouse, LLC | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604
> 312-676-8870
> sthomas(at)optionshouse(dot)com
>
> ______________________________________________
>
> See http://www.peak6.com/email_disclaimer/ for terms and conditions
> related to this email
>
>
> --
> 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 | Raymond O'Donnell | 2014-06-26 16:38:54 | Re: Function Syntax Help |
Previous Message | Shaun Thomas | 2014-06-26 16:28:28 | Re: Function Syntax Help |