--cursor_attributes.sql implicit cursor use of SQL%ROWCOUNT BEGIN UPDATE customers SET post_code = '12345' WHERE post_code = '67890'; DBMS_OUTPUT.PUT_LINE (SQL%ROWCOUNT||' were updated in the'|| ' customers table'); END; / --************************************************************************* --explicit_cursor.sql DECLARE v_cust_no CUSTOMERS.Cust_no%TYPE; CURSOR c_customer IS -- declaring a cursor SELECT Cust_no FROM customers WHERE rownum <= 10; --rownum is a virtual colum like use and sysdate BEGIN OPEN c_customer; -- opening the cursor LOOP -- fetching the cursor FETCH c_customer INTO v_cust_no; EXIT WHEN c_customer%NOTFOUND; DBMS_OUTPUT.PUT_LINE ('Customer ID: '||v_cust_no); END LOOP; CLOSE c_customer; -- closing the cursor END; / --******************************************************************************** --cursor_for_loop.sql DECLARE -- declaring a cursor CURSOR c_customer IS SELECT Cust_no FROM customers WHERE rownum <= 10; BEGIN -- opening the cursor FOR r_customer IN c_customer LOOP DBMS_OUTPUT.PUT_LINE('Customer ID: '||r_customer.Cust_no); -- closing the cursor END LOOP; END; / --************************************************************************************ --parameter_cursor.sql DECLARE v_post_code customers.post_code%TYPE := '&sv_zip'; CURSOR c_customer(p_zip customers.post_code%TYPE) IS SELECT cust_name FROM customers WHERE post_code = p_zip; BEGIN FOR r_customer IN c_customer(v_post_code) LOOP DBMS_OUTPUT.PUT_LINE(r_customer.cust_name); END LOOP; END; / --*********************************************************************