NVL, IS NULL

Posts   
 
    
PAZIMLI
User
Posts: 82
Joined: 01-May-2008
# Posted on: 23-Oct-2008 17:13:23   

C#.net 2005 Adapter LLBLGEN Pro V2.5 Oracle 10g, SqlServer 2000, MySql 5.0

How can i write the stated Sql Statement in LLBLGEN?

SELECT NVL (SUM (miktar), 0) FROM acilan_is_emri

I write this but i could not generate the NVL Syntax.

ScalarQueryExpression sqe = new ScalarQueryExpression( AcilanIsEmriFields.Miktar.SetAggregateFunction(AggregateFunction.Sum), filter3);

            fields.DefineField(new EntityField2("IeMiktar", sqe), 11);
MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
PAZIMLI
User
Posts: 82
Joined: 01-May-2008
# Posted on: 24-Oct-2008 14:28:43   

wHEN İ TRİED THıs for oracle;

PredicateExpression filter3 = new PredicateExpression((AcilanIsEmriFields.MusteriSiparisNo == SiparisKalemiFields.SiparisNo) & (AcilanIsEmriFields.MusteriSkNo == SiparisKalemiFields.SkNo)& (AcilanIsEmriFields.IsEmriNo == UretimIsEmriFields.IsEmriNo) & (UretimIsEmriFields.IsEmriDurumu != UretimTakipInterface._D_ISEMRI_DURUMU_IPTAL) & (SiparisKalemiFields.SkDurumu == (decimal)2));

            ScalarQueryExpression sqe = new ScalarQueryExpression(
                AcilanIsEmriFields.Miktar.SetAggregateFunction(AggregateFunction.Sum),
                            filter3);

           decimal dDefault = 0;
           DbFunctionCall dbc = new DbFunctionCall(
          "[color value="FF0000"]ISNULL[/color]",
           new object[] { sqe, dDefault });

           fields.DefineField(new EntityField2("IeMiktar", dbc), 3);

I get the error message:

System.Data.OracleClient.OracleException: ORA-00904: "ISNULL": invalid identifier

But if i try 'NVL' instead of 'ISNULL' it works for Oracle. But it will not be suitable for SqlServer or MySql.

Is there a db function that will work for all?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-Oct-2008 05:43:06   
System.Data.OracleClient.OracleException: ORA-00904: "ISNULL": invalid identifier

But if i try 'NVL' instead of 'ISNULL' it works for Oracle. But it will not be suitable for SqlServer or MySql.

Is there a db function that will work for all? 

No. DBFunctionCall only wraps your call and send it in a properly manner but the generated SQL uses the exact name you use to construct the call. So, if you want something like that you must write a wrapper method by yourself that receive a field and a substitute and returns a DBFunctionCall object. But, do you really need that? or just testing?

David Elizondo | LLBLGen Support Team
PAZIMLI
User
Posts: 82
Joined: 01-May-2008
# Posted on: 25-Oct-2008 09:18:48   

Thanks, I have to write a db function for different databases. because My code is working on three different databases.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 25-Oct-2008 10:25:47   

PAZIMLI wrote:

Thanks, I have to write a db function for different databases. because My code is working on three different databases.

You could also use a method in .Net code which produces the DbFunctionCall for you based on the database to target...

Frans Bouma | Lead developer LLBLGen Pro