%notfound - explicit cursor attributes, PL-SQL Programming

%NOTFOUND

The %NOTFOUND is logical, opposite of the %FOUND. The %NOTFOUND yields FALSE if the last fetch returned a row, or TRUE when the final fetch failed to return a row. In the illustration below, you use the %NOTFOUND to exit a loop if FETCH fails to return a row:

LOOP

FETCH c1 INTO my_ename, my_sal, my_hiredate;

EXIT WHEN c1%NOTFOUND;

...

END LOOP;

Before the first fetch, the %NOTFOUND evaluates to NULL. Therefore, if FETCH never executes effectively, the loop is never existed. That is as the EXIT WHEN statement executes only if it's WHEN condition is true. To be secure, you might want to use the EXIT statement below instead:

EXIT WHEN c1%NOTFOUND OR ci%NOTFOUND IS NULL;

When a cursor or cursor variable is not open, referencing it with the %NOTFOUND raises

INVALID_CURSOR.

Posted Date: 10/4/2012 4:11:04 AM | Location : United States







Related Discussions:- %notfound - explicit cursor attributes, Assignment Help, Ask Question on %notfound - explicit cursor attributes, Get Answer, Expert's Help, %notfound - explicit cursor attributes Discussions

Write discussion on %notfound - explicit cursor attributes
Your posts are moderated
Related Questions
The Package Specification The package specifications contain the public declarations. The scopes of these declarations are local to your database representation and global to t

IN OUT Mode An IN OUT parameter passes initial values to the subprogram being called and return efficient values to the caller. Within the subprogram, an IN OUT parameter acts

Literature review

Using Invoker Rights: By default, the stored procedure executes with the privileges of its definer, not its invoker. These procedures are bound to the schema in which they inh

MAX and MIN operator in SQL Example: (SELECT MAX (Mark) FROM EXAM_MARK WHERE StudentId = 'S1') (SELECT MIN (Mark) FROM EXAM_MARK WHERE StudentId = 'S1') Example

set serveroutput on declare a number(5); b number(5); c number(5); begin a:=&a; b:=&b; c:=a/b; dbms_output.put_line(c); exception when zero_divide then d

Using FORALL and BULK COLLECT Together You can unite the BULK COLLECT clause with the FORALL statement, in that case, the SQL engine bulk-binds column values incrementally. In

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

Loop Labels Like the PL/SQL blocks, loops can also be labeled. The label, an undeclared identifier enclosed by double angle brackets, should appear at the beginning of the LOOP

Aggregate Operators SQL Supports all of the aggregate operators mentioned in the theory book and many more besides. The syntax, however, involves an unusual trick that SQL cal