SlideShare a Scribd company logo
1 of 4
Download to read offline
P L / S Q L T u t o r i a l - B y E r G u r p r e e t S i n g h
Visit: http://gsbprogramming.blogspot.in
P L / S Q L T u t o r i a l - B y E r G u r p r e e t S i n g h
Visit: http://gsbprogramming.blogspot.in
Iterative or Looping statements in PL/SQL
Basic structure of a Looping statement is:
PL/SQL provides following Looping statements:
 BASIC LOOP
 WHILE LOOP
 FOR LOOP
 Nested Loops
P L / S Q L T u t o r i a l - B y E r G u r p r e e t S i n g h
Visit: http://gsbprogramming.blogspot.in
 BASIC LOOP
Syntax:
LOOP
<Looping statements>
END LOOP;
Note: EXIT or EXIT WHEN is used for breaking the loop
Condition must be that statement which results a Boolean value i.e. either true or false
For example
DECLARE
vCount number :=1;
BEGIN
LOOP
dbms_output.put(vCount||‘ ’);
vCount:=vCount + 1;
EXIT WHEN vCount=5;
END LOOP;
dbms_output.new_line;
END;
Will print:
1 2 3 4
dbms_output.new_line; is used to flush the output, otherwise your output will not be shown
 WHILE LOOP
Syntax:
WHILE condition LOOP
<Looping statements>
END LOOP;
Condition must be that statement which results a Boolean value i.e. either true or false
For example:
DECLARE
vCount number :=1;
BEGIN
WHILE vCount!=5 LOOP
dbms_output.put(vCount||‘ ’);
vCount:=vCount + 1;
END LOOP;
dbms_output.new_line;
END;
P L / S Q L T u t o r i a l - B y E r G u r p r e e t S i n g h
Visit: http://gsbprogramming.blogspot.in
Will print:
1 2 3 4
 FOR LOOP
Syntax:
FOR counter IN start_value . . end_value LOOP
<Looping statements>
END LOOP;
Counter must have value between start_value and end_value, only then looping statements will
execute. You cannot update the value of counter
For example
BEGIN
FOR vCount IN 1 .. 4 LOOP
dbms_output.put(vCount||‘ ’);
END LOOP;
dbms_output.new_line;
END;
Will print:
1 2 3 4
 Nested LOOPs
Loops can also be nested in each other. For example:
Condition must be that statement which results a Boolean value i.e. either true or false
For example
BEGIN
FOR i IN 1 .. 4 LOOP
FOR j IN 1 .. i LOOP
dbms_output.put(i||‘ ’);
END LOOP;
dbms_output.new_line;
END LOOP;
END;
Will print:
1
2 2
3 3 3
4 4 4 4

More Related Content

What's hot

What's hot (20)

PL/SQL Code for Sample Projects
PL/SQL Code for Sample ProjectsPL/SQL Code for Sample Projects
PL/SQL Code for Sample Projects
 
Activities on Operands
Activities on OperandsActivities on Operands
Activities on Operands
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
Function overloading(C++)
Function overloading(C++)Function overloading(C++)
Function overloading(C++)
 
Increment and Decrement operators in C++
Increment and Decrement operators in C++Increment and Decrement operators in C++
Increment and Decrement operators in C++
 
function in c
function in cfunction in c
function in c
 
1 introducing c language
1  introducing c language1  introducing c language
1 introducing c language
 
Functions in c
Functions in cFunctions in c
Functions in c
 
C language function
C language functionC language function
C language function
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
 
Function & Recursion in C
Function & Recursion in CFunction & Recursion in C
Function & Recursion in C
 
Compiler Design Lab File
Compiler Design Lab FileCompiler Design Lab File
Compiler Design Lab File
 
Effective PHP. Part 5
Effective PHP. Part 5Effective PHP. Part 5
Effective PHP. Part 5
 
Seasar Conference 2009 White - DI
Seasar Conference 2009 White - DISeasar Conference 2009 White - DI
Seasar Conference 2009 White - DI
 
Effective PHP. Part 4
Effective PHP. Part 4Effective PHP. Part 4
Effective PHP. Part 4
 
Effective PHP. Part 2
Effective PHP. Part 2Effective PHP. Part 2
Effective PHP. Part 2
 
C programming Workshop
C programming WorkshopC programming Workshop
C programming Workshop
 
C programming function
C  programming functionC  programming function
C programming function
 
What is c
What is cWhat is c
What is c
 
