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

Thread: Unable to add data to Oracle Custom Record - Error - Subscript beyond count

Hybrid View

  1. #1
    Join Date
    Nov 2014
    Posts
    1

    Unable to add data to Oracle Custom Record - Error - Subscript beyond count

    I have created Custom Oracle Record Type and iam trying to populate with some values and trying to access the same in another stored procedure(actually i will be calling from java-Iam getting the same error in java too.) but iam getting "Subscript beyond count" error message.

    Iam just a beginner to Stored Procedure. Below is what i have done

    Oracle Custome Record Type

    Code:
    create or replace type learnerMapCustomRecord as object(activityName varchar2(20),activityDescn varchar2(20));
    
    create or replace type learnerMapCustomRecordTable as table of learnerMapCustomRecord;
    Stored Procedure to populate values to record type
    
    create or replace PROCEDURE getLearnerMapDetails(learnerMapCustomRecord out learnerMapCustomRecordTable) as 
    cursor c1 is select object_name,status from user_objects  where rownum <= 2;
    c c1%rowtype;
    i number:=1;
    begin
      learnerMapCustomRecord := learnerMapCustomRecordTable();
      open c1;
      loop
        fetch c1 into c;
        EXIT WHEN C1%NOTFOUND;
        dbms_output.put_line(c.object_name||'==>'||c.status);
      --  learnerMapCustomRecord.extend;
        learnerMapCustomRecord(I).activityName:=C.OBJECT_NAME;
        learnerMapCustomRecord(i).activityDescn:=c.status;
        i:=i+1;
      end loop; 
    end;
    /
    Stored proc from where iam invoking the above SP to access the list of Custom Record Types.

    Code:
    create or replace procedure data_collection_extract as
    learnerMapCustomRecord learnerMapCustomRecordTable;
    begin
      getLearnerMapDetails(learnerMapCustomRecord);
      for i in learnerMapCustomRecord.first..learnerMapCustomRecord.last
      LOOP
       dbms_output.put_line(learnerMapCustomRecord(i).activityName||'==>'||learnerMapCustomRecord(i).activityDescn);
      end loop; 
    end;
    
    set serveroutput on;
    exec data_collection_extract();
    /
    show error;
    Error report -
    ORA-06533: Subscript beyond count
    ORA-06512: at "FOL_DEV.GETLEARNERMAPDETAILS", line 13
    ORA-06512: at "FOL_DEV.DATA_COLLECTION_EXTRACT", line 4
    ORA-06512: at line 1
    06533. 00000 - "Subscript beyond count"
    *Cause: An in-limit subscript was greater than the count of a varray
    or too large for a nested table.
    *Action: Check the program logic and explicitly extend if necessary.
    Any Takers?
    Last edited by gandolf989; 11-05-2014 at 02:51 PM.

  2. #2
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    Look at this document example 5-20:

    http://docs.oracle.com/cd/B12037_01/...lls.htm#i20453

    You need to extend the collection before you can assign a value to the collection. you would basically be extending the collection every time you add a row. This is not efficient. You should stop using explicit cursors and use collections with BULK COLLECT.

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