pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
ibatis with overlaps query 2+ messages / 2 participants [nested] [flat]
* ibatis with overlaps query @ 2009-04-02 14:01 Emi Lu <emilu@encs.concordia.ca> 0 siblings, 1 reply; 2+ messages in thread From: Emi Lu @ 2009-04-02 14:01 UTC (permalink / raw) To: pgsql-sql Good morning, 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 Always get: ============ 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? -- Lu Ying ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: ibatis with overlaps query @ 2009-04-02 15:09 Tom Lane <tgl@sss.pgh.pa.us> parent: Emi Lu <emilu@encs.concordia.ca> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2009-04-02 15:09 UTC (permalink / raw) To: emilu@encs.concordia.ca; +Cc: pgsql-sql 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 ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2009-04-02 15:09 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2009-04-02 14:01 ibatis with overlaps query Emi Lu <emilu@encs.concordia.ca> 2009-04-02 15:09 ` Tom Lane <tgl@sss.pgh.pa.us>
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