Guest User

Untitled

a guest
May 19th, 2011
169
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CURSOR curs IS
  2.   SELECT cust_id--,COUNT(cust_id) AS num_ocurrences
  3.   FROM trab.sales
  4.   GROUP BY cust_id
  5.   HAVING ( COUNT(cust_id)>=1 )
  6.   ORDER BY cust_id;
  7.  
  8.   last_sale DATE;
  9.  
  10. BEGIN  
  11.   FOR cs IN curs
  12.   LOOP
  13.     SELECT MAX(sale_date)INTO last_date FROM trab.sales s WHERE s.cust_id= cs.cust_id;
  14.     UPDATE indw.CLIENTS aux_t SET aux_t.CLIENT_LAST_BUY = last_date
  15.     WHERE aux_t.CLIENT_ID_SRC = cs.CUST_ID;
  16.   END LOOP;
  17. END;
RAW Paste Data