Re: Function not inserting rows

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Frank Foerster <ivaypoint(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Function not inserting rows
Date: 2017-08-23 16:04:47
Message-ID: CAKFQuwawVk7ZauoTeYrm7eaW0+5PGdZ2UCQs6zPOzhxfh1kx_g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Aug 23, 2017 at 8:23 AM, Frank Foerster <ivaypoint(at)gmail(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Daniele Varrazzo 2017-08-23 16:20:32 Re: Function not inserting rows
Previous Message Frank Foerster 2017-08-23 15:23:15 Function not inserting rows