2

i need something like this in procedure PLSQL

 arrayCount:=parArray.Count;
 For i In 1 .. arrayCount Loop
    lsPar(i):=parArray(i);
 End Loop;

is it possible? Thx for advice! :)

Shannon Severance
  • 18,025
  • 3
  • 46
  • 67
FireVortex
  • 303
  • 3
  • 8
  • 16
  • :I think you have not tried it once ,try this and you will know whether this is possible or not – Gaurav Soni Sep 14 '12 at 14:14
  • I tried it and it can't be done... it is asking me for DECLARE lsPar – FireVortex Sep 14 '12 at 14:16
  • @user1518308: If you'll post the full procedure, we can help you figure out the problem. That error message makes it sound like you never declared `lsPar`. – ruakh Sep 14 '12 at 14:26
  • But I dont need to add values into lsPar... I need to add value into lsPar1, lsPar2, lsPar3, lsPar4 and these variables I declared – FireVortex Sep 14 '12 at 14:30

1 Answers1

9

If you're working on oracle ,then this piece of anonymous block will work for you

 declare
    TYPE parArray IS TABLE OF VARCHAR2(64) index by binary_integer;
    v_parArray parArray;
    arrayCount number;
    lsPar parArray;

    begin
    v_parArray(1):='A';
    v_parArray(2):='B';
    v_parArray(3):='C';

    arrayCount:=v_parArray.Count;
       For i In 1 .. arrayCount 
       Loop
          lsPar(i):=v_parArray(i);
       End Loop;

     arrayCount:=lsPar.Count;
        For i In 1 .. arrayCount
         Loop
          dbms_output.put_line('The value of Ispar at index '||i||' is '||lsPar(i));
        End Loop;
     end;  

Output

 The value of Ispar at index 1 is A
 The value of Ispar at index 2 is B
 The value of Ispar at index 3 is C
Gaurav Soni
  • 6,278
  • 9
  • 52
  • 72