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

Oracle SQL & PL - SQL - Examples of Oracle PL - SQL Cursors

Oracle SQL and PL / SQL: Examples of Oracle PL/ SQL Cursors Share Report Abuse Next Blog>> Create Blog Sign In Database recovery Fix Databases and Recover Data. Fast Turnaround. Speak To An Expert Now. Www.data-recovery.com.au Oracle SQL SQL Introduction SQL Syntax SQL select SQL Insert SQL Update SQL Delete SQL Joins SQL Explicit vs. Implicit Joins SQL Group by SQL Group by Examples SQL - Nth Highest Salary SQL Second

Uploaded by

Hansa Dammulla
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
483 views

Oracle SQL & PL - SQL - Examples of Oracle PL - SQL Cursors

Oracle SQL and PL / SQL: Examples of Oracle PL/ SQL Cursors Share Report Abuse Next Blog>> Create Blog Sign In Database recovery Fix Databases and Recover Data. Fast Turnaround. Speak To An Expert Now. Www.data-recovery.com.au Oracle SQL SQL Introduction SQL Syntax SQL select SQL Insert SQL Update SQL Delete SQL Joins SQL Explicit vs. Implicit Joins SQL Group by SQL Group by Examples SQL - Nth Highest Salary SQL Second

Uploaded by

Hansa Dammulla
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Oracle SQL & PL/SQL: Examples of Oracle PL/SQL Cursors

http://sql-plsql.blogspot.com/2007/05/examples-of-oracle-plsql-cursors...

Share

Report Abuse

Next Blog

Create Blog

Sign In

Oracle SQL & PL/SQL


Ads by Google

RSS Feed
Database Recovery Fix Databases & Recover Data. Fast Turnaround. Speak To An Expert Now.
www.data-recovery.com.au

Oracle PL SQL Tutorial Oracle PL SQL White Paper PLSQL

Oracle Services Oracle Database Services & Support EBS Consulting & Support
www.dhanushinfotech.com

Oracle SQL & PL/SQL


Oracle SQL SQL Introduction SQL Syntax SQL Select SQL Insert SQL Update SQL Delete SQL Joins SQL Explicit vs. Implicit Joins SQL Group By SQL Group By Examples SQL Having SQL - IN SQL - NULLs Functional Dependencies ACID Properties SQL SubQueries SQL - Queries With Examples SQL Views Insert, Update, Delete Views SQL Join Views SQL Inline Views SQL - Nth Highest Salary SQL Second Highest Salary SQL - Difference Truncate / Delete SQL - Difference Truncate / Drop SQL - Difference HAVING / WHERE SQL - Difference CAST / CONVERT SQL - Difference NOT IN / NOT EXIST SQL - Difference IN / EXISTS SQL - Difference UNION / UNION ALL SQL - REPLACE SQL - TOP SQL - LIKE SQL - SELECT INTO SQL - CREATE TABLE SQL - CREATE TABLE (More Examples) SQL - ALTER TABLE SQL - Difference views / Materialized views SQL Count SQL Update SQL Clustered / Non-Clustered Indexes SQL - Delete Duplicate Records SQL - Difference Unique/Primary Key SQL - GETDATE() SQL - DATEDIFF() SQL - DATEADD() SQL - DATEPART() SQL - Convert() SQL - SUM() SQL - AVG() SQL - MIN() SQL - MAX() SQL - Insert Into Select SQL - Insert Multiple Values In Table SQL - Referential Integrity SQL - Not Null Constraint SQL - Unique Constraint SQL - Primary Key Constraint

Free Dynamics AX Training Accelerate your ERP career now Switch skills to Microsoft Dynamics
www.linkedin.com

Application Load Testing Specializing in load test mentoring consulting and troubleshooting
loadtest.com.au

Examples of Oracle PL/SQL Cursors


Examples of Oracle PL/SQL Cursors: 1) Retrieving the records from the emp table and displaying them one by one using cursors: CREATE OR REPLACE PROCEDURE my_proc IS var_empno emp.empno%type; var_ename emp.ename%type; var_sal emp.sal%type; //declaring a cursor// CURSOR EMP_CURSOR IS select empno, ename, sal from emp; BEGIN //opening a cursor// open EMP_CURSOR; LOOP //fetching records from a cursor// fetch EMP_CURSOR into var_empno, var_ename, var_sal; //testing exit conditions// EXIT when EMP_CURSOR%NOTFOUND; IF (var_sal > 1000) then DBMS_OUTPUT.put_line(var_empno || ' ' || var_ename || ' ' || var_sal); ELSE DBMS_OUTPUT.put_line(var_ename || ' sal is less then 1000'); END IF; END LOOP; //closing the cursor// close EMP_CURSOR; DBMS_OUTPUT.put_line('DONE');

1 of 2

8/05/2011 10:08 PM

Oracle SQL & PL/SQL: Examples of Oracle PL/SQL Cursors

http://sql-plsql.blogspot.com/2007/05/examples-of-oracle-plsql-cursors...

END; 2) Create a PL/SQL block to increase salary of employees in department 17. a) The salary increase is 20% for the employees making less than $90,000 and 12% for the employees making $90,000 or more. b) Use a cursor with a FOR UPDATE clause. c) Update the salary with a WHERE CURRENT OF clause in a cursor FOR loop (cursor FOR loop problem).

SQL - Foreign Key Constraint SQL - Default Constraint SQL - Check Constraint SQL - ROLLUP SQL - CUBE SQL - STUFF() SQL - Count_Big SQL - Binary_Checksum SQL - Checksum_AGG SQL - Index Include SQL - Covered Query SQL - Identity SQL - sp_columns SQL Interview Questions Oracle PL/SQL PL/SQL Introduction PL/SQL Procedures PL/SQL Functions PL/SQL Collections PL/SQL Records PL/SQL Table Based Records PL/SQL Programmer Defined Records PL/SQL Cursor Based Records PL/SQL Tables PL/SQL Varrays PL/SQL Nested Tables PL/SQL Triggers PL/SQL Cursors PL/SQL Implicit Cursors PL/SQL Explicit Cursors PL/SQL REF Cursors PL/SQL Cursor For Loop PL/SQL Cursors with Parameters PL/SQL Where Current Of and For Update Examples of PL/SQL Cursors PL/SQL Interview Questions SQL PL/SQL Sitemap

PL/SQL procedure successfully completed. 3) An example of an Implicit cursor

Oracle automatically associates an implicit cursor with the SELECT INTO statement and fetches the values for the variables var_firstname and var_lastname. After the SELECT INTO statement completes, Oracle closes the implicit cursor.

Home

2 of 2

8/05/2011 10:08 PM

You might also like