a guest Jun 24th, 2018 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- cnt NUMBER := 0;
- new_cit customers.city%TYPE := 'Orlando';
- c_nm customers.customer_nm%TYPE;
- c_nbr customers.customer_nbr%TYPE;
- c_cit customers.city%TYPE;
- CURSOR CSR IS
- SELECT c.customer_nm, c.customer_nbr, c.city
- FROM customers c,
- states s,
- orders o,
- order_details d,
- products p
- WHERE c.state_cd = s.state_cd
- AND c.customer_nbr = o.customer_nbr
- AND o.order_nbr = d.order_nbr
- AND d.product_nbr = p.product_nbr
- AND c.state_cd = 'FL'
- AND p.retail_price > 25
- FOR UPDATE -- Required of any cursor for update
- OF C.CITY ;
- OPEN CSR;
- FETCH CSR INTO c_nm, c_nbr, c_cit ;
- EXIT WHEN CSR%notfound;
- cnt := cnt + 1;
- IF (c_cit = 'Tampa')
- UPDATE CUSTOMERS
- SET CITY = new_cit
- WHERE CURRENT OF CSR; --- Only used inside of a cursor
- DBMS_OUTPUT.put_line (cnt
- ||' CNAME = '
- ||' CNBR = '
- ||' CCIT = '
- END IF;
- END LOOP;
- WHEN OTHERS
- DBMS_OUTPUT.put_line ('Trapped the error: '|| DBMS_UTILITY.format_error_stack () );
- CLOSE CSR;
RAW Paste Data