Search Postgresql Archives

Re: Function Syntax Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






2014-06-26 18:28 GMT+02:00 Shaun Thomas <sthomas@xxxxxxxxxxxxxxxx>:
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@xxxxxxxxxxxxxxxx

______________________________________________

See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux