UniQuery error by CASE in ORDER BY on oracle db

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
tutko
Posts: 2
Joined: Wed 08 Jul 2009 15:37

UniQuery error by CASE in ORDER BY on oracle db

Post by tutko » Thu 13 Oct 2016 15:51

Hi

I have this simple SQL example:

Code: Select all

select jobid from updatejobqueue 
order by 
  case
    when jobid > 1000 then 0 
    else 1
  end 
if the property Options.QueryRecCount = True, I receive this error on oracle db:

ORA-00907: missing right parenthesis

Important is the CASE conditional in ORDER BY, this causes always an error on oracle db. On SQLServer works without error.

Can you help me?
Thanks
Willi

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UniQuery error by CASE in ORDER BY on oracle db

Post by MaximG » Fri 21 Oct 2016 10:23

Thank you for the information. We have reproduced the problem and fixed the bug. The fix will be included in the next UniDAC build.

jrheisler
Posts: 48
Joined: Tue 25 Oct 2011 17:47

Re: UniQuery error by CASE in ORDER BY on oracle db

Post by jrheisler » Thu 01 Dec 2016 23:51

Is there a hot release? or when will the release be available?

jrheisler
Posts: 48
Joined: Tue 25 Oct 2011 17:47

Re: UniQuery error by CASE in ORDER BY on oracle db

Post by jrheisler » Fri 02 Dec 2016 00:37

I downloaded Universal Data Access Components Professional 6.4.16 21-Nov-2016

and it is still broken.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UniQuery error by CASE in ORDER BY on oracle db

Post by MaximG » Fri 02 Dec 2016 08:58

We checked UniDAC 6.4.16 behavior when using the CASE construction in queries and found no issues. As an example we chose the demo table DEPT :

Code: Select all

var
  Query: TUniQuery;
begin
  Query := TUniQuery.Create(Nil);
  try
    Query.Connection := UniConnection;
    Query.Options.QueryRecCount := True;
    Query.SQL.Text := 'select deptno from dept order by case when deptno > 1000 then 0 else 1 end';
    Query.Open;
  finally
    Query.Free;
  end;
end;
Please make sure that the mentioned code fragment works correctly in your test environment. Change it to make the issue occur. Inform us about the obtained results.

jrheisler
Posts: 48
Joined: Tue 25 Oct 2011 17:47

Re: UniQuery error by CASE in ORDER BY on oracle db

Post by jrheisler » Fri 02 Dec 2016 14:33

After upgrading from 6.3.x to 6.4.x the sql give the error ora-00907: missing right parenthesis

select distinct a.* ,x.obj_id
from chg_master a,object_ids x
where a.chg_num = ''

order by a.ECP_NUM ASC,a.CHG_CAGE ASC ,a.TYPE ASC ,a.REV DESC,a.CORR ASC,a.CHG_TYPE ASC



by changing the sql to this (commenting out the order by), the error goes away:

select distinct a.* ,x.obj_id
from chg_master a,object_ids x
where a.chg_num = ''

--order by a.ECP_NUM ASC,a.CHG_CAGE ASC ,a.TYPE ASC ,a.REV DESC,a.CORR ASC,a.CHG_TYPE ASC


That is the most isolated way I could show it. Unfortunately, there are other parts of our code where many queries are run to and I would likely spend a week going through it all.

Perhaps it has nothing to do with case construction, I don't know, but I do know that a paid upgrade from 6.3.x to 6.4.x resulted in this.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UniQuery error by CASE in ORDER BY on oracle db

Post by MaximG » Mon 05 Dec 2016 11:55

We checked the similar query work using UniDAC 6.4.16 and found no issues. To investigate the issue in details, please send us via e-support a script to create the chg_master and object_ids tables and also a sample of populating them with data.

jrheisler
Posts: 48
Joined: Tue 25 Oct 2011 17:47

Re: UniQuery error by CASE in ORDER BY on oracle db

Post by jrheisler » Mon 05 Dec 2016 16:14

What is e-support?

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UniQuery error by CASE in ORDER BY on oracle db

Post by MaximG » Tue 06 Dec 2016 09:45

E-support form is available on our site: https://www.devart.com (меню «Support»\«Request Support»). You can post the script to create the chg_master and object_ids tables on this forum directly

Post Reply