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


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.

Oracle PL SQL Tutorial Oracle PL SQL White Paper PLSQL

Oracle Services Oracle Database Services & Support EBS Consulting & Support

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

Application Load Testing Specializing in load test mentoring consulting and troubleshooting

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 closes the implicit cursor.Foreign Key Constraint 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.ROLLUP SQL .CUBE SQL . 2) Create a PL/SQL block to increase salary of employees in department 17.000 or more.000 and 12% for the employees making $90.STUFF() SQL .blogspot. a) The salary increase is 20% for the employees making less than $90.Default Constraint SQL . SQL .Index Include SQL ..Identity SQL .Oracle SQL & PL/SQL: Examples of Oracle PL/SQL Cursors http://sql-plsql.Covered Query SQL .Binary_Checksum SQL . SQL . 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). 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.Count_Big SQL .Check Constraint SQL . Home 2 of 2 8/05/2011 10:08 PM . After the SELECT INTO statement completes..

Sign up to vote on this title
UsefulNot useful