Cursor for loops, PL-SQL Programming

Cursor FOR Loops

In most cases that need an explicit cursor, you can simplify the coding by using a cursor FOR loop rather of the OPEN, FETCH, and CLOSE statements. A cursor FOR loop implicitly declares its loop index as a record that shows a row fetched from the database. Then, it opens a cursor, repeatedly fetches rows of values from the result set into fields in the record, and after that closes the cursor when all rows have been processed. In the example below, the cursor FOR loop implicitly declares emp_rec as a record:

DECLARE

CURSOR c1 IS

SELECT ename, sal, hiredate, deptno FROM emp;

... BEGIN

FOR emp_rec IN c1 LOOP

...

salary_total := salary_total + emp_rec.sal; END LOOP;

To reference the individual fields in the record, you use dot notation, in which a dot (.) serves as the component selector.

Posted Date: 10/2/2012 1:16:05 AM | Location : United States







Related Discussions:- Cursor for loops, Assignment Help, Ask Question on Cursor for loops, Get Answer, Expert's Help, Cursor for loops Discussions

Write discussion on Cursor for loops
Your posts are moderated
Related Questions
Table Represents an Extension - SQL It describes how each tuple in a relation represents a true instantiation of some predicate and each true instantiation is represented by s

Cursors   To execute the multi-row query, the Oracle opens an unnamed work region which stores the processing information. The cursor names the work region, access the informa

IS NULL Operator The IS NULL operator returns the Boolean value TRUE whenever its operand is null or FALSE if it is not null. The comparisons including the nulls always yield NU

Declaring and Initializing Objects: An object type is once defined and installed in the schema; you can use it to declare the objects in any PL/SQL, subprogram, block or packa

query to Find the account numbers of all customers whose balance is more than 10,000 $

Many of the reports generated from the system calculate the total dollars in purchases for a shopper. Complete the following steps to create a function named TOT_PURCH_SF that acce

Managing Cursors The PL/SQL uses 2 types of cursors: implicit and explicit. The PL/SQL declares a cursor implicitly for all the SQL data manipulation statements, including th

Demonstrate your knowledge of PL/SQL programming by writing and thoroughly testing triggers and stored procedures associated with an e-commerce application that provides security l

Cursor FOR Loops In most cases that need an explicit cursor, you can simplify the coding by using a cursor FOR loop rather of the OPEN, FETCH, and CLOSE statements. A cursor FO

Existential Quantification - SQL Existential quantification-stating that something is true of at least one object under consideration-can be expressed by OR(r,c), meaning tha