Effective PHP. Part 3
Effective PHP. Part 3Effective PHP. Part 3
Effective PHP. Part 3
 

Viewers also liked

Assessment for Learning Using Moodle
Assessment for Learning Using MoodleAssessment for Learning Using Moodle
Assessment for Learning Using MoodleCheryl Cox
 
Considerations for creating meaningful assessments in Moodle
Considerations for creating meaningful assessments in MoodleConsiderations for creating meaningful assessments in Moodle
Considerations for creating meaningful assessments in MoodleHazel Owen
 
Jugadores míticos del madrid (Dani Y Pablo)
Jugadores míticos del madrid (Dani Y Pablo)Jugadores míticos del madrid (Dani Y Pablo)
Jugadores míticos del madrid (Dani Y Pablo)pablobernad
 
Cms lcms-theory
Cms lcms-theoryCms lcms-theory
Cms lcms-theoryagostont
 
Acpet Moodle from Scratch Version 2
Acpet Moodle from Scratch Version 2Acpet Moodle from Scratch Version 2
Acpet Moodle from Scratch Version 2Yum Studio
 
LCMS - Content Artery To The Portal
LCMS - Content Artery To The PortalLCMS - Content Artery To The Portal
LCMS - Content Artery To The Portalrnjohnso
 
Lms And Lcms
Lms And LcmsLms And Lcms
Lms And Lcmstinech
 
LCMS, LMS, & CMS in eLearning
LCMS, LMS, & CMS in eLearningLCMS, LMS, & CMS in eLearning
LCMS, LMS, & CMS in eLearningJibril Touzi
 

Viewers also liked (12)

Moodle Keynote July 2011
Moodle Keynote July 2011Moodle Keynote July 2011
Moodle Keynote July 2011
 
Assessment for Learning Using Moodle
Assessment for Learning Using MoodleAssessment for Learning Using Moodle
Assessment for Learning Using Moodle
 
Considerations for creating meaningful assessments in Moodle
Considerations for creating meaningful assessments in MoodleConsiderations for creating meaningful assessments in Moodle
Considerations for creating meaningful assessments in Moodle
 
Jugadores míticos del madrid (Dani Y Pablo)
Jugadores míticos del madrid (Dani Y Pablo)Jugadores míticos del madrid (Dani Y Pablo)
Jugadores míticos del madrid (Dani Y Pablo)
 
Cms lcms-theory
Cms lcms-theoryCms lcms-theory
Cms lcms-theory
 
Acpet Moodle from Scratch Version 2
Acpet Moodle from Scratch Version 2Acpet Moodle from Scratch Version 2
Acpet Moodle from Scratch Version 2
 
LMS & LCMS
LMS & LCMSLMS & LCMS
LMS & LCMS
 
LCMS - Content Artery To The Portal
LCMS - Content Artery To The PortalLCMS - Content Artery To The Portal
LCMS - Content Artery To The Portal
 
Moodle February 2013
Moodle February 2013Moodle February 2013
Moodle February 2013
 
Lms And Lcms
Lms And LcmsLms And Lcms
Lms And Lcms
 
LCMS, LMS, & CMS in eLearning
LCMS, LMS, & CMS in eLearningLCMS, LMS, & CMS in eLearning
LCMS, LMS, & CMS in eLearning
 
CMS, LMS & LCMS
CMS, LMS & LCMSCMS, LMS & LCMS
CMS, LMS & LCMS
 

Similar to PL/SQL Part 5 (20)

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
 
C-PROGRAMING FOR LOOP PPT
C-PROGRAMING FOR LOOP PPTC-PROGRAMING FOR LOOP PPT
C-PROGRAMING FOR LOOP PPT
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KRLoops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
 
PLSQL (1).ppt
PLSQL (1).pptPLSQL (1).ppt
PLSQL (1).ppt
 
Plsql
PlsqlPlsql
Plsql
 
C language 2
C language 2C language 2
C language 2
 
C++ programming
C++ programmingC++ programming
C++ programming
 
banaz hilmy.pptx
banaz hilmy.pptxbanaz hilmy.pptx
banaz hilmy.pptx
 
loops in C ppt.pdf
loops in C ppt.pdfloops in C ppt.pdf
loops in C ppt.pdf
 
Flow of control ppt
Flow of control pptFlow of control ppt
Flow of control ppt
 
Blackfin Loop Asm
Blackfin Loop AsmBlackfin Loop Asm
Blackfin Loop Asm
 
