Re: [Pgjdbc-commit] ERROR: syntax error at or near "$1" - Mailing list pgsql-jdbc

From Tom Lane
Subject Re: [Pgjdbc-commit] ERROR: syntax error at or near "$1"
Date
Msg-id 25249.1131295774@sss.pgh.pa.us
Whole thread Raw
In response to Re: [Pgjdbc-commit] ERROR: syntax error at or near "$1"  (Dave Cramer <pg@fastcrypt.com>)
List pgsql-jdbc
Dave Cramer <pg@fastcrypt.com> writes:
> On 6-Nov-05, at 9:01 AM, William Harris wrote:
>> intervalStmt = con.prepareStatement( "select current_date +
>> (interval ?)" );

The above is not and never has been correct syntax; the fact that it
failed to fail in previous JDBC versions was accidental.  The syntax
    interval 'literal'
(or in general any type name followed by a string literal) is defined
to work only for literals.  The correct way to do this is either
    CAST(? AS interval)        (SQL standard)
    ?::interval            (Postgres-ism)
See
http://www.postgresql.org/docs/8.0/static/sql-syntax.html#SQL-SYNTAX-CONSTANTS
particularly the note at the end of section 4.1.2.5.

Fraid you're out of luck on the SET example though :-(

            regards, tom lane

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: [Pgjdbc-commit] ERROR: syntax error at or near "$1"
Next
From: Heikki Linnakangas
Date:
Subject: Re: Stable JDBC drivers for 8.1