DbFunctionCall question

Posts   
 
    
matlaf
User
Posts: 95
Joined: 25-Jan-2005
# Posted on: 02-May-2006 15:48:19   

The DbFunctionCall class is very great.

In the help, I found example with sql server (YEAR, MONTH). I tested it and it's really great.

How with Oracle, can I apply a TO_CHAR(:1, 'YYYY') function with DbFunctionCall?

Thanks,

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39625
Joined: 17-Aug-2003
# Posted on: 02-May-2006 16:35:51   

To a field you mean? Could you give a more precise example?

Frans Bouma | Lead developer LLBLGen Pro
matlaf
User
Posts: 95
Joined: 25-Jan-2005
# Posted on: 03-May-2006 02:02:01   

With SQLServer


fields.DefineField( OrderFieldIndex.OrderId, 0, "OrderID" );
fields.DefineField( OrderFieldIndex.OrderDate, 1, "Month" );

fields[1].ExpressionToApply = new DbFunctionCall( "MONTH", new object[] { OrderFields.OrderDate } );

This will create a query like

select orderID, MONTH(orderdate) from xxxx

With Oracle the function to get the month is to_char(date, 'MM').

The select I want is

select orderID, to_char(orderdate, 'MM') from xxxx

confused ...

As I write my post, I answer my question.

Is this code is correct if I want to select month in Oracle ?


fields.DefineField( OrderFieldIndex.OrderId, 0, "OrderID" );
fields.DefineField( OrderFieldIndex.OrderDate, 1, "Month" );

fields[1].ExpressionToApply = new DbFunctionCall( "TO_CHAR", new object[] { OrderFields.OrderDate, "MM" } );

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39625
Joined: 17-Aug-2003
# Posted on: 03-May-2006 08:46:26   

Yes simple_smile

Frans Bouma | Lead developer LLBLGen Pro