Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-06532: Subscript outside of limit - problem with types in function

2717954Feb 2 2010 — edited Feb 2 2010
hi,

i have code:
CREATE OR REPLACE FUNCTION is_regon (str_regon IN VARCHAR2)
    RETURN VARCHAR2
    IS

/*
*  
*
*
*/

    flaga    VARCHAR2(5);
    suma     pls_integer;
    k        pls_integer;
    
    
    TYPE integer_varray IS VARRAY(8) OF NUMBER;
        v_control_9 INTEGER_VARRAY := integer_varray(8, 9, 2, 3, 4, 5, 6, 7);

    TYPE integer_varray_14 IS VARRAY(13) OF NUMBER;
        v_control_14 INTEGER_VARRAY := integer_varray(2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8);
    
    BEGIN
    --
    
    flaga := 'false';
    IF (length(str_regon) = 9 or length(str_regon) = 14) THEN
        suma := 0;
        
        FOR i in 1..8 LOOP
             suma := suma + (TO_NUMBER(substr(str_regon, i, 1)) * v_control_9(i));
        END LOOP;
        
        k := mod(suma, 11);
       
        
        IF(k = 10) THEN
             k := 0;
        END IF;     
        
                
        IF (TO_NUMBER(substr(str_regon, 9, 1)) = k) THEN 
           flaga := 'true';
        ELSE
           flaga := 'false';
        END IF;   
           
       
       
        IF (length(str_regon) <> 9) THEN 
            suma := 0;
               
            FOR i in 1..13 LOOP
             suma := suma + (TO_NUMBER(substr(str_regon, i, 1)) * v_control_14(i));
            END LOOP;    
               
            k := mod(suma, 11);
                        
            IF (k = 10) THEN 
               k := 0;
            END IF;
               
               
            IF (TO_NUMBER(substr(str_regon, 14, 1)) = k) THEN 
               flaga := 'true';
            ELSE
                flaga := 'false';
            END IF;
               
                
        END IF;

     ELSE 
          flaga := 'false';
     END IF;     

        
    RETURN (flaga);
    
END is_regon; 
when i run this func i have: ORA-06532, why?

is this problem with my declarations of arrays:
TYPE integer_varray IS VARRAY(8) OF NUMBER;
v_control_9 INTEGER_VARRAY := integer_varray(8, 9, 2, 3, 4, 5, 6, 7);

TYPE integer_varray_14 IS VARRAY(13) OF NUMBER;
v_control_14 INTEGER_VARRAY := integer_varray(2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8);
?
did i declare these array corectly? i want to my v_control_14 array use the integer_varray_14 type, is it ok?

thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 2 2010
Added on Feb 2 2010
2 comments
4,921 views