Page 1 of 1

Bug on Query method using select count(*)

Posted: Thu 10 Feb 2011 09:14
by bmarotta
Happened on vrs 5.70

Code: Select all

int i = context.Query(string.Format("select count(*) from USER_SYS_PRIVS where privilege = '{0}'", privilegeName)).FirstOrDefault();
Error

Devart.Data.Linq.LinqCommandExecutionException: Error on executing DbCommand. ---> Devart.Data.Oracle.OracleException: ORA-00904: "T2"."c1": invalid identifier


Generated query:

Code: Select all

SELECT t1."c1"
FROM (
    SELECT t2."c1", ROWNUM AS "rnum"
    FROM (
        select count(*) from USER_SYS_PRIVS where privilege = 'CHANGE NOTIFICATION'
        ) t2
    ) t1
WHERE t1."rnum" <= 1
c1 identifier is missing...

Posted: Fri 11 Feb 2011 14:35
by StanislavK
Thank you for your report, we have reproduced the issue. We will analyze it and inform you about the results of our investigation.

As a temporary workaround, you can set the aliases explicitly in the command:

Code: Select all

int i = context.Query(
    string.Format("select count(*) \"c1\" from USER_SYS_PRIVS where privilege = '{0}'", privilegeName)
  )
  .FirstOrDefault();

Posted: Fri 18 Feb 2011 14:41
by StanislavK
We will consider handling queries without aliases in future, but cannot provide any timeframe for this. At the moment, it is necessary to set an alias for each column being selected. Aliases should be 'c1', 'c2', 'c3' etc., with respect to the order of columns.