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
Tables within a Table - SQL Figure here is an exact copy of the one in the theory book and as before it is just an alternative way of representing some of the information con

Using Cursor Attributes: Every cursor has 4 attributes: %NOTFOUND, %FOUND, %ISOPEN, and %ROWCOUNT. If appended to the cursor name, they return the helpful information about

Comparison Operators The Comparison operators can compare one expression to another. The outcome is always true, false, or null. Usually, you use a comparison operators in condi

Varrays versus Nested Tables The Nested tables are differing from varrays in the following ways: 1)  Varrays have a maximum size, while nested tables do not. 2)  Varrays are

Parameter and Keyword Description: collection_name: This keyword identifies the index-by table, nested table, or varray formerly declared within the present scope. cu

Keyword and Parameter Description: boolean_expression: This is an expression which results the Boolean value TRUE, FALSE, & NULL. It is related with a series of statement

ROWID and UROWID Internally, every database table has a ROWID pseudo column that stores binary values known as rowids. Each rowid shows the storage address of a row. A physical

Creating and Destroying Base Tables: Example shows an SQL command to create the base table counterpart of the ENROLMENT variable Example  Creating a base table. CREATE T

Parameter Aliasing   To optimize the subprogram call, the PL/SQL compiler can decide between the two techniques of the parameter passing. With the by-value techniques, the v

Hi there, I have the final part of a submission to do, it is a demonstration that takes place tomorrow. I do not have to use previous information, but i have resources that sho