Getting a Oracle Exception
I'm not sure if this a problem with how I have written the LINQ query or if it is a bug with LINQPad, but I have the following:
from system in MonitorSystems select new { Id = system.ID, Name = system.Name, Average = system.SystemRecords.Average(x => x.Measurement), LatestMeasurement = (from record in Records where record.SystemID == system.ID orderby record.ID descending select record).First().Measurement, Measurements = from record in system.SystemRecords orderby record.RecordDate descending select new { Measurement = record.Measurement, RecordDate = record.RecordDate } }It compiles fine, but I get a ORA-00933 error: SQL command not properly ended. This is the SQL it generates,
SELECT t2.SYSTEM_ID, t2.MEASUREMENT, t2.RECORD_DATE FROM MONITOR_SYSTEM t0 OUTER APPLY ( SELECT * FROM (SELECT t3.ID FROM RECORD t3 WHERE (t3.SYSTEM_ID = t0.ID) ORDER BY t3.ID DESC) WHERE ROWNUM<=1 ) t1 LEFT OUTER JOIN RECORD t2 ON (t2.SYSTEM_ID = t0.ID) ORDER BY t1.ID DESC, t2.RECORD_DATE DESC
Comments
-
So...any ideas if this a bug with linqpad or the driver it uses?
-
I'm still getting this exception on various queries. Is the developer around? Should I email him?
-
If the SQL is malformed, it will be a bug in the driver. I'm not an expert on Oracle - can you say what's wrong with the SQL it produced?
-
I believe it has to do with the OUTER APPLY.
Take a look here:
https://forums.oracle.com/forums/message.jspa?messageID=10166766#10166766