-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: passing in parameters to sql functions
PostPosted: Wed Apr 16, 2008 4:01 pm 
Newbie

Joined: Wed Apr 16, 2008 3:53 pm
Posts: 1
hi. i'm having a problem trying to pass in parameters to sql functions. see below:

StringBuffer sb = new StringBuffer("SELECT lastName from myDB where dateAdded <= TO_TIMESTAMP_TZ(:dateAdded, 'DY MON DD HH24:MI:SS TZD YYYY')");

Query myquery = sessionFactory.getCurrentSession().createQuery(sb.toString());

myquery.setDate("dateAdded", dateAdded);

after checking the logs, i'll get org.hibernate.exception.SQLGrammarException: could not execute query. But, if i remove the TO_TIMESTAMP_TZ function and just do "dateAdded <= :dateAdded" that'll work fine. Do you know how i can fix this? thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 16, 2008 5:15 pm 
Newbie

Joined: Fri Mar 28, 2008 2:37 pm
Posts: 4
Location: Toronto
TO_TIMESTAMP_TZ converts char of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 datatype to a value of TIMESTAMP WITH TIME ZONE datatype.

you are entering a date as a parameter to this function

to make your code work say something like

Code:
myquery.setString("dateAdded", "1999-12-01 11:00:00 -8:00");


Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.