pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: emilu@encs.concordia.ca
Cc: PostgreSQL SQL List <pgsql-sql@postgresql.org>
Subject: Re: ibatis with overlaps query
Date: Thu, 02 Apr 2009 11:09:44 -0400
Message-ID: <23537.1238684984@sss.pgh.pa.us> (raw)
In-Reply-To: <49D4C551.3030702@encs.concordia.ca>
References: <49D4C551.3030702@encs.concordia.ca>

Emi Lu <emilu@encs.concordia.ca> writes:
> With ibatis, do overlap checking:

> (1) select (DATE #begin_date#, DATE #end_date#) overlaps
> (DATE '2008-01-01', DATE '2009-01-01')
> . #begin_date# is varchar
> . #end_date#   is varchar

> Cause: java.sql.SQLException: ERROR: syntax error at or near "$4"

> However, when I updated the query to
> (2) select (#begin_date#::DATE, #end_date#::DATE) overlaps
> (DATE '2008-01-01', DATE '2009-01-01')

> It works. I am bit confused why (1) does not work, but (2) does?

The syntax DATE 'foo' (or more generally, typename 'foo') works
only for string-literal constants 'foo'.  It looks like what your
frontend is actually sending is a parameter symbol, like DATE $1,
which is a syntax error.

There is more about this in the manual, sections 4.1.2.5
and 4.2.8:
http://www.postgresql.org/docs/8.3/static/sql-syntax.html

			regards, tom lane



view thread (2+ messages)

Message-ID: <23537.1238684984@sss.pgh.pa.us>
Permalink:  ../23537.1238684984@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/23537.1238684984@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, emilu@encs.concordia.ca
  Subject: Re: ibatis with overlaps query
  In-Reply-To: <23537.1238684984@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox