Using prior and next - collection method, PL-SQL Programming

Using PRIOR and NEXT

The PRIOR(n) returns the index number that precede index n in a collection. The NEXT(n) returns the index number which succeed the index n. If n has no predecessor, then the PRIOR(n) returns NULL. Similarly, if n has no successor, then NEXT(n) returns NULL. The PRIOR and NEXT do not wrap from one end of a collection to another. For illustration, the statement below assigns a NULL to n as the first element in a collection has no predecessor:

n := courses.PRIOR(courses.FIRST); -- assigns NULL to n

The PRIOR is the inverse of NEXT. For illustration, if element i exists, the statement below assigns element i to itself:

projects(i) := projects.PRIOR(projects.NEXT(i));

You can use PRIOR or NEXT to traverse the collections indexed by any sequence of subscripts. In the example below, you use NEXT to traverse a nested table from that some elements have been deleted:

i := courses.FIRST; -- get subscript of first element

WHILE i IS NOT NULL LOOP

-- do something with courses(i)

i := courses.NEXT(i); -- get subscript of next element

END LOOP;

Posted Date: 10/4/2012 3:16:56 AM | Location : United States







Related Discussions:- Using prior and next - collection method, Assignment Help, Ask Question on Using prior and next - collection method, Get Answer, Expert's Help, Using prior and next - collection method Discussions

Write discussion on Using prior and next - collection method
Your posts are moderated
Related Questions
Scoping Within the similar scope, all the declared identifiers should be unique. So, even if their datatypes differ, the variables and parameters cannot share the similar name.

%FOUND Subsequent to a cursor or cursor variable is opened but before the first fetch, the %FOUND yields NULL. Afterward, it yields TRUE when the last fetch returned a row, or

FORALL Statement The FORALL statements instruct the PL/SQL engine to bulk-bind the input collections before sending them to the SQL engine. Though the FORALL statement consists

Components of an Object Type: An object type encapsulates the operations and data. Therefore, you can declare the methods and attributes in an object type specification, but no

Cursor Variables Similar to a cursor, cursor variable points to the current row in the result set of a multi-row query. But, dissimilar a cursor, a cursor variable can be opene

%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. I

Parameter Modes: You do not require to specify a parameter mode for the input bind arguments (those used, for illustration, in the WHERE clause) as the mode defaults to IN. Th

Functions   The function is a subprogram that calculates a value. The Functions and procedures are structured similar, except that the functions have a RETURN clause. You can

Wrapping and unwrapping in SQL Operators WRAP and UNWRAP in connection with attributes whose declared types are tuple types. Example shows how extension and projection can be

Block Structure The PL/SQL is a block-structured language. That is, the fundamental units (procedures, anonymous blocks, and functions) that make up a PL/SQL program are logi