SlideShare ist ein Scribd-Unternehmen logo
1 von 3
REF CURSORS AND CURSOR VARIABLES
1 This is unconstrained cursor which will return different types depends
upon the user input.
2 Ref cursors can not be closed implicitly.
3 Ref cursor with return type is called strong cursor.
4 Ref cursor with out return type is called weak cursor.
5 You can declare ref cursor type in package spec as well as body.
6 You can declare ref cursor types in local subprograms or anonymous
blocks.
7 Cursor variables can be assigned from one to another.
8 You can declare a cursor variable in one scope and assign another
cursor variable with different scope, then you can use the cursor
variable even though the assigned cursor variable goes out of scope.
9 Cursor variables can be passed as a parameters to the subprograms.
10 Cursor variables modes are in or out or in out.
11 Cursor variables can not be declared in package spec and package
body (excluding subprograms).
12 You can not user remote procedure calls to pass cursor variables from
one server to another.
13 Cursor variables can not use for update clause.
14 You can not assign nulls to cursor variables.
15 You can not compare cursor variables for equality, inequality and
nullity.
Ex:
CREATE OR REPLACE PROCEDURE REF_CURSOR(TABLE_NAME IN VARCHAR) IS
type t is ref cursor;
c t;
v_dept dept%rowtype;
type r is record(ename emp.ename%type,job emp.job%type,sal
emp.sal%type);
v_emp r;
v_stud student.name%type;
BEGIN
if table_name = 'DEPT' then
http://ebiztechncis.blogspot.com
open c for select * from dept;
elsif table_name = 'EMP' then
open c for select ename,job,sal from emp;
elsif table_name = 'STUDENT' then
open c for select name from student;
end if;
loop
if table_name = 'DEPT' then
fetch c into v_dept;
exit when c%notfound;
dbms_output.put_line('Deptno = ' || v_dept.deptno || ' Dname
= ' ||
v_dept.dname || ' Loc = ' ||
v_dept.loc);
elsif table_name = 'EMP' then
fetch c into v_emp;
exit when c%notfound;
dbms_output.put_line('Ename = ' || v_emp.ename || ' Job = '
|| v_emp.job
|| ' Sal = ' || v_emp.sal);
elsif table_name = 'STUDENT' then
fetch c into v_stud;
exit when c%notfound;
dbms_output.put_line('Name = ' || v_stud);
end if;
end loop;
close c;
END;
Output:
SQL> exec ref_cursor('DEPT')
Deptno = 10 Dname = ACCOUNTING Loc = NEW YORK
Deptno = 20 Dname = RESEARCH Loc = DALLAS
Deptno = 30 Dname = SALES Loc = CHICAGO
Deptno = 40 Dname = OPERATIONS Loc = BOSTON
http://ebiztechncis.blogspot.com
SQL> exec ref_cursor('EMP')
Ename = SMITH Job = CLERK Sal = 800
Ename = ALLEN Job = SALESMAN Sal = 1600
Ename = WARD Job = SALESMAN Sal = 1250
Ename = JONES Job = MANAGER Sal = 2975
Ename = MARTIN Job = SALESMAN Sal = 1250
Ename = BLAKE Job = MANAGER Sal = 2850
Ename = CLARK Job = MANAGER Sal = 2450
Ename = SCOTT Job = ANALYST Sal = 3000
Ename = KING Job = PRESIDENT Sal = 5000
Ename = TURNER Job = SALESMAN Sal = 1500
Ename = ADAMS Job = CLERK Sal = 1100
Ename = JAMES Job = CLERK Sal = 950
Ename = FORD Job = ANALYST Sal = 3000
Ename = MILLER Job = CLERK Sal = 1300
SQL> exec ref_cursor('STUDENT')
Name = saketh
Name = srinu
Name = satish
Name = sudha
http://ebiztechncis.blogspot.com

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (19)

C# conditional branching statement
C# conditional branching statementC# conditional branching statement
C# conditional branching statement
 
Flow of Control
Flow of ControlFlow of Control
Flow of Control
 
Presentation of control statement
Presentation of control statement  Presentation of control statement
Presentation of control statement
 
C statements
C statementsC statements
C statements
 
Chap 5(decision making-branching)
Chap 5(decision making-branching)Chap 5(decision making-branching)
Chap 5(decision making-branching)
 
Control structure of c language
Control structure of c languageControl structure of c language
Control structure of c language
 
