Closing a cursor variable, PL-SQL Programming

Closing a Cursor Variable

The CLOSE statement disables the cursor variable. After that, the related result set is undefined. The syntax for the same is as shown below:

CLOSE {cursor_variable_name | :host_cursor_variable_name);

In the illustration below, if the last row is processed, then you can close the cursor variable emp_cv:

LOOP

FETCH emp_cv INTO emp_rec;

EXIT WHEN emp_cv%NOTFOUND;

-- process data record

END LOOP;

/* Close cursor variable. */

CLOSE emp_cv;

Whenever declaring a cursor variable as the formal parameter of the subprogram which closes the cursor variable, you should specify the IN or IN OUT mode.

If you attempt to close an already-closed or never-opened cursor variable, the PL/SQL raises the predefined exception that is the INVALID_CURSOR.

Posted Date: 10/4/2012 4:05:15 AM | Location : United States







Related Discussions:- Closing a cursor variable, Assignment Help, Ask Question on Closing a cursor variable, Get Answer, Expert's Help, Closing a cursor variable Discussions

Write discussion on Closing a cursor variable
Your posts are moderated
Related Questions
Project Description: I have two types of data sources. One that is a list in SharePoint and another that is an access desktop database. The access desktop database is fairly com

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

Subprograms The PL/SQL has two types of subprograms known as the procedures and functions that can take parameters and be invoked. As the following example represents, a subp

Data Types in SQL - Character CHARACTER or, synonymously, CHAR, for character strings. When this type is to be the declared type of something (e.g., a column), the permissible

Packaging Cursors   You can split a cursor specification from its body for placement in a package. In that way, you can change the cursor body without changing the cursor spec

Example of Using Aggregation on Nested Tables Example: How many students sat each exam WITH C_ER AS (SELECT CourseId, CAST (TABLE (SELECT DISTINCT StudentId, Mark FROM EXAM

Naming Conventions The similar naming conventions apply to all PL/SQL program items and units including the variables, cursors, constants, cursor variables, procedures, exception

UPDATE Command- SQL Loosely speaking, UPDATE changes some of the column values of some existing rows of its target table. Thus, although some rows disappear from the target an

Data Types in SQL - XML, Array, Row BINARY LARGE OBJECT for arbitrarily large bit strings. XML for XML documents and fragments. ARRAY types for arrays.

Fetching Across Commits The FOR UPDATE clauses acquire exclusive all row locks. All rows are locked when you open the cursor, and when you commit your transaction they are unl