From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | tango ward <tangoward15(at)gmail(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Insert data if it is not existing |
Date: | 2018-05-24 12:57:52 |
Message-ID: | dde6f4f8-cdb5-781d-f037-595917fa0c9d@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 05/23/2018 09:39 PM, David G. Johnston wrote:
> On Wednesday, May 23, 2018, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com
> <mailto:adrian(dot)klaver(at)aklaver(dot)com>> wrote:
>
>
> '''INSERT INTO my_table(name, age)
> SELECT %s, %s
> WHERE NOT EXISTS(SELECT name FROM my_table WHERE name=%s)''',
> ('Scott', 23)
>
>
> I doubt that worked, you have three parameter markers(%s) and two
> parameter values. Not only that two of the markers are for identifiers.
>
>
> The count is indeed off but the two markers after the main select are
> literals, not identifiers. As is the one being compared to name.
>
> SELECT 'Scott', 23;
>
> is a valid query.
Yeah, forgot about that.
>
> David J.
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Karthick Damodar | 2018-05-24 13:31:59 | RE:Extension/Language of plPerl in PostgreSQL |
Previous Message | David G. Johnston | 2018-05-24 12:17:52 | Re: Parameter placeholders, $n vs ? |