Control Structure in C
Control Structure in CControl Structure in C
Control Structure in C
 
.Net F# Generic class
.Net F# Generic class.Net F# Generic class
.Net F# Generic class
 
Controlstatment in c
Controlstatment in cControlstatment in c
Controlstatment in c
 
Switch statement, break statement, go to statement
Switch statement, break statement, go to statementSwitch statement, break statement, go to statement
Switch statement, break statement, go to statement
 
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow controlIntroduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
 
Introduction to perl_operators
Introduction to perl_operatorsIntroduction to perl_operators
Introduction to perl_operators
 
Ma3696 Lecture 3
Ma3696 Lecture 3Ma3696 Lecture 3
Ma3696 Lecture 3
 
Cs1123 5 selection_if
Cs1123 5 selection_ifCs1123 5 selection_if
Cs1123 5 selection_if
 
1 plsql introduction1
1 plsql introduction11 plsql introduction1
1 plsql introduction1
 
Branching in C
Branching in CBranching in C
Branching in C
 
Oracle - Program with PL/SQL - Lession 06
Oracle - Program with PL/SQL - Lession 06Oracle - Program with PL/SQL - Lession 06
Oracle - Program with PL/SQL - Lession 06
 
Flow chart
Flow chartFlow chart
Flow chart
 
Functional dependencies in Database Management System
Functional dependencies in Database Management SystemFunctional dependencies in Database Management System
Functional dependencies in Database Management System
 

Andere mochten auch

Colorectal Cancer-A Rising Concern
Colorectal Cancer-A Rising ConcernColorectal Cancer-A Rising Concern
Colorectal Cancer-A Rising ConcernIsDocIn .
 
Oracle Baisc Tutorial
Oracle Baisc TutorialOracle Baisc Tutorial
Oracle Baisc Tutorialbunny0143
 
Joins in databases
Joins in databases Joins in databases
Joins in databases CourseHunt
 
Everything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsEverything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsAbdul Rahman Sherzad
 
Object relational and extended relational databases
Object relational and extended relational databasesObject relational and extended relational databases
Object relational and extended relational databasesSuhad Jihad
 
Lecture 14 requirements modeling - flow and behavior
Lecture 14   requirements modeling - flow and  behaviorLecture 14   requirements modeling - flow and  behavior
Lecture 14 requirements modeling - flow and behaviorIIUI
 
Oracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step GuideOracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step GuideSrinimf-Slides
 
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMSM.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMSSupriya Radhakrishna
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, proceduresVaibhav Kathuria
 

Andere mochten auch (20)

Colorectal Cancer-A Rising Concern
Colorectal Cancer-A Rising ConcernColorectal Cancer-A Rising Concern
Colorectal Cancer-A Rising Concern
 
Payilagam oracle sql & plsql training syllabus
Payilagam oracle sql & plsql training syllabusPayilagam oracle sql & plsql training syllabus
Payilagam oracle sql & plsql training syllabus
 
Oracle Baisc Tutorial
Oracle Baisc TutorialOracle Baisc Tutorial
Oracle Baisc Tutorial
 
En ch23
En ch23En ch23
En ch23
 
Database lab manual
Database lab manualDatabase lab manual
Database lab manual
 
Eer case study
Eer case studyEer case study
Eer case study
 
Joins in databases
Joins in databases Joins in databases
Joins in databases
 
Adbms
AdbmsAdbms
Adbms
 
PLSQL Cursors
PLSQL CursorsPLSQL Cursors
PLSQL Cursors
 
Chapter02
Chapter02Chapter02
Chapter02
 
PLSQL Tutorial
PLSQL TutorialPLSQL Tutorial
PLSQL Tutorial
 
Everything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsEverything about Database JOINS and Relationships
Everything about Database JOINS and Relationships
 
Object relational and extended relational databases
Object relational and extended relational databasesObject relational and extended relational databases
Object relational and extended relational databases
 
Lecture 14 requirements modeling - flow and behavior
Lecture 14   requirements modeling - flow and  behaviorLecture 14   requirements modeling - flow and  behavior
Lecture 14 requirements modeling - flow and behavior
 
Adbms lab manual
Adbms lab manualAdbms lab manual
Adbms lab manual
 
Oracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step GuideOracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step Guide
 
Database Triggers
Database TriggersDatabase Triggers
Database Triggers
 
Chapter19
Chapter19Chapter19
Chapter19
 
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMSM.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, procedures
 

Ähnlich wie Oracle Ref cursors

Ähnlich wie Oracle Ref cursors (20)

Plsql
PlsqlPlsql
Plsql
 
SQL- Introduction to PL/SQL
SQL- Introduction to  PL/SQLSQL- Introduction to  PL/SQL
SQL- Introduction to PL/SQL
 
Pl-sql blocks and block types and variablesdeclaring.pptx
Pl-sql blocks and block types and variablesdeclaring.pptxPl-sql blocks and block types and variablesdeclaring.pptx
Pl-sql blocks and block types and variablesdeclaring.pptx
 
Oracle - Program with PL/SQL - Lession 04
Oracle - Program with PL/SQL - Lession 04Oracle - Program with PL/SQL - Lession 04
Oracle - Program with PL/SQL - Lession 04
 
Cursors.ppt
Cursors.pptCursors.ppt
Cursors.ppt
 
Pl sql programme
Pl sql programmePl sql programme
Pl sql programme
 
Pl sql programme
Pl sql programmePl sql programme
Pl sql programme
 
PL_SQL - II.pptx
PL_SQL - II.pptxPL_SQL - II.pptx
PL_SQL - II.pptx
 
as
asas
as
 
PLSQLmy Updated (1).pptx
PLSQLmy Updated (1).pptxPLSQLmy Updated (1).pptx
PLSQLmy Updated (1).pptx
 
Cursors
CursorsCursors
Cursors
 
a basic java programming and data type.ppt
a basic java programming and data type.ppta basic java programming and data type.ppt
a basic java programming and data type.ppt
 
Programming in Oracle with PL/SQL
Programming in Oracle with PL/SQLProgramming in Oracle with PL/SQL
Programming in Oracle with PL/SQL
 
PL-SQL.pdf
PL-SQL.pdfPL-SQL.pdf
PL-SQL.pdf
 
PL/SQL Code for Sample Projects
PL/SQL Code for Sample ProjectsPL/SQL Code for Sample Projects
PL/SQL Code for Sample Projects
 
PLSQL Note
PLSQL NotePLSQL Note
PLSQL Note
 
Cursor
CursorCursor
Cursor
 
Cursor
CursorCursor
Cursor
 
1 z0 001
1 z0 0011 z0 001
1 z0 001
 
Oracle - Program with PL/SQL - Lession 07
Oracle - Program with PL/SQL - Lession 07Oracle - Program with PL/SQL - Lession 07
Oracle - Program with PL/SQL - Lession 07
 

Mehr von Sekhar Byna

Oracle Applications R12 architecture
Oracle Applications R12 architectureOracle Applications R12 architecture
Oracle Applications R12 architectureSekhar Byna
 
oracle APPS: Weekly Update
oracle APPS: Weekly Updateoracle APPS: Weekly Update
oracle APPS: Weekly UpdateSekhar Byna
 
Oracle APPS :Receivables Auto Invoice
Oracle APPS :Receivables Auto InvoiceOracle APPS :Receivables Auto Invoice
Oracle APPS :Receivables Auto InvoiceSekhar Byna
 
Oracle apps online training
Oracle apps online trainingOracle apps online training
Oracle apps online trainingSekhar Byna
 
Oracle Forms : Timers
Oracle Forms : TimersOracle Forms : Timers
Oracle Forms : TimersSekhar Byna
 
Oracle Forms: Oracle Server features
Oracle Forms: Oracle Server featuresOracle Forms: Oracle Server features
Oracle Forms: Oracle Server featuresSekhar Byna
 
Oracle Forms : Multiple Forms
Oracle Forms : Multiple FormsOracle Forms : Multiple Forms
Oracle Forms : Multiple FormsSekhar Byna
 
Oracle Forms: Record Groups
Oracle Forms: Record GroupsOracle Forms: Record Groups
Oracle Forms: Record GroupsSekhar Byna
 
Oracle Forms: Master Detail form
Oracle Forms: Master Detail formOracle Forms: Master Detail form
Oracle Forms: Master Detail formSekhar Byna
 
Oracle Forms :Object Features In forms
Oracle Forms :Object Features In formsOracle Forms :Object Features In forms
Oracle Forms :Object Features In formsSekhar Byna
 
