Hi. 

        It seems there is a weird bug somewhere in query parser. Please check
following script:

>---
drop table test_bug
//
drop table test_bug1
//
create table test_bug (
        id integer, val varchar(100), tstamp timestamp
)
//
create table test_bug1(
        id integer, tstamp timestamp
)
//
select t_id, t_val from (
 select a.id as t_id, a.val as t_val
  from test_bug a
   where a.tstamp = (
       select max(b.tstamp) from test_bug1 b where a.id=b.id)
     and a.id > 10 and a.id < 20
) order by  t_val
//
select t_id, t_val from (
 select a.id as t_id, a.val as t_val
  from test_bug a
   where a.tstamp = (
       select max(b.tstamp) from test_bug1 b where a.id=b.id)
     and a.id > 10 and a.id < 20
 union
 select a.id as t_id, a.val as t_val
  from test_bug a
   where a.tstamp = (
       select max(b.tstamp) from test_bug1 b where a.id=b.id)
     and a.id > 20 and a.id < 30
) order by  t_val
//
select t_id, t_val from (
 select a.id as t_id, a.val as t_val
  from test_bug a
   where a.tstamp = (
          select max(b.tstamp) from test_bug1 b)
     and a.id > 10 and a.id < 20
 union
 select a.id as t_id, a.val as t_val
  from test_bug a
   where a.tstamp = (
      select max(b.tstamp) from test_bug1 b where a.id=b.id)
   and a.id > 20 and a.id < 30
) order by  t_val
>---

        As you can see, first query works fine, but second fails with an error
-8010 (Table name must be in from list) at the first occurance of
"a.id=b.id". More mysteriously, query will work again with first
occurance of "where a.id=b.id" removed (see third query). All three
queries work fine in Oracle.

-- 
 Alexey Naidyonov

_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to