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
Keyword and Parameter Description select_statement: This is a query which returns a result set of the rows. Its syntax is such that of select_ into_statement without the IN

Data Types in SQL - Integer INTEGER or  synonymously INT, for integers within a certain range. SQL additionally has types SMALLINT and BIGINT for certain ranges of integers. T

Overriding Default Locking By default, the Oracle locks the data structures for you automatically. Though, you can request exact data locks on rows or tables when it is to you

Calling Constructors: The Calls to a constructor are allowed wherever the function calls are allowed. Similarly to the functions, a constructor is called as a section of an ex

Example of COALESCE operator Example: Give the total of marks for each exam (simplified solution) SELECT CourseId, COALESCE ((SELECT SUM (Mark) FROM EXAM_MARK AS EM

which operation is used if we are interested in only certain columns of a table?

Using DELETE This process has three forms. The DELETE removes all elements from the collection. DELETE(n) removes the nth element from the nested table. When n is null, then D

Write SQL queries to solve the following specifications. Include the query AND THE OUTPUT.  A screen dump of the output is acceptable. Show as many rows as you can. A screen dump i

Develop Data Business Intelligence Project Project Description: We are linking our Microsoft SQL Database to GoodData Business Intelligence. We are seeking somebody who has e

Primary Key - SQL A PRIMARY KEY specification carries an implicit NOT NULL constraint on each column of the specified key. When more than one key constraint is required, the k