Skip to Main Content

PL|SQL problem: PLS-00302:

660136Oct 6 2008 — edited Oct 6 2008
Hi,

I have trouble runing a piece of PL/SQL. The problem is that I keep on getting an initialisation error, however the variable does not need to be initialised.
set serveroutput on;
declare
      cursor cust is
                      select order_id, item_id from ph2 
                      order by order_date, customer_id, ship_date, order_id, item_id
                      for update of order_id, item_id;
                      
      neworder_id  ph2_item.order_id%type;
      multicust multi_site_cust.cust%type;
      newitem_id ph2_item.item_id%type;
      
      
begin
        /*Initialising neworder_id */
        select 
              max(order_id)+1
        into
              neworder_id
        from
              sales_order;     
        
        newitem_id := 1;
                  
         for c_rec in cust loop
         
         /*initilising multicust */
            select
                  customer
            into
                  multicust
            from
                  multi_ships_cust
            order by
                  customer;

                update 
                        ph2_item p 
                    set 
                        p.order_id =
                                  (
                                    case
                                          when 
                                                c_rec.customer_id = multicust
                                          then 
                                                neworder_id
                                          else
                                                neworder_id + 1
                                     end
                                  ),
                        p.item_id = 
                                 (
                                  case
                                          when 
                                                c_rec.customer_id = multicust
                                          then
                                                newitem_id + 1 
                                          --else
                                               -- newitem_id
                                    end
                                 )
               where current of cust;
          end loop;
end;
/
Comments
Post Details
Added on Oct 6 2008
8 comments
143 views