Cursors in pl/sql, PL-SQL Programming

Assignment Help:

Cursors

The Oracle uses work areas to execute the SQL statements and to store process information. A PL/SQL construct known as the cursor. Let's you assume name a work area and access its stored information. There are 2 kinds of cursors: implicit and explicit. The PL/SQL implicitly declares a cursor for all the SQL data manipulation, together with queries that return only one row. For queries which return more than one row, you can explicitly declare the cursor to process the rows separately. An example is as shown:

DECLARE

CURSOR c1 IS

SELECT empno, ename, job FROM emp WHERE deptno = 20;

The set of rows returned by a multi-row query is known as result set. The size is the number of rows that meet your search criteria. As the figure shows, an explicit cursor points to the current row in the result set. This permits your program to process the rows one at a time.

854_cursors.png

Figure: Query Processing

The Multi-row query processing is somewhat like the file processing. For e.g., a COBOL program opens a file, processes records, and then closes the file. Similarly, a PL/SQL program opens a cursor, then processes rows returned by a query, and then closes the cursor. Now as a file pointer marks the current position in an open file, a cursor notes the current position in a result set.

You use the OPEN, CLOSE, and FETCH statements to control a cursor. The OPEN statement executes the query related with the cursor, identifies the result set, & positions the cursor before the first row. The FETCH statement retrieves the current row and advances the cursor to the next row. If the last row has been processed, the cursor is then disabling by the CLOSE statement.


Related Discussions:- Cursors in pl/sql

Read-only operator (+) - sql, Read-Only Operator (+) - SQL The term r...

Read-Only Operator (+) - SQL The term read-only operator to the mathematical term function. Here I just need to add that the SQL standard reserves the term function for read-

Merge and truncate in sql, MERGE and TRUNCATE in SQL SQL has two more ...

MERGE and TRUNCATE in SQL SQL has two more table update operators, MERGE and TRUNCATE. MERGE, like INSERT, takes a source table s and uses it to update a target table t. Brief

Closest approximation to relational union - sql, Closest Approximation to R...

Closest Approximation to Relational Union - SQL Actually, just as SQL has several varieties of JOIN, it also has several varieties of UNION, none of which is equivalent to th

Write a program, to write a heap sort program usin pl-sql

to write a heap sort program usin pl-sql

Use the nocopy compiler hint - performance of application, Use the NOCOPY C...

Use the NOCOPY Compiler Hint By default, the OUT and IN OUT parameters are passed by the value i.e. the value of an IN OUT actual parameter is copied into the corresponding fo

Assignment statement in pl sql, Assignment Statement: The assignment s...

Assignment Statement: The assignment statement sets the present value of the variable, parameter, field, or element. The statement consists of an assignment target followed by

Sql query on hospital database, Perform the following queries on the Hospit...

Perform the following queries on the Hospital1.DB using SQL Anywhere (START EARLY!). a. Which patients have purchased the drug "Tylenol"? List the names and addresses. Arrange the

I want online credit application website, Project Description: We organi...

Project Description: We organize an online system called ACPAS we have created a project called EVO that can be use by our customers to integrate their web sites with the Acpas

Effects of null for multiple assignments - sql, Effects of NULL for Multipl...

Effects of NULL for Multiple Assignments - SQL If the row expression given as the source for a multiple assignment evaluates to NULL, then NULL is assigned to each target. If

Union without corresponding - sql, UNION without CORRESPONDING - SQL T...

UNION without CORRESPONDING - SQL The use of UNION without CORRESPONDING. Example is merely by omitting CORRESPONDING, but only because the operands have identical SELECT clau

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd