Home » SQL & PL/SQL » SQL & PL/SQL » Finding an element in PL/SQl table
Finding an element in PL/SQl table [message #41394] Sat, 28 December 2002 03:06 Go to next message
Rajasekkhar
Messages: 1
Registered: December 2002
Junior Member
Hi,
I have an PL/SQL table with 100 records.I want to find a particular element say 45th record from the table.I can find it by looping thru the table content and comapring with my required data.But is there any faster way of accessing the element from the table?
Re: Finding an element in PL/SQL table [message #41400 is a reply to message #41394] Sat, 28 December 2002 12:47 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
If you know you want a specific entry (say, the 45th element), then you can just reference that directly:

i := 45;
x := my_array(i);


But if you are just looking for a specific value, then, yes, you need to scan the array until you find a match or run out of elements to search:

for i in my_array.first..my_array.last loop
  if my_array(i) = v_search then
    ...
  end if;
end loop;
Previous Topic: CONNECT VB WITH ORACLE
Next Topic: Oracle Privlages
Goto Forum:
  


Current Time: Fri May 17 07:38:44 CDT 2024