Re: Using Insert with case

From: Chris Angelico <rosuav(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Using Insert with case
Date: 2012-08-07 22:34:13
Message-ID: CAPTjJmq7n2H-=S1hDbnzLVFKeWn2LRfSam4ORnM4BvqZtNZSaw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Aug 8, 2012 at 8:26 AM, Bob Pawley <rjpawley(at)shaw(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2012-08-07 22:40:01 Re: Using Insert with case
Previous Message Bob Pawley 2012-08-07 22:26:25 Using Insert with case