Re: passing parameters to multiple statements - Mailing list pgsql-general

From Konstantin Izmailov
Subject Re: passing parameters to multiple statements
Date
Msg-id 72746b5e0911170833j7e48f8b1r9921e5a0bb3f98f6@mail.gmail.com
Whole thread Raw
In response to Re: passing parameters to multiple statements  (manitou-sig@sd-9404.dedibox.fr)
Responses Re: passing parameters to multiple statements  (David Fetter <david@fetter.org>)
Re: passing parameters to multiple statements  (Thomas Kellerer <spam_eater@gmx.net>)
Re: passing parameters to multiple statements  ("Daniel Verite" <daniel@manitou-mail.org>)
List pgsql-general
Some companies have policy to stay DB agnostic, i.e. use standard SQL only. This is why they want to use multiple statements, not stored procedures.
 
I'm not familiar with RETURNING. Is this SQL standard? Can it be used for inserting a row and returning back primary key for the inserted row in one statement?
 
If PQexecParams does not support multiple statements, it needs to be extended for the support, or new function created for the purpose. If I do the change in libpq, may I submit the code to community?
 
Thank you!
Konstantin

On Mon, Nov 16, 2009 at 2:11 PM, <manitou-sig@sd-9404.dedibox.fr> wrote:
       Konstantin Izmailov wrote:

> I'm planning to use multiple statements via libpq. Before starting coding
> I'm trying to understand are there any limitations on passing parameters.
> E.g. would the following work:
>   PQexecParams(conn, "BEGIN;INSERT INTO tbl VALUES($1,$2);SELECT
> lastval();SELECT * INTO AUDIT FROM (SELECT $3, 'tbl action',
> lastval());COMMIT;", 3, ...);

No, because PQexecParams doesn't accept multiple SQL statements.

Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org

pgsql-general by date:

Previous
From: Geoffrey
Date:
Subject: Re: WAL file question
Next
From: Ivan Sergio Borgonovo
Date:
Subject: impersonating a user/ownership problems