Home » RDBMS Server » Performance Tuning » Comparing collection against cursor (oracle,9i,sunos)
Comparing collection against cursor [message #292428] Tue, 08 January 2008 22:58 Go to next message
shahnazurs
Messages: 240
Registered: June 2005
Location: India
Senior Member
Hi,

I have checked the following two codes, both are giving the same result. Please tell me which method is optimized one.

Code 1:-
--------

declare
type nttype is table of emp%rowtype;
nt nttype;
begin
select * bulk collect into nt
from emp;
for i in nt.first..nt.last
loop
if nt(i).sal>1500 then
dbms_output.put_line(nt(i).empno||','||nt(i).ename||','||nt(i).sal);
end if;
end loop;
exception
when others then
dbms_output.put_line('Error');
end;

Code 2:-
--------

declare
cursor c1
is select * from emp;
c1rec c1%rowtype;
begin
open c1;
loop
fetch c1 into c1rec;
exit when c1%notfound;
if c1rec.sal>1500 then
dbms_output.put_line(c1rec.empno||','||c1rec.ename||','||c1rec.sal);
end if;
end loop;
close c1;
exception
when others then
dbms_output.put_line('Error');
end;


Thanks.
Re: Comparing collection against cursor [message #292429 is a reply to message #292428] Tue, 08 January 2008 23:01 Go to previous messageGo to next message
BlackSwan
Messages: 25035
Registered: January 2009
Location: SoCal
Senior Member
How disappointing that after more than 180 posts you still choose to NOT follow posting guidelines as stated below:
http://www.orafaq.com/forum/t/88153/0/
Therefore I choose to decline to provide any clue or answer.
Re: Comparing collection against cursor [message #292498 is a reply to message #292428] Wed, 09 January 2008 01:24 Go to previous message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
After almost 200 posts a non-formatted post does not deserve any answer.
And a performances question without the usual necessary information, no more.

Regards
Michel
Previous Topic: How can i tune the query...
Next Topic: performance tuning
Goto Forum:
  


Current Time: Sat Dec 03 16:26:46 CST 2016

Total time taken to generate the page: 0.07284 seconds