Wednesday, January 09, 2008

PLS-00642: local collection types not allowed in SQL statements

This error is easily explained:
declare
type WARRAY is varray(324) OF varchar2(200);
LLISTA WARRAY;
VALS WARRAY;
number pls_integer := 1;
begin
VALS := WARRAY('a','b');
LLISTA := WARRAY('c','d','e');
LLISTA := VALS;
number := VALS.COUNT;

select column_value
bulk collect into LLISTA
from table(cast (VALS as string_table_type));

dbms_output.put_line(number);
dbms_output.put_line(LLISTA(number));
end;

Error report:
ORA-06550: line 13, column 21:
PLS-00642: local collection types not allowed in SQL statements
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:

Collection VALS is not a SQL object type (a user-defined type anyway), but it's a PL/SQL local type, that is a type defined inside the program.
Casting the local type to an external object type, string_table_type in the sample code above, is not sufficient to make it work, you need to change the collection type altogether, as shown in the PL/SQL snippet of the related article.

See message translations for PLS-00642 and search additional resources.

No comments:

yes you can!

Two great ways to help us out with a minimal effort. Click on the Google Plus +1 button above or...
We appreciate your support!

latest articles