Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

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;
/
This post has been answered by cdkumar on Oct 6 2008
Jump to Answer

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 3 2008
Added on Oct 6 2008
8 comments
212 views