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: (view raw, whole thread or download thread mbox)
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:


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 


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-2017 The PostgreSQL Global Development Group