/ Published in: SQL
URL: http://www.techonthenet.com/oracle/loops/cursor_for.php
You would use a CURSOR FOR Loop when you want to fetch and process every record in a cursor. The CURSOR FOR Loop will terminate when all of the records in the cursor have been fetched.
Expand |
Embed | Plain Text
CREATE OR REPLACE FUNCTION TotalIncome ( name_in IN varchar2 ) RETURN varchar2 IS total_val number(6); cursor c1 IS SELECT monthly_income FROM employees WHERE name = name_in; BEGIN total_val := 0; FOR employee_rec IN c1 LOOP total_val := total_val + employee_rec.monthly_income; END LOOP; RETURN total_val; END;
You need to login to post a comment.
