From: | Greg Sabino Mullane <htamfids(at)gmail(dot)com> |
---|---|
To: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
Cc: | Alban Hertroys <haramrae(at)gmail(dot)com>, yudhi s <learnerdatabase99(at)gmail(dot)com>, David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Insert works but fails for merge |
Date: | 2024-08-13 13:55:18 |
Message-ID: | CAKAnmmK2iECtmatmiOq_JE03K5dFPmugy_CqbGAs-SR-3U1bbw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Sabino Mullane | 2024-08-13 14:08:52 | Re: Column type modification in big tables |
Previous Message | Ron Johnson | 2024-08-13 12:00:23 | Re: PG Dump on 11 - Restore on 16 - is possible? |