Bug on Query method using select count(*)

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
bmarotta
Posts: 34
Joined: Wed 29 Sep 2010 11:27

Bug on Query method using select count(*)

Post by bmarotta » Thu 10 Feb 2011 09:14

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...

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Fri 11 Feb 2011 14:35

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();

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Fri 18 Feb 2011 14:41

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.

Post Reply