SlideShare a Scribd company logo
1 of 16
DISCOVER . LEARN . EMPOWER
Conditional Control Structure
APEX INSTITUTE OF TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
Database Management System (21CSH-243)
Faculty: Mr. Saurabh Singhal(E12800)
1
DBMS: Course Objectives
2
COURSE OBJECTIVES
The Course aims to:
• Understand database system concepts and design databases for different
applications and to acquire the knowledge on DBMS and RDBMS.
• Implement and understand different types of DDL, DML and DCL statements.
• Understand transaction concepts related to databases and recovery/backup
techniques required for the proper storage of data.
COURSE OUTCOMES
3
On completion of this course, the students shall be able to:-
CO3
Apply relational algebra and relational calculus to query the database of
organization
Lecture Outline
• Control Structures of PL/SQL
• Loops
• Nested Loops
• For
• While
4
Structure of PL/SQL
5
Structure of PL/SQL
6
Example for Structure of PL/SQL
7
Example for Structure of PL/SQL
DECLARE
a number;
text1 varchar2(20);
text2 varchar2(20) := “HI”;
BEGIN
DBMS_OUTPUT.PUT_LINE(text2) ;
---------- ---------- ----------;
END;
8
DBMS_OUTPUT.PUT_LINE(text2)
• It prints Message and value of variable
• Package: Dbms_Output
• Procedure: Put_Line()
9
PL/SQL Control Structure
PL/SQL has a number of control structures which includes:
• Conditional controls
• Iterative or loop controls.
It is these controls, used singly or together, that allow the PL/SQL
developer to direct the flow of execution through the program.
10
PL/SQL Control Structure: Conditional Controls
• Conditional Controls
IF....THEN....END IF;
IF....THEN...ELSE....END IF;
IF....THEN...ELSIF....THEN....ELSE....END IF;
11
IF THEN ELSE STATEMENT:
12
1)
IF condition THEN
Statement 1;
ELSE
Statement 2;
END IF;
2)
IF condition 1 THEN
Statement 1;
Statement 2;
ELSIF condtion2 THEN
Statement 3;
ELSE
Statement 4;
END IF
Write PL/SQL code for finding Even Numbers.
BEGIN
FOR I IN 1..100 LOOP
IF MOD(I,2)=0 THEN
DBMS_OUTPUT.PUT_LINE(I);
END IF;
END LOOP;
END;
/
13
//Write PL/SQL code to find Largest of three numbers.
DECLARE
A NUMBER;
B NUMBER;
C NUMBER;
BEGIN
A:=&A;
B:=&B;
C:=&C;
IF A=B AND B=C AND C=A THEN
DBMS_OUTPUT.PUT_LINE('ALL ARE EQUAL');
ELSE IF A>B AND A>C THEN
DBMS_OUTPUT.PUT_LINE('A IS GREATER');
ELSE IF B>C THEN
DBMS_OUTPUT.PUT_LINE('B IS GREATER');
ELSE
DBMS_OUTPUT.PUT_LINE('C IS GREATER');
END IF;
END IF;
END IF;
END;/ 14
References
• RamezElmasri and Shamkant B. Navathe, “Fundamentals of Database
System”, The Benjamin / Cummings Publishing Co.
• Korth and Silberschatz Abraham, “Database System Concepts”,
McGraw Hall.
• C.J.Date, “An Introduction to Database Systems”, Addison Wesley.
• Thomas M. Connolly, Carolyn & E. Begg, “Database Systems: A Practical
Approach to Design, Implementation and Management”, 5/E,
University of Paisley, Addison-Wesley.
15
THANK YOU
For queries
Email: saurabh.e12800@cumail.in
16

More Related Content

Similar to Lecture 2.3.26_Conditional Control Structure.pptx

Similar to Lecture 2.3.26_Conditional Control Structure.pptx (20)

Pl sql
Pl sqlPl sql
Pl sql
 
B.Sc. II (IV Sem) RDBMS & PL/SQL Unit-5 PL/SQL, Cursor and Trigger
B.Sc. II (IV Sem) RDBMS & PL/SQL Unit-5 PL/SQL, Cursor and TriggerB.Sc. II (IV Sem) RDBMS & PL/SQL Unit-5 PL/SQL, Cursor and Trigger
B.Sc. II (IV Sem) RDBMS & PL/SQL Unit-5 PL/SQL, Cursor and Trigger
 
PPT Lecture 2.3.4 Cursortttttttttttttttttttttttttttttttts.pptx
PPT Lecture 2.3.4 Cursortttttttttttttttttttttttttttttttts.pptxPPT Lecture 2.3.4 Cursortttttttttttttttttttttttttttttttts.pptx
PPT Lecture 2.3.4 Cursortttttttttttttttttttttttttttttttts.pptx
 
Pl sql-ch1
Pl sql-ch1Pl sql-ch1
Pl sql-ch1
 
Procedures andcursors
Procedures andcursorsProcedures andcursors
Procedures andcursors
 
pl_sql.ppt
pl_sql.pptpl_sql.ppt
pl_sql.ppt
 
MODULE 5.pptx
MODULE 5.pptxMODULE 5.pptx
MODULE 5.pptx
 