Oracle Forms: Data Blocks on Different Sources
Oracle Forms: Data Blocks on Different SourcesOracle Forms: Data Blocks on Different Sources
Oracle Forms: Data Blocks on Different SourcesSekhar Byna
 
Oracle Forms :Window and Canvases
Oracle Forms :Window and CanvasesOracle Forms :Window and Canvases
Oracle Forms :Window and CanvasesSekhar Byna
 
Oracle Forms Mouse triggers
Oracle Forms Mouse triggersOracle Forms Mouse triggers
Oracle Forms Mouse triggersSekhar Byna
 
Oracle Forms- key triggers
Oracle Forms- key triggersOracle Forms- key triggers
Oracle Forms- key triggersSekhar Byna
 
Oracle Forms: Menu
Oracle Forms: MenuOracle Forms: Menu
Oracle Forms: MenuSekhar Byna
 
Oracle Forms: Introduction to multiple Forms
Oracle Forms: Introduction to multiple FormsOracle Forms: Introduction to multiple Forms
Oracle Forms: Introduction to multiple FormsSekhar Byna
 
Oracle Forms : Reusable Components
Oracle Forms : Reusable ComponentsOracle Forms : Reusable Components
Oracle Forms : Reusable ComponentsSekhar Byna
 
Oracle Forms : Coding ..
Oracle Forms : Coding ..Oracle Forms : Coding ..
Oracle Forms : Coding ..Sekhar Byna
 
Oracle Forms : Transnational Triggers
Oracle Forms : Transnational TriggersOracle Forms : Transnational Triggers
Oracle Forms : Transnational TriggersSekhar Byna
 
Oracle Forms : Validation Triggers
Oracle Forms : Validation TriggersOracle Forms : Validation Triggers
Oracle Forms : Validation TriggersSekhar Byna
 

Mehr von Sekhar Byna (20)

Oracle Applications R12 architecture
Oracle Applications R12 architectureOracle Applications R12 architecture
Oracle Applications R12 architecture
 
oracle APPS: Weekly Update
oracle APPS: Weekly Updateoracle APPS: Weekly Update
oracle APPS: Weekly Update
 
Oracle APPS :Receivables Auto Invoice
Oracle APPS :Receivables Auto InvoiceOracle APPS :Receivables Auto Invoice
Oracle APPS :Receivables Auto Invoice
 
Oracle apps online training
Oracle apps online trainingOracle apps online training
Oracle apps online training
 
Oracle Forms : Timers
Oracle Forms : TimersOracle Forms : Timers
Oracle Forms : Timers
 
Oracle Forms: Oracle Server features
Oracle Forms: Oracle Server featuresOracle Forms: Oracle Server features
Oracle Forms: Oracle Server features
 
Oracle Forms : Multiple Forms
Oracle Forms : Multiple FormsOracle Forms : Multiple Forms
Oracle Forms : Multiple Forms
 
Oracle Forms: Record Groups
Oracle Forms: Record GroupsOracle Forms: Record Groups
Oracle Forms: Record Groups
 
Oracle Forms: Master Detail form
Oracle Forms: Master Detail formOracle Forms: Master Detail form
Oracle Forms: Master Detail form
 
Oracle Forms :Object Features In forms
Oracle Forms :Object Features In formsOracle Forms :Object Features In forms
Oracle Forms :Object Features In forms
 
Oracle Forms: Data Blocks on Different Sources
Oracle Forms: Data Blocks on Different SourcesOracle Forms: Data Blocks on Different Sources
Oracle Forms: Data Blocks on Different Sources
 
Oracle Forms :Window and Canvases
Oracle Forms :Window and CanvasesOracle Forms :Window and Canvases
Oracle Forms :Window and Canvases
 
Oracle Forms Mouse triggers
Oracle Forms Mouse triggersOracle Forms Mouse triggers
Oracle Forms Mouse triggers
 
Oracle Forms- key triggers
Oracle Forms- key triggersOracle Forms- key triggers
Oracle Forms- key triggers
 
Oracle Forms: Menu
Oracle Forms: MenuOracle Forms: Menu
Oracle Forms: Menu
 
Oracle Forms: Introduction to multiple Forms
Oracle Forms: Introduction to multiple FormsOracle Forms: Introduction to multiple Forms
Oracle Forms: Introduction to multiple Forms
 
