Hi,
I have a problem with executing an Any() linq statement on DB2, it's a pretty straightforward query:
var exists = linq.Opdracht.Any(o => o.NummerLm == 1 && o.Opdrachtnr == 1);
The resulting error is this:
SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException occurred
Message=An exception was caught during the execution of a retrieval query: ERROR [42601] [IBM][DB2/AIX64] SQL0104N An unexpected token "END-OF-STATEMENT" was found following "HTNR" = ?)))) THEN 1". Expected tokens may include: "END". SQLSTATE=42601
. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
Source=SD.LLBLGen.Pro.ORMSupportClasses.NET20
RuntimeBuild=11292011
RuntimeVersion=3.1.0.0
QueryExecuted=
Query: SELECT CASE WHEN EXISTS (SELECT "LPLA_1"."WERKBONNUMMER" AS "Werkbonnummer" FROM "RDCINST1"."OPDRACHT" "LPLA_1" WHERE ( ( ( "LPLA_1"."NUMMER_LM" = ?) AND ( "LPLA_1"."OPDRACHTNR" = ?)))) THEN 1; ELSE 0; END CASE AS "LPFA_1" FROM "RDCINST1"."OPDRACHT" "LPLA_1" FETCH FIRST 1 ROWS ONLY OPTIMIZE FOR 1 ROWS
Parameter: @p1 : Int32. Length: 4. Precision: 10. Scale: 0. Direction: Input. Value: 943588.
Parameter: @p2 : Int32. Length: 4. Precision: 10. Scale: 0. Direction: Input. Value: 61.
StackTrace:
at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Query\RetrievalQuery.cs:line 136
InnerException: IBM.Data.DB2.DB2Exception
Message=ERROR [42601] [IBM][DB2/AIX64] SQL0104N An unexpected token "END-OF-STATEMENT" was found following "HTNR" = ?)))) THEN 1". Expected tokens may include: "END". SQLSTATE=42601
Source=IBM.Data.DB2
ErrorCode=-2147467259
StackTrace:
at IBM.Data.DB2.DB2Command.ExecuteReaderObject(CommandBehavior behavior, String method, DB2CursorType reqCursorType, Boolean abortOnOptValueChg, Boolean skipDeleted, Boolean isResultSet, Int32 maxRows)
at IBM.Data.DB2.DB2Command.ExecuteReaderObject(CommandBehavior behavior, String method)
at IBM.Data.DB2.DB2Command.ExecuteReader(CommandBehavior behavior)
at IBM.Data.DB2.DB2Command.ExecuteDbDataReader(CommandBehavior behavior)
at SD.Tools.OrmProfiler.Interceptor.ProfilerDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.1\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Query\RetrievalQuery.cs:line 112
InnerException:
It's easy to solve with a Count() > 0, but still it seems like a bug, or am I just using a DB2 version that's too old?
-W