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.  [ 5 posts ] 
Author Message
 Post subject: Concat in SQL Projection?
PostPosted: Wed May 23, 2007 3:56 am 
Newbie

Joined: Wed May 16, 2007 11:41 am
Posts: 8
Hibernate version: v1.1.4322

Name and version of the database you are using: Sql server 2000, SP4

I'm having some problems to concatenate two fields in the projection of my query.

I've tried this:
select width.WidthInCm, width.WidthInCm from Com.Hotec.Manager.Hibernate.Model.Width width and that worked OK but of course that's not concatenation.

but when I try this:

select (width.WidthInCm || '_' || width.WidthInCm) from Com.Hotec.Manager.Hibernate.Model.Width width

or

select (width.WidthInCm + '_' + width.WidthInCm) from Com.Hotec.Manager.Hibernate.Model.Width width

results in this error:
aggregate function expected before (executed query)

when I searched the forum, I've noticed the NHibernate forum doesn't have much topics about this issue. Does that mean it isn't implemented yet?

Thanks for the clarification


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 4:07 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
The operators might not be supported. Try using concat(...) instead.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 4:48 am 
Newbie

Joined: Wed May 16, 2007 11:41 am
Posts: 8
As a workaround, I've created a view with the field I wanted to concatenate.

It seems this is also working ok.

Thanks for the help


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 6:17 pm 
Regular
Regular

Joined: Tue Dec 02, 2003 6:25 pm
Posts: 61
Location: Dallas, TX
Was this ever resolved? Is this a known issue?

When I try to do concatenation in a select clause, I can't get it to work.

If I try:
Code:
select o.LastName||', '||o.FirstName from Person o


I get:

, expected in SELECT [select o.LastName||o.FirstName from Common.Security.Person o]

If I try:
Code:
select concat(o.LastName, o.FirstName) from Person o


I get:

alias or expression expected in SELECT [select concat(o.LastName, o.FirstName) from Common.Security.Person o]

I am using NHibernate 1.2


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 07, 2007 6:59 pm 
Beginner
Beginner

Joined: Fri Jan 12, 2007 1:08 am
Posts: 41
The concat operator only works in the where clause in 1.2.x. However if you look at the trunk you'll see that this feature is now implemented in the select clause too.


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