Oracle Forms : Reusable Components
Oracle Forms : Reusable ComponentsOracle Forms : Reusable Components
Oracle Forms : Reusable Components
 
Oracle Forms : Coding ..
Oracle Forms : Coding ..Oracle Forms : Coding ..
Oracle Forms : Coding ..
 
Oracle Forms : Transnational Triggers
Oracle Forms : Transnational TriggersOracle Forms : Transnational Triggers
Oracle Forms : Transnational Triggers
 
Oracle Forms : Validation Triggers
Oracle Forms : Validation TriggersOracle Forms : Validation Triggers
Oracle Forms : Validation Triggers
 

Kürzlich hochgeladen

Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROmotivationalword821
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 

Kürzlich hochgeladen (20)

Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTRO
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 

Oracle Ref cursors

  • 1. REF CURSORS AND CURSOR VARIABLES 1 This is unconstrained cursor which will return different types depends upon the user input. 2 Ref cursors can not be closed implicitly. 3 Ref cursor with return type is called strong cursor. 4 Ref cursor with out return type is called weak cursor. 5 You can declare ref cursor type in package spec as well as body. 6 You can declare ref cursor types in local subprograms or anonymous blocks. 7 Cursor variables can be assigned from one to another. 8 You can declare a cursor variable in one scope and assign another cursor variable with different scope, then you can use the cursor variable even though the assigned cursor variable goes out of scope. 9 Cursor variables can be passed as a parameters to the subprograms. 10 Cursor variables modes are in or out or in out. 11 Cursor variables can not be declared in package spec and package body (excluding subprograms). 12 You can not user remote procedure calls to pass cursor variables from one server to another. 13 Cursor variables can not use for update clause. 14 You can not assign nulls to cursor variables. 15 You can not compare cursor variables for equality, inequality and nullity. Ex: CREATE OR REPLACE PROCEDURE REF_CURSOR(TABLE_NAME IN VARCHAR) IS type t is ref cursor; c t; v_dept dept%rowtype; type r is record(ename emp.ename%type,job emp.job%type,sal emp.sal%type); v_emp r; v_stud student.name%type; BEGIN if table_name = 'DEPT' then http://ebiztechncis.blogspot.com
  • 2. open c for select * from dept; elsif table_name = 'EMP' then open c for select ename,job,sal from emp; elsif table_name = 'STUDENT' then open c for select name from student; end if; loop if table_name = 'DEPT' then fetch c into v_dept; exit when c%notfound; dbms_output.put_line('Deptno = ' || v_dept.deptno || ' Dname = ' || v_dept.dname || ' Loc = ' || v_dept.loc); elsif table_name = 'EMP' then fetch c into v_emp; exit when c%notfound; dbms_output.put_line('Ename = ' || v_emp.ename || ' Job = ' || v_emp.job || ' Sal = ' || v_emp.sal); elsif table_name = 'STUDENT' then fetch c into v_stud; exit when c%notfound; dbms_output.put_line('Name = ' || v_stud); end if; end loop; close c; END; Output: SQL> exec ref_cursor('DEPT') Deptno = 10 Dname = ACCOUNTING Loc = NEW YORK Deptno = 20 Dname = RESEARCH Loc = DALLAS Deptno = 30 Dname = SALES Loc = CHICAGO Deptno = 40 Dname = OPERATIONS Loc = BOSTON http://ebiztechncis.blogspot.com
  • 3. SQL> exec ref_cursor('EMP') Ename = SMITH Job = CLERK Sal = 800 Ename = ALLEN Job = SALESMAN Sal = 1600 Ename = WARD Job = SALESMAN Sal = 1250 Ename = JONES Job = MANAGER Sal = 2975 Ename = MARTIN Job = SALESMAN Sal = 1250 Ename = BLAKE Job = MANAGER Sal = 2850 Ename = CLARK Job = MANAGER Sal = 2450 Ename = SCOTT Job = ANALYST Sal = 3000 Ename = KING Job = PRESIDENT Sal = 5000 Ename = TURNER Job = SALESMAN Sal = 1500 Ename = ADAMS Job = CLERK Sal = 1100 Ename = JAMES Job = CLERK Sal = 950 Ename = FORD Job = ANALYST Sal = 3000 Ename = MILLER Job = CLERK Sal = 1300 SQL> exec ref_cursor('STUDENT') Name = saketh Name = srinu Name = satish Name = sudha http://ebiztechncis.blogspot.com