-->
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.  [ 6 posts ] 
Author Message
 Post subject: ISNULL function in hsql
PostPosted: Wed May 07, 2008 12:19 pm 
Newbie

Joined: Wed May 07, 2008 12:15 pm
Posts: 2
Hi!
Anybody knows if in HSQL, there is a function like ISNULL (SQL Server) or NVL (Oracle)??


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 07, 2008 2:01 pm 
Newbie

Joined: Fri Nov 02, 2007 9:27 am
Posts: 5
Hi,

Yes... it is possible.

See a sample:

Code:
String str_query = "select t from Task t where t.user is null";


t.user is null

Bye!

Claudiney


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 07, 2008 2:55 pm 
Newbie

Joined: Wed May 07, 2008 12:15 pm
Posts: 2
Thanks Claudiney!, but I don't want filter the null values.

I want replace the null value with another value, like this:

SELECT IsNull(T.Name,'N/A') FROM T


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 23, 2008 1:23 am 
Newbie

Joined: Thu Oct 23, 2008 1:18 am
Posts: 1
@grimpi,

You can use a custom defined "IsNull" function. Then you can create an alias in HSQLDB (CREATE ALIAS IsNull "package.FinalClass.isNull") and use it exactly like you mentioned.

Make sure the method you defined is static, as HSQLDB can only call static methods (as functions).

Here is a good tutorial on how to do this: http://blog.dotkam.com/2008/10/22/use-hsqldb-functions-with-hibernate-mapping-files/

-- buntu


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 23, 2008 8:07 am 
Regular
Regular

Joined: Mon Jan 22, 2007 10:32 am
Posts: 101
I think you can use nullIf method in HQL.

_________________
Please rate this post if you find it helpful


Top
 Profile  
 
 Post subject: Re: ISNULL function in hsql
PostPosted: Fri Jun 24, 2011 11:26 am 
Newbie

Joined: Fri Jun 24, 2011 11:21 am
Posts: 2
If you are going to use hsqldb you can also look through the already defined list of functions:http://hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html

Quote:

IFNULL

ISNULL

IFNULL | ISNULL ( <value expr 1>, <value expr 2> )

Returns <value expr 1> if it is not null, otherwise returns <value expr 2>. The type of the return value is the type of <value expr 1>. Almost equivalent to SQL Standard COALESCE(<value expr 1>, <value expr 2>) function, but without type modification. (JDBC)



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