Using count, PL-SQL Programming

Using COUNT

The COUNT returns the number of elements that a collection presently contains. For instance, when a varray projects contains 15 elements, then the following IF condition is true:

IF projects.COUNT = 15 THEN...

The COUNT is very useful as the present size of a collection is not always known. For e.g. if you fetch a column of the Oracle data into a nested table, then how many elements does the table contain? The COUNT provides you the answer.

You can also use the COUNT where an integer expression is allowed. In the next e.g. you use COUNT to specify the upper bound of a loop range:

FOR i IN 1..courses.COUNT LOOP ...

For the varrays, the COUNT is always equals to LAST. For nested tables, COUNT generally equals to LAST. But, if you delete elements from the middle of a nested table, then the COUNT becomes smaller than LAST.

Posted Date: 10/4/2012 3:13:37 AM | Location : United States







Related Discussions:- Using count, Assignment Help, Ask Question on Using count, Get Answer, Expert's Help, Using count Discussions

Write discussion on Using count
Your posts are moderated
Related Questions
Use Bulk Binds If SQL statements execute inside a loop using the collection elements as bind variables, context switching between the PL/SQL & SQL engines can slow down the ex

Example of Cast Operator So long as CAST is used as shown, we could obtain the total marks for each exam in similar fashion, using SUM (Mark) AS TotalMarks. However, this giv

Accessing Attributes: You can refer to an attribute only by its name not by its position in the object type. To access or modify the value of an attribute, you can use the dot

Built-In Functions The PL/SQL provides a lot of powerful functions to help you to manipulate the data. These built-in functions fall into the categories as shown below: error r

Implicit Cursor is declared and used by the oracle environment internally. while the explicit cursor is declared and used by the external user. more over implicitly cursors are no

Package Specification The package specifications contain the public declarations. The scopes of these declarations are local to your database representation and global to the

Using FIRST and LAST FIRST and LAST return the first and last (minimum and maximum) index numbers in a collection. When the collection is empty, the FIRST and LAST return NULL

Implicit Cursors The Oracle implicitly opens a cursor to process each SQL statement not related with an explicitly declared cursor. The PL/SQL lets you refer to the most recen

Raise_application_error -  procedure of package DBMS_STANDARD , allows to issue an user_defined error messages by stored sub-program or database trigger.

Forward Declarations The PL/SQL needs that you declare an identifier before using it. And hence, you should declare a subprogram before calling it. For illustration, the decla