|
-
Check your code..
Hi,
Usually, you may receive these errors when some of the objects
are not initialized.
For example:
------------
drop table emp;
drop type emp_type;
create type emp_type as object(
name VARCHAR2(30),
address VARCHAR2(30));
/
create table emp of emp_type;
insert into emp
values (emp_type('Kumar', 'Chennai'));
create or replace procedure test as
emp1 emp_type;
begin
select emp.name, emp.address into emp1.name, emp1.address
from emp
where emp.name = 'Kumar';
dbms_output.put_line('emp1.name : '||emp1.name);
dbms_output.put_line('emp1.address : '||emp1.address);
end;
/
SQL> execute test;
begin test; end;
*
ERROR at line 1:
ORA-06530: Reference to uninitialized composite
ORA-06512: at "TEST", line 15
ORA-06512: at line 1
Solution Description
--------------------
You have to initialize the object using a constructor.
After initializing the object 'emp1' as below in the example it worked.
emp1 := emp_type(NULL, NULL);
Changed example:
----------------
set serveroutput on;
drop table emp;
drop type emp_type;
create type emp_type as object(
name VARCHAR2(40),
address VARCHAR2(40));
/
create table emp of emp_type;
insert into emp
values (emp_type('Kumar', 'Chennai'));
create or replace procedure test as
emp1 emp_type;
begin
emp1 := emp_type(NULL, NULL);
select emp.name, emp.address into emp1.name, emp1.address
from emp
where emp.name = 'Kumar';
dbms_output.put_line('emp1.name : '||emp1.name);
dbms_output.put_line('emp1.address : '||emp1.address);
end;
/
show errors;
SQL> execute test;
emp1.name : Kumar
emp1.address : Chennai
PL/SQL procedure successfully completed.
Hope this will help you.
Regards,
RP Kumar
You Can Win, if u believe Yourself
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|