Re: Function Syntax Help

From: Shaun Thomas <sthomas(at)optionshouse(dot)com>
To: Dennis Ryan <dennis(at)kabonkulator(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Function Syntax Help
Date: 2014-06-26 16:28:28
Message-ID: 53AC4A2C.1000801@optionshouse.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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;

--
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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2014-06-26 16:37:00 Re: Function Syntax Help
Previous Message Pavel Stehule 2014-06-26 16:27:41 Re: Function Syntax Help