0% found this document useful (0 votes)
137 views

Cursor in Oracle

This document is about the cursor concept in Oracle. The central purpose of the Oracle PL/SQL language is to make it as easy and efficient as possible to query and change the contents of tables in a database. You must, of course, use the SQL language to access tables, and each time you do so, you use a cursor to get the job done. A cursor is a pointer to a private SQL area that stores information about the processing of a SELECT or data manipulation language (DML) statement (INSERT, UPDATE, DELETE, or MERGE). Cursor management of DML statements is handled by Oracle Database, but PL/SQL offers several ways to define and manipulate cursors to execute SELECT statements. This article focuses on the most-common ways programmers execute SELECT statements in PL/SQL, namely

Uploaded by

deveshdashora123
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views

Cursor in Oracle

This document is about the cursor concept in Oracle. The central purpose of the Oracle PL/SQL language is to make it as easy and efficient as possible to query and change the contents of tables in a database. You must, of course, use the SQL language to access tables, and each time you do so, you use a cursor to get the job done. A cursor is a pointer to a private SQL area that stores information about the processing of a SELECT or data manipulation language (DML) statement (INSERT, UPDATE, DELETE, or MERGE). Cursor management of DML statements is handled by Oracle Database, but PL/SQL offers several ways to define and manipulate cursors to execute SELECT statements. This article focuses on the most-common ways programmers execute SELECT statements in PL/SQL, namely

Uploaded by

deveshdashora123
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

create view ccc as select * from company where company_id=&cid; create cursor ddd (id in number) is products - pno,pname,categoryid,companyid

create cursor pro_info (pid in number) select pno,pname,category_name, company_name, select sum(amount) from purchase where prono=pid, select sum(amount) from sales where prono=pid, from products, categories, companies where products.companyid=companies.compid a nd products.categoryid = categories.category_id and products.pno = pid; declare cominfo company_cur%ROWTYPE; begin OPEN company_cur(101); loop while company_cur % found FETCH company_cur into cominfo; insert into othercompany values(cominfo.company_id, comi nfo.company_name, cominfo.company_city); end loop; CLOSE company_cur; end; declare cominfo company_cur%ROWTYPE; begin OPEN company_cur(101); loop FETCH company_cur into cominfo; EXIT WHEN company_cur % NOTFOUND; insert into othercompany values(cominfo.company_id, cominfo.comp any_name, cominfo.company_city); end loop; CLOSE company_cur; end;

You might also like