PL/SQL Fundamentals I
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals I
 
01 oracle architecture
01 oracle architecture01 oracle architecture
01 oracle architecture
 
plsql les06
 plsql les06 plsql les06
plsql les06
 
Oracle notes
Oracle notesOracle notes
Oracle notes
 
Performance tuning
Performance tuningPerformance tuning
Performance tuning
 
Fdms 1st cycle exp.pdf
Fdms 1st cycle exp.pdfFdms 1st cycle exp.pdf
Fdms 1st cycle exp.pdf
 
3963066 pl-sql-notes-only
3963066 pl-sql-notes-only3963066 pl-sql-notes-only
3963066 pl-sql-notes-only
 
PLSQL Tutorial
PLSQL TutorialPLSQL Tutorial
PLSQL Tutorial
 
PLSQL (1).ppt
PLSQL (1).pptPLSQL (1).ppt
PLSQL (1).ppt
 
SQL – The Natural Language for Analysis - Oracle - Whitepaper - 2431343
SQL – The Natural Language for Analysis - Oracle - Whitepaper - 2431343SQL – The Natural Language for Analysis - Oracle - Whitepaper - 2431343
SQL – The Natural Language for Analysis - Oracle - Whitepaper - 2431343
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, procedures
 
Ordina SOFTC Presentation - SQL CLR
Ordina SOFTC Presentation - SQL CLROrdina SOFTC Presentation - SQL CLR
Ordina SOFTC Presentation - SQL CLR
 
PL/SQL CURSORES
PL/SQL CURSORESPL/SQL CURSORES
PL/SQL CURSORES
 

Recently uploaded

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 

Recently uploaded (20)

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 

Lecture 2.3.26_Conditional Control Structure.pptx

  • 1. DISCOVER . LEARN . EMPOWER Conditional Control Structure APEX INSTITUTE OF TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Database Management System (21CSH-243) Faculty: Mr. Saurabh Singhal(E12800) 1
  • 2. DBMS: Course Objectives 2 COURSE OBJECTIVES The Course aims to: • Understand database system concepts and design databases for different applications and to acquire the knowledge on DBMS and RDBMS. • Implement and understand different types of DDL, DML and DCL statements. • Understand transaction concepts related to databases and recovery/backup techniques required for the proper storage of data.
  • 3. COURSE OUTCOMES 3 On completion of this course, the students shall be able to:- CO3 Apply relational algebra and relational calculus to query the database of organization
  • 4. Lecture Outline • Control Structures of PL/SQL • Loops • Nested Loops • For • While 4
  • 7. Example for Structure of PL/SQL 7
  • 8. Example for Structure of PL/SQL DECLARE a number; text1 varchar2(20); text2 varchar2(20) := “HI”; BEGIN DBMS_OUTPUT.PUT_LINE(text2) ; ---------- ---------- ----------; END; 8
  • 9. DBMS_OUTPUT.PUT_LINE(text2) • It prints Message and value of variable • Package: Dbms_Output • Procedure: Put_Line() 9
  • 10. PL/SQL Control Structure PL/SQL has a number of control structures which includes: • Conditional controls • Iterative or loop controls. It is these controls, used singly or together, that allow the PL/SQL developer to direct the flow of execution through the program. 10
  • 11. PL/SQL Control Structure: Conditional Controls • Conditional Controls IF....THEN....END IF; IF....THEN...ELSE....END IF; IF....THEN...ELSIF....THEN....ELSE....END IF; 11
  • 12. IF THEN ELSE STATEMENT: 12 1) IF condition THEN Statement 1; ELSE Statement 2; END IF; 2) IF condition 1 THEN Statement 1; Statement 2; ELSIF condtion2 THEN Statement 3; ELSE Statement 4; END IF
  • 13. Write PL/SQL code for finding Even Numbers. BEGIN FOR I IN 1..100 LOOP IF MOD(I,2)=0 THEN DBMS_OUTPUT.PUT_LINE(I); END IF; END LOOP; END; / 13
  • 14. //Write PL/SQL code to find Largest of three numbers. DECLARE A NUMBER; B NUMBER; C NUMBER; BEGIN A:=&A; B:=&B; C:=&C; IF A=B AND B=C AND C=A THEN DBMS_OUTPUT.PUT_LINE('ALL ARE EQUAL'); ELSE IF A>B AND A>C THEN DBMS_OUTPUT.PUT_LINE('A IS GREATER'); ELSE IF B>C THEN DBMS_OUTPUT.PUT_LINE('B IS GREATER'); ELSE DBMS_OUTPUT.PUT_LINE('C IS GREATER'); END IF; END IF; END IF; END;/ 14
  • 15. References • RamezElmasri and Shamkant B. Navathe, “Fundamentals of Database System”, The Benjamin / Cummings Publishing Co. • Korth and Silberschatz Abraham, “Database System Concepts”, McGraw Hall. • C.J.Date, “An Introduction to Database Systems”, Addison Wesley. • Thomas M. Connolly, Carolyn & E. Begg, “Database Systems: A Practical Approach to Design, Implementation and Management”, 5/E, University of Paisley, Addison-Wesley. 15
  • 16. THANK YOU For queries Email: saurabh.e12800@cumail.in 16