Fundamentals of Programming Chapter 7
Fundamentals of Programming Chapter 7Fundamentals of Programming Chapter 7
Fundamentals of Programming Chapter 7
 
Php Loop
Php LoopPhp Loop
Php Loop
 
loops and iteration.docx
loops and iteration.docxloops and iteration.docx
loops and iteration.docx
 
Loops c++
Loops c++Loops c++
Loops c++
 
Loops In C++
Loops In C++Loops In C++
Loops In C++
 
PLSQL Tutorial
PLSQL TutorialPLSQL Tutorial
PLSQL Tutorial
 
Xamarin: Branching and Looping
Xamarin: Branching and LoopingXamarin: Branching and Looping
Xamarin: Branching and Looping
 

More from Gurpreet singh

Introduction to Oracle Fusion BIP Reporting
Introduction to Oracle Fusion BIP ReportingIntroduction to Oracle Fusion BIP Reporting
Introduction to Oracle Fusion BIP ReportingGurpreet singh
 
Understanding Flex Fields with Accounting Flexfields(Chart of Accounts) in O...
Understanding Flex Fields with  Accounting Flexfields(Chart of Accounts) in O...Understanding Flex Fields with  Accounting Flexfields(Chart of Accounts) in O...
Understanding Flex Fields with Accounting Flexfields(Chart of Accounts) in O...Gurpreet singh
 
Oracle Application Developmenr Framework
Oracle Application Developmenr FrameworkOracle Application Developmenr Framework
Oracle Application Developmenr FrameworkGurpreet singh
 
Oracle advanced queuing
Oracle advanced queuingOracle advanced queuing
Oracle advanced queuingGurpreet singh
 
Generics and collections in Java
Generics and collections in JavaGenerics and collections in Java
Generics and collections in JavaGurpreet singh
 
IO Streams, Serialization, de-serialization, autoboxing
IO Streams, Serialization, de-serialization, autoboxingIO Streams, Serialization, de-serialization, autoboxing
IO Streams, Serialization, de-serialization, autoboxingGurpreet singh
 
Creating business group in oracle apps
Creating business group in oracle appsCreating business group in oracle apps
Creating business group in oracle appsGurpreet singh
 
Defing locations in Oracle Apps
Defing locations in Oracle AppsDefing locations in Oracle Apps
Defing locations in Oracle AppsGurpreet singh
 
Assigning role AME_BUS_ANALYST
Assigning role AME_BUS_ANALYSTAssigning role AME_BUS_ANALYST
Assigning role AME_BUS_ANALYSTGurpreet singh
 
Introduction to Data Flow Diagram (DFD)
Introduction to Data Flow Diagram (DFD)Introduction to Data Flow Diagram (DFD)
Introduction to Data Flow Diagram (DFD)Gurpreet singh
 
Ingenium test(Exam Management System) Project Presentation (Full)
Ingenium test(Exam Management System) Project Presentation (Full)Ingenium test(Exam Management System) Project Presentation (Full)
Ingenium test(Exam Management System) Project Presentation (Full)Gurpreet singh
 
Computer Graphics Notes
Computer Graphics NotesComputer Graphics Notes
Computer Graphics NotesGurpreet singh
 

More from Gurpreet singh (20)

Introduction to Oracle Fusion BIP Reporting
Introduction to Oracle Fusion BIP ReportingIntroduction to Oracle Fusion BIP Reporting
Introduction to Oracle Fusion BIP Reporting
 
Why Messaging system?
Why Messaging system?Why Messaging system?
Why Messaging system?
 
Understanding Flex Fields with Accounting Flexfields(Chart of Accounts) in O...
Understanding Flex Fields with  Accounting Flexfields(Chart of Accounts) in O...Understanding Flex Fields with  Accounting Flexfields(Chart of Accounts) in O...
Understanding Flex Fields with Accounting Flexfields(Chart of Accounts) in O...
 
Oracle Application Developmenr Framework
Oracle Application Developmenr FrameworkOracle Application Developmenr Framework
Oracle Application Developmenr Framework
 
Java Servlet part 3
Java Servlet part 3Java Servlet part 3
Java Servlet part 3
 
Oracle advanced queuing
Oracle advanced queuingOracle advanced queuing
Oracle advanced queuing
 
Oracle SQL Part 3
Oracle SQL Part 3Oracle SQL Part 3
Oracle SQL Part 3
 
Oracle SQL Part 2
Oracle SQL Part 2Oracle SQL Part 2
Oracle SQL Part 2
 
Oracle SQL Part1
Oracle SQL Part1Oracle SQL Part1
Oracle SQL Part1
 
Generics and collections in Java
Generics and collections in JavaGenerics and collections in Java
Generics and collections in Java
 
IO Streams, Serialization, de-serialization, autoboxing
IO Streams, Serialization, de-serialization, autoboxingIO Streams, Serialization, de-serialization, autoboxing
IO Streams, Serialization, de-serialization, autoboxing
 
Java Servlets Part 2
Java Servlets Part 2Java Servlets Part 2
Java Servlets Part 2
 
Creating business group in oracle apps
Creating business group in oracle appsCreating business group in oracle apps
Creating business group in oracle apps
 
Defing locations in Oracle Apps
Defing locations in Oracle AppsDefing locations in Oracle Apps
Defing locations in Oracle Apps
 
Assigning role AME_BUS_ANALYST
Assigning role AME_BUS_ANALYSTAssigning role AME_BUS_ANALYST
Assigning role AME_BUS_ANALYST
 
PL/SQL Part 1
PL/SQL Part 1PL/SQL Part 1
PL/SQL Part 1
 
Introduction to Data Flow Diagram (DFD)
Introduction to Data Flow Diagram (DFD)Introduction to Data Flow Diagram (DFD)
Introduction to Data Flow Diagram (DFD)
 
Ingenium test(Exam Management System) Project Presentation (Full)
Ingenium test(Exam Management System) Project Presentation (Full)Ingenium test(Exam Management System) Project Presentation (Full)
Ingenium test(Exam Management System) Project Presentation (Full)
 
Computer Graphics Notes
Computer Graphics NotesComputer Graphics Notes
Computer Graphics Notes
 
Learn Java Part 11
Learn Java Part 11Learn Java Part 11
Learn Java Part 11
 

Recently uploaded

Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 

Recently uploaded (20)

Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 

PL/SQL Part 5

  • 1. P L / S Q L T u t o r i a l - B y E r G u r p r e e t S i n g h Visit: http://gsbprogramming.blogspot.in
  • 2. P L / S Q L T u t o r i a l - B y E r G u r p r e e t S i n g h Visit: http://gsbprogramming.blogspot.in Iterative or Looping statements in PL/SQL Basic structure of a Looping statement is: PL/SQL provides following Looping statements:  BASIC LOOP  WHILE LOOP  FOR LOOP  Nested Loops
  • 3. P L / S Q L T u t o r i a l - B y E r G u r p r e e t S i n g h Visit: http://gsbprogramming.blogspot.in  BASIC LOOP Syntax: LOOP <Looping statements> END LOOP; Note: EXIT or EXIT WHEN is used for breaking the loop Condition must be that statement which results a Boolean value i.e. either true or false For example DECLARE vCount number :=1; BEGIN LOOP dbms_output.put(vCount||‘ ’); vCount:=vCount + 1; EXIT WHEN vCount=5; END LOOP; dbms_output.new_line; END; Will print: 1 2 3 4 dbms_output.new_line; is used to flush the output, otherwise your output will not be shown  WHILE LOOP Syntax: WHILE condition LOOP <Looping statements> END LOOP; Condition must be that statement which results a Boolean value i.e. either true or false For example: DECLARE vCount number :=1; BEGIN WHILE vCount!=5 LOOP dbms_output.put(vCount||‘ ’); vCount:=vCount + 1; END LOOP; dbms_output.new_line; END;
  • 4. P L / S Q L T u t o r i a l - B y E r G u r p r e e t S i n g h Visit: http://gsbprogramming.blogspot.in Will print: 1 2 3 4  FOR LOOP Syntax: FOR counter IN start_value . . end_value LOOP <Looping statements> END LOOP; Counter must have value between start_value and end_value, only then looping statements will execute. You cannot update the value of counter For example BEGIN FOR vCount IN 1 .. 4 LOOP dbms_output.put(vCount||‘ ’); END LOOP; dbms_output.new_line; END; Will print: 1 2 3 4  Nested LOOPs Loops can also be nested in each other. For example: Condition must be that statement which results a Boolean value i.e. either true or false For example BEGIN FOR i IN 1 .. 4 LOOP FOR j IN 1 .. i LOOP dbms_output.put(i||‘ ’); END LOOP; dbms_output.new_line; END LOOP; END; Will print: 1 2 2 3 3 3 4 4 4 4