Re: Insert works but fails for merge - Mailing list pgsql-general

From Greg Sabino Mullane
Subject Re: Insert works but fails for merge
Date
Msg-id CAKAnmmK2iECtmatmiOq_JE03K5dFPmugy_CqbGAs-SR-3U1bbw@mail.gmail.com
Whole thread Raw
In response to Re: Insert works but fails for merge  (Greg Sabino Mullane <htamfids@gmail.com>)
List pgsql-general
I just remembered that one of the complaints was not wanting to worry about looking up the data types. In my previous example, you can also leave out the types and Postgres will do the right thing. I prefer the explicit data type version for clarity, but though I would provide this one for completeness:

prepare foo as with x as (update tab1 set mid=$2 where id=$1 returning 1)
  insert into tab1 select $1,$2,$3 where not exists (select 1 from x);

Cheers,
Greg

pgsql-general by date:

Previous
From: Ron Johnson
Date:
Subject: Re: PG Dump on 11 - Restore on 16 - is possible?
Next
From: Greg Sabino Mullane
Date:
Subject: Re: Column type modification in big tables