SQL: Oracle vs ANSI

  • Thread starter Thread starter uv
  • Start date Start date

uv

uv

Soldato
Joined
16 May 2006
Posts
8,435
Location
Manchester
Howdy :)

I've recently started writing my Oracle SQL scripts in ANSI - I find it much cleaner, much easier to read, much easier to make sure joins aren't missed, allows you to use multiple outer joins against the same table and isn't proprietary. My colleagues, however, all use regular Oracle joins - and are adamant that the old-school method is faster and better.

Which do you guys use?

ANSI:
Code:
cursor  cs_jobs is
select  w.id wid,
        w.ext_sys_ref ext,
        o.name opn,
        g.name gpn,
        nvl(h.date_time,p.date_time) app,
        u.user_id||' - '||u.name usr
from    assign.worklist w
left    join assign.possibledates p      on p.worklist_id = w.id
left    join assign.users u              on u.id = w.user_id
left    join assign.scheduledetail d     on d.worklist_id = w.id
left    join assign.scheduleheader h     on h.id = d.schedule_id
left    join assign.operatives o         on o.id = h.operative_id
left    join assign.operativegroups g    on g.id = o.group_id
where   trunc(w.date_booked) = trunc(sysdate)
and     w.location_postcode like '&&outcode'||'%';

Oracle:
Code:
cursor  cs_jobs is
select  w.id wid,
        w.ext_sys_ref ext,
        o.name opn,
        g.name gpn,
        nvl(h.date_time,p.date_time) app,
        u.user_id||' - '||u.name usr
from    assign.operativegroups g,
        assign.operatives o,
        assign.scheduleheader h,
        assign.scheduledetail d,
        assign.users u,
        assign.possibledates p,
        assign.worklist w
where   trunc(w.date_booked) = trunc(sysdate)
and     w.location_postcode like '&&outcode'||'%'
and     p.worklist_id(+) = w.id
and     u.id(+) = w.user_id
and     d.worklist_id(+) = w.id
and     h.id(+) = d.schedule_id
and     o.id(+) = h.operative_id
and     g.id(+) = o.group_id;
 
Unless you're running Oracle8i there's no reason do queries like that.QUOTE]

We've only recently moved from 8i to 10gR2, so I hadn't used ANSI previously (having always worked with Oracle 8i) :)
 
Back
Top Bottom