Skip site navigation (1) Skip section navigation (2)

Re: PreparedStatement setObject

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Kobus Walters <kobus(at)iveri(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: PreparedStatement setObject
Date: 2005-02-14 06:36:10
Message-ID: 421046DA.4040706@opencloud.com (view raw or flat)
Thread:
Lists: pgsql-bugs
Kobus Walters wrote:

> Create a prepared statement with sql "select localtimestamp - time ?". Call setObject(1, java.lang.String) with the String value "00:00:00" for instance. In version 7 this gets executed as "select localtimestamp - time '00:00:00'", while version 8 try to execute it as "select localtimestamp - time 00:00:00", which of cause fails since the quotes are missing.

I can't reproduce this. With the 8.0-310 driver against an 8.0.0 server, 
I get a syntax error with that query:

   ERROR: syntax error at or near "$1"

The query sent by the driver is:

   SELECT LOCALTIMESTAMP - TIME $1

which the backend does not like. The change in behaviour from 7.4-era 
drivers is because the 8.0 driver pushes handling of parameters to the 
server, so you have to follow the server's rules for where you may place 
parameters. Apparently, after TIME isn't one of those places.

To use a string as a time parameter, see the examples in my test code 
(attached).

-O

Attachment: TestTime.java
Description: text/plain (836 bytes)

In response to

pgsql-bugs by date

Next:From: Tom LaneDate: 2005-02-14 06:52:22
Subject: Re: Bug in ALTER LANGUAGE ... RENAME TO ...;
Previous:From: Tom LaneDate: 2005-02-14 06:19:06
Subject: Re: Bug in ALTER LANGUAGE ... RENAME TO ...;

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group