From: | Kris Jurka <books(at)ejurka(dot)com> |
---|---|
To: | Christophe Janton <christophe(dot)janton(at)gmail(dot)com> |
Cc: | pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: Bug report (with solution) on org.postgresql.jdbc2.EscapedFunctions |
Date: | 2008-11-16 12:15:41 |
Message-ID: | 49200EED.1070004@ejurka.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
I have applied your fix to CVS for 8.2 and up.
Kris Jurka
Christophe Janton wrote:
> Make a PreparedStatement like this :
>
> select *
> from TABLE t
> where
> t.col < {fn timestampadd(SQL_TSI_SECOND,?,now())}
>
> this will be convert to :
>
> select *
> from TABLE t
> where
> t.col < (interval '? second' + now())
>
> then when, in java, you will set the parameter on the PreparedStatement
> : the jdbc driver will raise an exception like wrong parameter index.
> This exception is because the parameters <?> is surround with simple
> quote and so not recognise as parameter.
>
> I suggest that the conversion have to be :
>
> select *
> from TABLE t
> where
> t.col < (CAST(? || ' second' as interval) + now())
>
> I hope this will help you.
>
> 2008/11/7 Kris Jurka <books(at)ejurka(dot)com <mailto:books(at)ejurka(dot)com>>
>
>
>
> On Wed, 5 Nov 2008, Christophe Janton wrote:
>
> org.postgresql.jdbc2.EscapedFunctions.constantToInterval method.
>
> Value parameter have not to contain an integer. For example : ?
> a prepared
> statment JDBC parameter
>
> each return of constantToInterval method like :
> *return "'"+value+" day'";*
> must be replaced by :
> *return "CAST(" + value + " || ' day' as interval)";*
>
> This modification required to remove the interval keyword of all
> method
> using constantToInterval.
>
>
> I'm not sure I fully understand the problem. Can you provide a
> testcase to demonstrate the failure?
>
> Kris Jurka
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2008-11-16 12:27:17 | Re: passing user defined data types to stored procedures |
Previous Message | Jay Howard | 2008-11-16 02:29:40 | Re: passing user defined data types to stored procedures |