Re: ibatis with overlaps query

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: ibatis with overlaps query
Дата
Msg-id 23537.1238684984@sss.pgh.pa.us
обсуждение исходный текст
Ответ на ibatis with overlaps query  (Emi Lu <emilu@encs.concordia.ca>)
Список 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


В списке pgsql-sql по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps
Следующее
От: Peter Willis
Дата:
Сообщение: Re: FUNCTION problem