Re: passing parameters to multiple statements

From: Konstantin Izmailov <pgfizm(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: passing parameters to multiple statements
Date: 2009-11-17 16:33:05
Message-ID: 72746b5e0911170833j7e48f8b1r9921e5a0bb3f98f6@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)sd-9404(dot)dedibox(dot)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
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ivan Sergio Borgonovo 2009-11-17 16:36:09 impersonating a user/ownership problems
Previous Message Geoffrey 2009-11-17 15:36:38 Re: WAL file question