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

Re: cannot dollar-quote $$?$$ in PreparedStatements

From: Kris Jurka <books(at)ejurka(dot)com>
To: Marc Herbert <Marc(dot)Herbert(at)continuent(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: cannot dollar-quote $$?$$ in PreparedStatements
Date: 2006-01-11 16:58:55
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc

On Wed, 11 Jan 2006, Marc Herbert wrote:

> With 8.0 postgresql and driver, this works fine:
> ps = con.prepareStatement("insert into product values(?, '?' , ?)");
> But this fails:
> ps = con.prepareStatement("insert into product values(?, $$?$$ , ?)");
> It looks like "someone" (driver or engine?) is counting 3 parameters 
> instead of 3:

This is a known issue.  The driver has no knowledge of dollar quotes in 
its query parser.  This is not just a problem for parameters, but also an 
issue when people want to issue a create function command with 
Statement.execute("CREATE FUNCTION f() RETURNS int AS $$ [a number of 
statements separated by semicolons] $$ language plpgsql");  The driver 
will detect the semicolons and try to execute each fragment separately. 
So this is a know issue with the only workaround being to not use dollar 

Kris Jurka

In response to

pgsql-jdbc by date

Next:From: Rainer LeoDate: 2006-01-12 00:05:28
Subject: error code invalid_input_syntax
Previous:From: Roland WalterDate: 2006-01-11 14:43:36
Subject: Re: Memory leak or client side caching?

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