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
Table Comparison - SQL The following definitions for relation comparisons: Let r1 and r2 be relations having the same heading. Then: r1 ⊆ r2 is true if every tuple of r1

This task involves developing some functions that extract data from an SQL database. The scenario is that a company which owns an online vehicle search website wants to generate so

Query: SELECT * FROM EMPLOYEE1; Select 5 columns and all rows from one table Query: SELECT C_ID, COMPANY, BUILDING, DEPARTMENT, BRANCH FROM CONTRACT;

Parameter and Keyword Description: cursor_name: This identifies an explicit cursor formerly declared within the present scope. cursor_variable_name: These identif

Effects of NULL The numeric variable X, perhaps of type INTEGER, might be assigned NULL. In that case the result of evaluating X + 1 is NULL, and so SET Y = X + 1 assigns NULL

DBMS_OUTPUT: The Package DBMS_OUTPUT enables you to display output from the PL/SQL subprograms and blocks, that makes it easier to test and debug them. The procedure put_ line

SQL Database: So, an SQL database is one whose symbols are organized into a collection of tables. Now, shows an SQL table as the current value of an SQL variable, ENROLMENT, b

MECHANISTI S THEORY-HAECKEL (1866) - Haeckel stating that after each catalysm, some new organism suddenly forms as a chance event in one stride from inanimate matter and sub

Opening a Cursor Variable The OPEN-FOR statement relates a cursor variable with the multi-row query, executes the query, and then identifies the result set. The syntax for ope

Using Aliases The Select-list items fetched from a cursor related with the %ROWTYPE should have simple names or, if they are expressions, should have aliases. In the example bel