aggregate function isnull (sql server)

Posts   
 
    
evb
User
Posts: 27
Joined: 17-Nov-2004
# Posted on: 17-Nov-2004 10:49:18   

Hello,

I searched the llblgen documentation, but didn't find a aggregate function for isnull. What i'm trying to do : SELECT something FROM sometable WHERE isnull(somedatefield, '3000/01/01') >= '2004/10/31'

Can we easily extend llblgen to support this aggregate function? A sort of customer extension with use of base classes from llblgen.

Or are we stuck with a SP?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 17-Nov-2004 11:19:55   

evb wrote:

I searched the llblgen documentation, but didn't find a aggregate function for isnull. What i'm trying to do : SELECT something FROM sometable WHERE isnull(somedatefield, '3000/01/01') >= '2004/10/31'

Can we easily extend llblgen to support this aggregate function? A sort of customer extension with use of base classes from llblgen.

Isn't that query the same as: SELECT something FROM sometable WHERE (somedatefield >= '2004/10/31' OR somedatefield IS NULL)

?

if so, you can do that with 2 predicates in a predicate expression simple_smile

Frans Bouma | Lead developer LLBLGen Pro
evb
User
Posts: 27
Joined: 17-Nov-2004
# Posted on: 17-Nov-2004 14:03:17   

flushed , you're right. For this case this workaround is correct.

But in case I want to implement really the, for example, 'isnull' aggregate function. Is there a possibility to implement this without changing the source code of llblgen? A custom class derived from a llblgen class to implement the new aggregate function?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 17-Nov-2004 17:18:14   

ISNULL() is used to give valid values for NULL values for a particular field. This is already done by teh generated code: a field of type T will get the default value defined in TypeDefaultValue.cs/vb

In predicates, you can always work around this using an IS [NOT] NULL predicate.

If I'm mistaken, could you please give an example of a query you need it for?

Frans Bouma | Lead developer LLBLGen Pro
evb
User
Posts: 27
Joined: 17-Nov-2004
# Posted on: 22-Nov-2004 09:30:41   

Thanks for your response. simple_smile

No, you helped me already with a solution for my problem. It was just a theoretical question. If I wanted to implement a not yet implemented aggregate function, what was the best way to follow...

Andrius
User
Posts: 68
Joined: 04-Apr-2005
# Posted on: 21-Nov-2005 09:39:30   

Hello, I thought it is better to continue existing thread than starting a new one

I wan to use IsNull expression in select

Select IsNull(onefield, anotherField) From ...

or something like this:

SELECT AVG(ISNULL(price, $10.00))

Is it possible?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 21-Nov-2005 09:47:55   

Not at the moment.

Unless you write your own IExpression implementation like in this example: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=3829

Frans Bouma | Lead developer LLBLGen Pro