Re: Getting value of bind variables

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Jayadevan M <Jayadevan(dot)Maymala(at)ibsplc(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Getting value of bind variables
Date: 2011-08-23 07:32:15
Message-ID: 20110823073215.GA18950@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Aug 23, 2011 at 09:07:20AM +0530, Jayadevan M wrote:
> I guess so. But when I tried the same query on psql by replacing ($4) with
> a value like '20110404', the query works OK. The value of $4 is being
> passed from a java application. So does this mean I have to change the
> data type in java code?

For clarity, when you put the value '20110404' in a query, that is not
a varchar. Rather it's type is coerced to whatever is most appropriate
from the surrounding SQL.

To generate the same error you need to put '20110404'::varchar in place
of the parameter.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> He who writes carelessly confesses thereby at the very outset that he does
> not attach much importance to his own thoughts.
-- Arthur Schopenhauer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message alexondi 2011-08-23 09:01:10 Wal archiving and streaming replication
Previous Message Giuseppe Sacco 2011-08-23 07:29:19 Re: SSL certificates issue