claghorn
asked on
oracle sql exists clause
Is there a more efficient/faster or more elegant way to do this statement with just the exists clause? I use these in triggers all over the place so I'd like to improve it if possible.
SQL Developer SQL Tuning Advisor says "no recomendation to improve it"
SQL Developer SQL Tuning Advisor says "no recomendation to improve it"
set serveroutput on;
declare l_count number;
begin
SELECT COUNT(*)
INTO l_count
FROM dual
WHERE EXISTS
(SELECT employee_id FROM hr.employees WHERE manager_id = 114);
if l_count > 0 then
dbms_output.put_line ('found some');
end if;
end;
I agree with the solution by ajexpert.
I would also ensure that the hr.employees table has an index on the column manager_id.
I would also ensure that the hr.employees table has an index on the column manager_id.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>> efficient/faster way?
You should check explain plan
I am sure involving dual table has more cost...
You should check explain plan
I am sure involving dual table has more cost...
Open in new window