question

OracleApprender avatar image
OracleApprender asked

Elaborate the error ORA-06531 while running the below query ?

I'm recieving the below error msg while running the query. Please can one elaborate it further. Thank you in advance.

SQL> declare
2     TYPE test IS VARRAY(6) OF VARCHAR2(20) ;
3 begin
4     dbms_output.put_line('test value is '||test(1));
5 end;
6 /
declare
*
ERROR at line 1:
ORA-06531: Reference to uninitialized collection
ORA-06512: at line 4
queryoracle
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Andrew Mobbs avatar image
Andrew Mobbs answered

You haven't initialized a collection variable, just defined the type.

To create a variable (v_test) of the collection type you've defined do something like:

 v_test test := test('foo');
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.