pl/sql object types "ORA-06530: Reference to uninitialized composite" error

Posted by mutoss on Stack Overflow See other posts from Stack Overflow or by mutoss
Published on 2010-06-11T09:34:13Z Indexed on 2010/06/11 9:52 UTC
Read the original article Hit count: 385

Filed under:
|
|

hi, i have a type as follows:

CREATE OR REPLACE TYPE tbusiness_inter_item_bag AS OBJECT (
   item_id              NUMBER,
   system_event_cd      VARCHAR2 (20),
   CONSTRUCTOR FUNCTION tbusiness_inter_item_bag RETURN SELF AS RESULT
);
CREATE OR REPLACE TYPE BODY tbusiness_inter_item_bag
AS
   CONSTRUCTOR FUNCTION tbusiness_inter_item_bag RETURN SELF AS RESULT
   AS
   BEGIN
      RETURN;
   END;
END;

when i execute the following script, i got a "Reference to uninitialized composite" error, which is imho quite suitable.

DECLARE
   item   tbusiness_inter_item_bag;
BEGIN
   item.system_event_cd := 'ABC';
END;

This also raises the same error:

item.item_id := 3;

But if i change my object type into:

CREATE OR REPLACE TYPE tbusiness_inter_item_bag AS OBJECT (
   item_id              NUMBER(1),
   system_event_cd      VARCHAR2 (20),
   CONSTRUCTOR FUNCTION tbusiness_inter_item_bag RETURN SELF AS RESULT
);

then the last statement raises no more error (where my "item" is still uninitialized):

item.item_id := 3;

Shouldn't i get the same ORA-06530 error?

ps: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

© Stack Overflow or respective owner

Related posts about Oracle

Related posts about plsql