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

Discrete Structures lecture 2
 Discrete Structures lecture 2 Discrete Structures lecture 2
Discrete Structures lecture 2Ali Usman
 
Finite State Machine.ppt.pptx
Finite State Machine.ppt.pptxFinite State Machine.ppt.pptx
Finite State Machine.ppt.pptxSKUP1
 
Exception handling in c++
Exception handling in c++Exception handling in c++
Exception handling in c++imran khan
 
Assembly Language Lecture 5
Assembly Language Lecture 5Assembly Language Lecture 5
Assembly Language Lecture 5Motaz Saad
 
Synchronous state machines. Moore and Mealy state machines (FSM)
Synchronous state machines.  Moore and Mealy state machines (FSM)Synchronous state machines.  Moore and Mealy state machines (FSM)
Synchronous state machines. Moore and Mealy state machines (FSM)Mumbi Chishimba
 
Selection Control Structures
Selection Control StructuresSelection Control Structures
Selection Control StructuresPRN USM
 
Universal logic gate
Universal logic gateUniversal logic gate
Universal logic gatesana younas
 
Dead Lock in operating system
Dead Lock in operating systemDead Lock in operating system
Dead Lock in operating systemAli Haider
 
Karnaugh map or K-map method
Karnaugh map or K-map methodKarnaugh map or K-map method
Karnaugh map or K-map methodAbdullah Moin
 
Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Abhimanyu Mishra
 

What's hot (20)

4. plsql
4. plsql4. plsql
4. plsql
 
Discrete Structures lecture 2
 Discrete Structures lecture 2 Discrete Structures lecture 2
Discrete Structures lecture 2
 
Finite State Machine.ppt.pptx
Finite State Machine.ppt.pptxFinite State Machine.ppt.pptx
Finite State Machine.ppt.pptx
 
Exception handling in c++
Exception handling in c++Exception handling in c++
Exception handling in c++
 
Semaphores
SemaphoresSemaphores
Semaphores
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
PLSQL Cursors
PLSQL CursorsPLSQL Cursors
PLSQL Cursors
 
Assembly Language Lecture 5
Assembly Language Lecture 5Assembly Language Lecture 5
Assembly Language Lecture 5
 
Synchronous state machines. Moore and Mealy state machines (FSM)
Synchronous state machines.  Moore and Mealy state machines (FSM)Synchronous state machines.  Moore and Mealy state machines (FSM)
Synchronous state machines. Moore and Mealy state machines (FSM)
 
Selection Control Structures
Selection Control StructuresSelection Control Structures
Selection Control Structures
 
Universal logic gate
Universal logic gateUniversal logic gate
Universal logic gate
 
Moore machine (automata)
Moore  machine (automata)Moore  machine (automata)
Moore machine (automata)
 
Dead Lock in operating system
Dead Lock in operating systemDead Lock in operating system
Dead Lock in operating system
 
Unit 4-booth algorithm
Unit 4-booth algorithmUnit 4-booth algorithm
Unit 4-booth algorithm
 
K map
K mapK map
K map
 
Karnaugh map or K-map method
Karnaugh map or K-map methodKarnaugh map or K-map method
Karnaugh map or K-map method
 
Autoboxing And Unboxing In Java
Autoboxing And Unboxing In JavaAutoboxing And Unboxing In Java
Autoboxing And Unboxing In Java
 
Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
 
C++ IF STATMENT AND ITS TYPE
C++ IF STATMENT AND ITS TYPEC++ IF STATMENT AND ITS TYPE
C++ IF STATMENT AND ITS TYPE
 

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
 

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 3
PL/SQL Part 3PL/SQL Part 3
PL/SQL Part 3
 
PL/SQL Part 2
PL/SQL Part 2PL/SQL Part 2
PL/SQL Part 2
 
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)
 

Recently uploaded

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 

Recently uploaded (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 

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