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
Running the PL/SQL Wrapper To run the PL/SQL Wrapper, go through the wrap command at your operating system prompt by using the syntax as shown: wrap iname=input_file [oname=

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

Keyword & Parameter Description: boolean_expression: This is an expression which yields the Boolean value that is TRUE, FALSE, & NULL. character_expression: This

Initial thought process: Design a script which was simple and user friendly. Integrate procedures/functions to extract data under the hood. I focused on giving the user the opt

Declaring a Cursor The Forward references are not allowed in the PL/SQL. Therefore, you must declare a cursor before referencing it in other statements. Whenever you declare a

Datatypes Every constant and variable has a datatype that specifies the storage format, constraints, and the valid range of values. The PL/SQL gives a variety of predefined dat

Initializing and Referencing Collections Until you initialize a collection, a nested table or varray is automatically null (i.e. the collection itself is null, not its elements)

Project Description: We organize an online system called ACPAS we have created a project called EVO that can be use by our customers to integrate their web sites with the Acpas

DECLARE : This keyword signals the beginning of the declarative section of the PL/SQL block, that contains local declarations. The Items declared locally exist only within the

%NOTFOUND The %NOTFOUND is the logical opposite of the %FOUND. The %NOTFOUND yields TRUE when an INSERT, UPDATE, or DELETE statement affected no rows, or the SELECT INTO state