Re: prepared statements and DBD::Pg

From: Andrej <andrej(dot)groups(at)gmail(dot)com>
To: JP Fletcher <jpfletch(at)ca(dot)afilias(dot)info>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: prepared statements and DBD::Pg
Date: 2009-05-06 16:54:06
Message-ID: b35603930905060954u134ff2b7t795c7d652d8075a2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2009/5/7 JP Fletcher <jpfletch(at)ca(dot)afilias(dot)info>:
> Hi,
>
> I see different behavior with DBI/DBD::Pg (1.607/2.11.8, pg 8.1) when the
> first command in a prepared statement is 'CREATE TEMP TABLE'.
>
> For instance, this works:
>
> my $prepare_sql =<<SQL;
> CREATE TEMP TABLE foo( id int, user_id int,);
>
> INSERT INTO foo(1, 1);
>
> INSERT INTO foo(2, 2);
> SQL
>
> my $sth = $dbh->prepare($prepare_sql);
>
>
> This produces the error
>
> ERROR: cannot insert multiple commands into a prepared statement
>
Blessed be CPAN and the manuals for DBD
http://search.cpan.org/~turnstep/DBD-Pg-2.13.1/Pg.pm#prepare

WARNING: DBD::Pg now (as of version 1.40) uses true prepared
statements by sending them to the backend to be prepared by the
Postgres server. Statements that were legal before may no longer work.
See below for details.

The prepare method prepares a statement for later execution.
PostgreSQL supports prepared statements, which enables DBD::Pg to only
send the query once, and simply send the arguments for every
subsequent call to "execute". DBD::Pg can use these server-side
prepared statements, or it can just send the entire query to the
server each time. The best way is automatically chosen for each query.
This will be sufficient for most users: keep reading for a more
detailed explanation and some optional flags.

Queries that do not begin with the word "SELECT", "INSERT", "UPDATE",
or "DELETE" are never sent as server-side prepared statements.

Cheers,
Andrej

--
Please don't top post, and don't use HTML e-Mail :} Make your quotes concise.

http://www.american.edu/econ/notes/htmlmail.htm

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robert Gravsjö 2009-05-06 17:59:04 Re: how to select temp table
Previous Message Joshua D. Drake 2009-05-06 16:51:12 Re: Yahoo Everest MPP - open source release?