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.  [ 4 posts ] 
Author Message
 Post subject: HQL, named parameters and the ':' character
PostPosted: Fri Aug 18, 2006 4:45 am 
Beginner
Beginner

Joined: Wed Apr 26, 2006 4:12 am
Posts: 29
I have a query like this:
SELECT Replace(Convert(varchar(5), ru.StartTime,8),':','') as StartTime
FROM Geography
WHERE :dateuse = ...

I set the the dateuse parameter, but it gets confused with the colon I'm using in the select cluase. Are there any escape characters I can use to escape that colon?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 5:58 am 
Newbie

Joined: Mon Jun 12, 2006 1:06 pm
Posts: 3
Not sure on the escape character, but thought I'd point out a not-very-i18n-compliant solution if you're in a hurry:
Your database will normally have a CHR or CHAR function for converting a numeric ascii value (readily retrieved using the ASC/ASCII function) to a character. I suspect NHibernate won't have a problem with that...

Mike.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 10:55 am 
Newbie

Joined: Mon Apr 10, 2006 11:45 pm
Posts: 17
Are you sure it's not your second ':' that's wrong?

Shouldn't it be:

I have a query like this:
SELECT Replace(Convert(varchar(5), ru.StartTime,8),':','') as StartTime
FROM Geography
WHERE dateuse = :paramName

Check the documentation here and look under "Tips and Tricks" at the bottom:
http://www.hibernate.org/hib_docs/nhibe ... ryhql.html


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 12:30 pm 
Beginner
Beginner

Joined: Tue Sep 14, 2004 1:03 pm
Posts: 33
Location: Calgary, Alberta Canada
You could also try this

SELECT Replace(Convert(varchar(5), ru.StartTime,8),':','') as StartTime
FROM Geography as g
WHERE g.dateuse = :paramName

also when you replace the named parameter do it like this
.SetParameter("paramName", value)

not
.SetParameter(":paramName", value)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.