You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Suhaib <su...@hotmail.com> on 2008/03/09 08:50:10 UTC

Passing date as string to IBATIS.

Hi all ,
I am using  IBATIS  2.3.0 and oracle 10g.

I have passed a date as string to select statments using IBATIS , the date
format is dd Mon yy ,ex. 12 Mar 007, using IBATIS , there is no result
return back from DB , but when i use any sql client I get the result from
DB.

SQL statement in IBATIS :
The hireDate is String

SELECT 	name, id from employee
where to_char(HIRE_DATE ,'dd Mon yy' ) = to_char(#hireDate#)
		
SQL statement in SQL client:
SELECT 	name, id from employee
where 
  to_char(HIRE_DATE ,'dd Mon yy' ) = '12 Mar 07'

OR 

SELECT 	name, id from employee
where 
  to_char(HIRE_DATE ,'dd Mon yy' ) = to_char ( to_date,'12 Mar 07','dd Mon
yy'),'dd Mon yy')

regards
Suhaib


-- 
View this message in context: http://www.nabble.com/Passing-date-as-string-to-IBATIS.-tp15924757p15924757.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Passing date as string to IBATIS.

Posted by Andrey Rogov <an...@gmail.com>.
and here I pass String

select count(*) as count
  from projects.documents d
where to_char( d.created, 'dd Mon yy' ) = to_char(#created#)  or

select count(*) as count
  from projects.documents d
where to_char( d.created, 'dd Mon yy' ) = #created#

DEBUG [http-8080-Processor24] java.sql.Connection debug- {conn-100003}
Connection
DEBUG [http-8080-Processor24] java.sql.PreparedStatement debug-
{pstm-100004} PreparedStatement:                select count(*) as
count             from projects.documents d            where to_char(
d.created, 'dd Mon yy' ) =
to_char(?)

DEBUG [http-8080-Processor24] java.sql.PreparedStatement debug-
{pstm-100004} Parameters: [28 Фев 08]
DEBUG [http-8080-Processor24] java.sql.PreparedStatement debug-
{pstm-100004} Types: [java.lang.String]
DEBUG [http-8080-Processor24] java.sql.ResultSet debug- {rset-100005}
ResultSet
DEBUG [http-8080-Processor24] java.sql.ResultSet debug- {rset-100005}
Header: [COUNT]
DEBUG [http-8080-Processor24] java.sql.ResultSet debug- {rset-100005}
Result: [2]

iBatis works great .

RE: Passing date as string to IBATIS.

Posted by Clinton Begin <cl...@gmail.com>.
Can I ask why you're not just converting the value to a Java Date (either
.sql. or .util.)?

Clinton

-----Original Message-----
From: Suhaib [mailto:suhaib_tawalbeh@hotmail.com] 
Sent: March-09-08 12:50 AM
To: user-java@ibatis.apache.org
Subject: Passing date as string to IBATIS.


Hi all ,
I am using  IBATIS  2.3.0 and oracle 10g.

I have passed a date as string to select statments using IBATIS , the date
format is dd Mon yy ,ex. 12 Mar 007, using IBATIS , there is no result
return back from DB , but when i use any sql client I get the result from
DB.

SQL statement in IBATIS :
The hireDate is String

SELECT 	name, id from employee
where to_char(HIRE_DATE ,'dd Mon yy' ) = to_char(#hireDate#)
		
SQL statement in SQL client:
SELECT 	name, id from employee
where 
  to_char(HIRE_DATE ,'dd Mon yy' ) = '12 Mar 07'

OR 

SELECT 	name, id from employee
where 
  to_char(HIRE_DATE ,'dd Mon yy' ) = to_char ( to_date,'12 Mar 07','dd Mon
yy'),'dd Mon yy')

regards
Suhaib


-- 
View this message in context:
http://www.nabble.com/Passing-date-as-string-to-IBATIS.-tp15924757p15924757.
html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Passing date as string to IBATIS.

Posted by Andrey Rogov <an...@gmail.com>.
Hi Suhaib,
I am using oracle 10g and my iBatis works well,
here is

 select count(*)
   from projects.documents d
 where to_char( d.created, 'dd Mon yy' ) = to_char( #docdate#, 'dd Mon yy' )

log
Documents Date = Sun Mar 09 17:50:09 MSK 2008
DEBUG [http-8080-Processor24] java.sql.PreparedStatement debug-
{pstm-100004}
 PreparedStatement:  select count(*)  from projects.documents d   where
to_char( d.created, 'dd Mon yy' ) = to_char( ?, 'dd Mon yy'
)

DEBUG [http-8080-Processor24] java.sql.PreparedStatement debug-
{pstm-100004} Parameters: [2008-03-09 17:50:09.578]
DEBUG [http-8080-Processor24] java.sql.PreparedStatement debug-
{pstm-100004} Types: [java.sql.Timestamp]
DEBUG [http-8080-Processor24] java.sql.ResultSet debug- {rset-100005}
ResultSet
DEBUG [http-8080-Processor24] java.sql.ResultSet debug- {rset-100005}
Header: [COUNT]
DEBUG [http-8080-Processor24] java.sql.ResultSet debug- {rset-100005}
Result: [1]

Andrey.

2008/3/9, Suhaib <su...@hotmail.com>:
>
>
> Hi all ,
> I am using  IBATIS  2.3.0 and oracle 10g.
>
> I have passed a date as string to select statments using IBATIS , the date
> format is dd Mon yy ,ex. 12 Mar 007, using IBATIS , there is no result
> return back from DB , but when i use any sql client I get the result from
> DB.
>
> SQL statement in IBATIS :
> The hireDate is String
>
> SELECT  name, id from employee
> where to_char(HIRE_DATE ,'dd Mon yy' ) = to_char(#hireDate#)
>
> SQL statement in SQL client:
> SELECT  name, id from employee
> where
>   to_char(HIRE_DATE ,'dd Mon yy' ) = '12 Mar 07'
>
> OR
>
> SELECT  name, id from employee
> where
>   to_char(HIRE_DATE ,'dd Mon yy' ) = to_char ( to_date,'12 Mar 07','dd Mon
> yy'),'dd Mon yy')
>
> regards
> Suhaib
>
>
>
> --
> View this message in context:
> http://www.nabble.com/Passing-date-as-string-to-IBATIS.-tp15924757p15924757.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>