Re: [GENERAL] Function not inserting rows - Mailing list pgsql-general

From David G. Johnston
Subject Re: [GENERAL] Function not inserting rows
Date
Msg-id CAKFQuwawVk7ZauoTeYrm7eaW0+5PGdZ2UCQs6zPOzhxfh1kx_g@mail.gmail.com
Whole thread Raw
In response to [GENERAL] Function not inserting rows  (Frank Foerster <ivaypoint@gmail.com>)
List pgsql-general
On Wed, Aug 23, 2017 at 8:23 AM, Frank Foerster <ivaypoint@gmail.com> wrote:

        sql = "select * from api_dev.add_texts_to_item( %s, %s ); x x"
i get the following python-error:
psycopg2.ProgrammingError: FEHLER:  Syntaxfehler bei »s«
LINE 1: ...dd_texts_to_item( 1234, ARRAY['PSYCOPG1', 'PSYCOPG2'] ); s s

But the created statement looks syntax-wise identical to the pgadmin-statement (except for the forced error of course):

select * from api_dev.add_texts_to_item( 444, array['PGADM1', 'PGADM2'] );


Try adding the following to your function to see what your function sees as being the value of the p_item_texts argument.

RAISE ERROR '%', p_item_texts;

I'm assuming that:

self.cur_.execute( sql, (doc_id, isins, ) )

performs dynamic string substitution as opposed to generating a prepared statement.  The placeholder values supplied to a prepared statement are treated as literals.

You may also want turn on statement logging in the server.

David J.

pgsql-general by date:

Previous
From: Frank Foerster
Date:
Subject: [GENERAL] Function not inserting rows
Next
From: Daniele Varrazzo
Date:
Subject: Re: [GENERAL] Function not inserting rows