Re: Using Insert with case - Mailing list pgsql-general

From Chris Angelico
Subject Re: Using Insert with case
Date
Msg-id CAPTjJmq7n2H-=S1hDbnzLVFKeWn2LRfSam4ORnM4BvqZtNZSaw@mail.gmail.com
Whole thread Raw
In response to Using Insert with case  ("Bob Pawley" <rjpawley@shaw.ca>)
List pgsql-general
On Wed, Aug 8, 2012 at 8:26 AM, Bob Pawley <rjpawley@shaw.ca> wrote:
> Hi
>
> select
> case when somevariable = 2
>     then (insert into pipe (line) ...
>
> I am attempting to use the above. However, with or without the enclosing
> brackets I get a syntax error on the word into.

Utterly untested, but does it work if you put a RETURNING clause onto
the INSERT? That would make it functionally similar to a SELECT, a
technique that works for me in other situations.

ChrisA

pgsql-general by date:

Previous
From: "Bob Pawley"
Date:
Subject: Using Insert with case
Next
From: Alban Hertroys
Date:
Subject: Re: Using Insert with case