DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: PLS-00302: component 'A' must be declared

Hybrid View

  1. #1
    Join Date
    Jul 2008
    Posts
    7

    PLS-00302: component 'A' must be declared

    I'm getting the above error for the following program
    Please hint me in this regard.

    Code:
    SQL> desc dup1
     Name                                                              Null?    Type
     ----------------------------------------------------------------- -------- ------------------
     A                                                                          NUMBER
    
    SQL> declare
      2  type typ_dup1 is table of dup1%rowtype;
      3  v_dup1 typ_dup1;
      4  begin
      5  select * bulk collect into v_dup1 from dup1;
      6  dbms_output.put_line(v_dup1.A);
      7  end;
      8  /
    dbms_output.put_line(v_dup1.A);
                                *
    ERROR at line 6:
    ORA-06550: line 6, column 29:
    PLS-00302: component 'A' must be declared
    ORA-06550: line 6, column 1:
    PL/SQL: Statement ignored

  2. #2
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    In your scenario v_dup1 is a table, you need an index to handle it.

    Try this...
    Code:
    SQL> 
    SQL> declare
      2  type typ_dup1 is table of dup1%rowtype;
      3  v_dup1 typ_dup1;
      4  begin
      5  select a bulk collect into v_dup1 from dup1;
      6  for i in v_dup1.first .. v_dup1.last loop
      7  dbms_output.put_line(v_dup1(i).a);
      8  end loop;
      9  end;
     10  /
    
    PL/SQL procedure successfully completed.
    
    SQL>
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  3. #3
    Join Date
    Jul 2008
    Posts
    7
    Hi PAVB,
    Thank you for your reply.
    I tried the code which you have sent

    But giving the following error
    Code:
     
    declare
    *
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at line 6
    What would be the reason.

  4. #4
    Join Date
    Jul 2008
    Posts
    7
    Hi friends,

    I got the output.
    The error is because there is no data in DUP1 table.

    After inserting the records into that, i got the o/p with the program

    Thank you

  5. #5
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Glad it worked out
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width