初めてのPL/SQL

2012年6月13日 Posted by PURGE

set serveroutput on
DECLARE
  CURSOR customer_ids is
  select customer_id
    from customer_mst
   where customer_id in
         (select customer_id
            from customers
           where customer_id in
                 (select customer_id
                    from customer_lst
                   where customer_id = 126 ));
 
  customers customer_ids%ROWTYPE;
BEGIN
  open customer_ids;
    LOOP
      FETCH customer_ids INTO customers;
 
        DBMS_OUTPUT.PUT_LINE(customers.customer_id);
 
      update customer_mst
         set exists_flg = 1
       where customer_id = customers.customer_id;
 
      EXIT WHEN customer_ids%NOTFOUND;
    END LOOP;
  commit;
  close customer_ids;
 
END;
/

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です