From: Kris Jurka <books@ejurka.com>
To: Jie Liang <jie@stbernard.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Prepare Statement
Date: Thu, 17 Jun 2004 17:25:54 -0500 (EST)
Message-ID: <Pine.BSO.4.56.0406171720310.16501@leary.csoft.net> (raw)
In-Reply-To: <E7E213858379814A9AE48CA6754F5ECB03451923@mail01.stbernard.com>
References: <E7E213858379814A9AE48CA6754F5ECB03451923@mail01.stbernard.com>
On Thu, 17 Jun 2004, Jie Liang wrote:
> Kris,
> You are right, I modified that piece of code a little bit,
> CallableStatement stmt = conn.prepareCall("{?=call chr(?)}");
> Then my log file were:
> Select * from chr(65) as result;
> Select * from chr(66) as result;
> ......
> However, if I use:
> PrepareStatement stmt = conn.prepareStatement("SELECT chr(?)");
> Then my log file are same as yours.i.e. it use PREPARE and EXECUTE.
>
> So, I am getting confusion.
> I think CallableStatement is extended from PrepareStatement, it should
> have same behaviou.
>
What's happening here is that you can only use prepared statements for
certain operations. You can't for example prepare a CREATE TABLE
statement. The driver examines the query to see if it is valid for
preparing and I believe the problem here is that with a callable statement
it is examinging the query with "call" before it is transformed to a
SELECT, so it doesn't recognize it as a preparable. This looks like a bug
to me.
Kris Jurka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: books@ejurka.com, jie@stbernard.com, tgl@sss.pgh.pa.us, pgsql-jdbc@postgresql.org
Subject: Re: Prepare Statement
In-Reply-To: <Pine.BSO.4.56.0406171720310.16501@leary.csoft.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox