Title: RE: Do triggers cause a context switch between SQL & PL/SQL

Well yes. I was pointing out a second way to write the query that avoided selecting from dual. But the time it takes to run the query is the same in both examples.

-----Original Message-----
From: Jamadagni, Rajendra [mailto:[EMAIL PROTECTED]]

I am not sure ... so far as I know "select count(*) from some_table" without any further group by has always resulted in one row ...

-----Original Message-----
From: Jacques Kilchoer [mailto:[EMAIL PROTECTED]]

Your query with the exists would be the same as doing this, right?
select count(*)
  into numrows
from ApplicationFormCriteria
where ApplicationFormCriteria.applicationFormId = :old.applicationFormId
      and rownum = 1 ;

-----Original Message-----
From: Jamadagni, Rajendra [mailto:[EMAIL PROTECTED]]

A context switch is order because a trigger is a pl/sql object ...
if you can change the trigger ... instead of count(*) try using exists assuming you have a usable index ...
select count(*)
  into numrows
from dual
where exists ( select 1
                from ApplicationFormCriteria
               where ApplicationFormCriteria.applicationFormId = :old.applicationFormId);

...

Reply via email to