4 Replies Latest reply: Oct 14, 2011 4:38 AM by Kim Berg Hansen RSS

    Reference to uninitialized collection

    Roger25
      Hi,

      In 11g we have the error "Reference to uninitialized collection"
       type SubmitCustomerOrderType is record(
          Header CoHeaderType,
          Body SubmitBodyType
        );
      
        type UpdateOrderItemType is record(
          OrderItemID       oi_cerinte.id%type,
          ServiceInstanceID number(18),
          Status            varchar2(30),
          StatusDetail      varchar2(4000),
          StatusDate        date,
          Parameters        ParametersType := ParametersType()
        );
      
        type UpdateOrderItemsType is table of UpdateOrderItemType;
      
        type UpdateBodyType is record(
          OrderItems UpdateOrderItemsType := UpdateOrderItemsType(),
          SOWorkAction varchar2(30)
        );
      It seems to be from the line:
      SubmitCustomerOrder.body.OrderItems.extend;

      so here we got that error

      This line, is correctly initialized? : OrderItems UpdateOrderItemsType := UpdateOrderItemsType()
      In 9i works, but in 11 we got that error.

      Thanks

      Edited by: Roger22 on 14.10.2011 12:07
        • 1. Re: Reference to uninitialized collection
          Kim Berg Hansen
          I do not know why it works in version 9 - I should think it should not work in any version?

          How does it make sense to initialize an element of an object type in the declaration of the type?
          Initialization is not used until you for example create a variable of that type?

          I think this ought to work:
          type SubmitCustomerOrderType is record(
              Header CoHeaderType,
              Body SubmitBodyType
            );
           
            type UpdateOrderItemType is record(
              OrderItemID       oi_cerinte.id%type,
              ServiceInstanceID number(18),
              Status            varchar2(30),
              StatusDetail      varchar2(4000),
              StatusDate        date,
              Parameters        ParametersType
            );
           
            type UpdateOrderItemsType is table of UpdateOrderItemType;
           
            type UpdateBodyType is record(
              OrderItems UpdateOrderItemsType,
              SOWorkAction varchar2(30)
            );
          • 2. Re: Reference to uninitialized collection
            Roger25
            Then where should i initialize them?

            the code for extending the collection, and populating is:
             SubmitCustomerOrder.body.OrderItems.extend;
            SubmitCustomerOrder.body.OrderItems(SubmitCustomerOrder.body.OrderItems.last).OrderItemID := pid_order_item;
            SubmitCustomerOrder.body.OrderItems(SubmitCustomerOrder.body.OrderItems.last).ParentOrderItemID := null;
            SubmitCustomerOrder.body.OrderItems(SubmitCustomerOrder.body.OrderItems.last).ProductInstanceID := null;
            SubmitCustomerOrder.body.OrderItems(SubmitCustomerOrder.body.OrderItems.last).ProductCode := get_tipprod_by_uid(v_lista_final(i).UID_PRODSO, null, null);
            SubmitCustomerOrder.body.OrderItems(SubmitCustomerOrder.body.OrderItems.last).WorkAction := 'SCHIMBARE PRODUS TV';
            SubmitCustomerOrder.body.OrderItems(SubmitCustomerOrder.body.OrderItems.last).ServiceInstanceID := v_lista_final(i).UID_PRODSO;
            SubmitCustomerOrder.body.OrderItems(SubmitCustomerOrder.body.OrderItems.last).PrereservationFlag := null;
            SubmitCustomerOrder.body.OrderItems(SubmitCustomerOrder.body.OrderItems.last).Comment := null;
            SubmitCustomerOrder.body.OrderItems(SubmitCustomerOrder.body.OrderItems.last).ProductLabel := get_eticheta_by_uid(v_lista_final(i).UID_PRODSO);
            SubmitCustomerOrder.body.OrderItems(SubmitCustomerOrder.body.OrderItems.last).GroupID := os_util.calcul_grupare(pid_cerere, pid_cerinta_parinte);
            The error is at first line
            • 3. Re: Reference to uninitialized collection
              Roger25
              So in my case Oracle 11g does not know "who" is OrderItems from SubmitCustomerOrder.body.OrderItems.extend;
              • 4. Re: Reference to uninitialized collection
                Kim Berg Hansen
                I would do something like:
                SubmitCustomerOrder.body := SubmitBodyType();
                somewhere in your code after you have created the SubmitCustomerOrder variable.

                But I may be wrong if what you have done works in a version 9. It could be that it is supposed to work?
                So I will not completely vouch for the correctness of my answer - maybe some other forum user can corroborate?