Daily Archives: October 29, 2009

What is a correlated sub query?

A correlated is a query in where the inner query is executed for each record returned
by the outer query.

For Example the query:

select * from emp a
where exists (select 1 from dept b
where a.deptno = b.deptno);

Will execute the sub query for each record returned from the first query (table emp).
If the employee is assigned a deptno then only that record will be displayed.

What are the Oracle Cursor Attributes ?

There are four attributes in Oracle cursor namely:

%ISOPEN
%FOUND
%NOTFOUND
%ROWCOUNT

Atrribute usage:

%ISOPEN – Returned Values TRUE or FALSE.
Returns TRUE if the cursor is open.
Retruns FALSE if cursor is not open.

%FOUND – Returned Values TRUE or FALSE.
Returns TRUE if the cursor returned values.
Retruns FALSE if cursor does not return values.

%NOTFOUND – Returned Values TRUE or FALSE.
Returns FALSE if the cursor returned values.
Retruns TRUE if cursor does not return values.

%ROWCOUNT – Returns a number.
This attribute will retrun the number of records fetched by the cursor.



Loading