I am a newbie in PL/SQL.
I am writing a small script that will help me join a collection to a database table. Th collection will contain thousands of IDs, but here, for the sake of simplicity, i have kept it very small.
VARIABLE cursor REFCURSOR;
DECLARE
your_collection SYS.ODCIVARCHAR2LIST := SYS.ODCIVARCHAR2LIST();
BEGIN
your_collection.EXTEND(2);
FOR i IN 1 .. 2 LOOP
your_collection(i) := DBMS_RANDOM.STRING( '7839', '7689' );
END LOOP;
OPEN :cursor FOR
SELECT t.*
FROM emp t
INNER JOIN
TABLE( your_collection ) c
ON t.empno = c.COLUMN_VALUE;
END;
/
PRINT cursor;
Here is the error im getting.
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "SYS.DBMS_RANDOM", line 144
ORA-06512: at line 6
06502. 00000 - "PL/SQL: numeric or value error%s"
*Cause: An arithmetic, numeric, string, conversion, or constraint error
occurred. For example, this error occurs if an attempt is made to
assign the value NULL to a variable declared NOT NULL, or if an
attempt is made to assign an integer larger than 99 to a variable
declared NUMBER(2).
*Action: Change the data, how it is manipulated, or how it is declared so
that values do not violate constraints.
CURSOR
Help me correct my script if there are other errors as well. I will be really grateful.
t.empno = c.COLUMN_VALUE. As the message suggests, check the types.