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
Example of GROUPBY Operator Example: How many students sat each exam, using GROUP BY, NATURAL LEFT JOIN, and COALESCE SELECT CourseId, COALESCE (n, 0) AS n FROM COURS

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

Literature review

Procedural Constraint Enforcement (Triggers) SQL has an alternative method of addressing database integrity, involving event-driven procedural code. The special procedures th

Effect of Anonymous Columns Now, recall that a VALUES expression denotes a table with undefined column names. If an initial value is to be specified when a base table is creat

Parameter and Keyword Description: dynamic_string: This is a string variable, literal, or expression which represents a SQL statement or the PL/SQL block. define_vari

Declaring Cursor Variables Once a REF CURSOR type is define by you, and then you can declare the cursor variables of that type in any PL/SQL block or subprogram. In the exampl

Name Resolution In potentially uncertain SQL statements, the names of the database columns take precedence over the names of the local variables and formal parameters. For e.g.

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

Relational Operators The relational operators permit you to compare randomly complex expressions. The list below provides the meaning of each operator: