0

How to perform the following in Oracle PL/SQL:

BEGIN
  FOR id IN ( 10,200,30,43,5444,6 ) 
    LOOP
        process_the_record ( id );
END LOOP;
END;    

As this does not seem to work for me.

I basically need to iterate through each of these numbers and pass each number into the procedure, process_the_record (id).

2 Answers 2

3

You can use a collection-- you'd just need to call process_the_record rather than dbms_output.put_line

SQL> declare
  2    type num_arr is table of number;
  3    l_ids num_arr := num_arr( 10, 200, 30, 32, 5444, 6 );
  4  begin
  5    for i in 1 .. l_ids.count
  6    loop
  7      dbms_output.put_line( l_ids(i) );
  8    end loop;
  9  end;
 10  /
10
200
30
32
5444
6
Sign up to request clarification or add additional context in comments.

Comments

0

See the varrays entry here. Will these numbers ever change? Seems like its an awkward way to do things.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.