Search Postgresql Archives

Re: Insert data if it is not existing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/23/2018 09:39 PM, David G. Johnston wrote:
On Wednesday, May 23, 2018, Adrian Klaver <adrian.klaver@xxxxxxxxxxx <mailto:adrian.klaver@xxxxxxxxxxx>> 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.klaver@xxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux