Database Programming Using Oracle 11g

Slides:



Advertisements
Similar presentations
While loops.
Advertisements

Looping Structures: Do Loops
How SAS implements structured programming constructs
Do-while Loops Programming. COMP102 Prog Fundamentals I: do-while Loops /Slide 2 The do-while Statement l Syntax do action while (condition) l How it.
Two-Dimensional Arrays Chapter What is a two-dimensional array? A two-dimensional array has “rows” and “columns,” and can be thought of as a series.
Executes a statement or statements for a number of times – iteration. Syntax for(initialize; test; increment) { // statements to be executed } Initial.
Branching Constructs Review l what are branching constructs? what type of branching constructs have we studied? l what is nested if? l what is multiway.
Do Loop The syntax of DO loop: DO variable = initial_value, final_value[, increment] [statements] END DO Example: PROGRAM LINES ! Illustration of DO-loops.
Iteration This week we will learn how to use iteration in C++ Iteration is the repetition of a statement or block of statements in a program. C++ has three.
Chapter 8 (Control Structure) Slide 1 Control Structures Control structures are used by the programmer to incorporate the desired sequence of execution.
1 MATERI PENDUKUNG JUMP Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 6: Loop Control Structures.
CHAPTER 2 ANALYSIS OF ALGORITHMS Part 2. 2 Running time of Basic operations Basic operations do not depend on the size of input, their running time is.
Computer Programming 1 Repetition. Computer Programming 2 Objectives Repetition structures Study while and do loops Examine for loops A practical example.
Iteration Conditional Loops Counted Loops. Charting the Flow of Control We’ve used flow charts to visualise the flow of control. The simplest form is.
Nested Loops. Nesting Control Structures One if statement inside another one An if statement inside a loop A loop inside an if statement Control structures.
There are two additional statements that can be used to control the operation of while loops and for loops: break statements continue statements.
Introduction to PL/SQL. Procedural Language extension for SQL Oracle Proprietary 3GL Capabilities Integration of SQL Portable within Oracle data bases.
Do … while ( continue_cond ) Syntax: do { stuff you want to happen in the loop } while (continue_condition);
DiagrammaticRepresentation Iteration Construct False True Condition Exit from Statement (s) loop Sequence construct Selection construct Statement 1 Statement.
Chapter 6 - VB 2005 by Schneider1 Chapter 6 – Repetition 6.1 Do While and Do Until Loops 6.2 Processing Lists of Data with Do Loops 6.3 For...Next Loops.
CPS120 Introduction to Computer Science Iteration (Looping)
PL/SQL Loops. Building Logical Conditions All logical conditions must yield a boolean condition. You can build a simple Boolean condition by combining.
Lecture 14: Control Flow. The break, continue, goto statements.
Chapter 8 Iteration Dept of Computer Engineering Khon Kaen University.
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
PL/SQL. Introduction to PL/SQL block Declare declarations Begin executable statement Exception exception handlers End;
Bordoloi and Bock Control Structures: Iterative Control.
Looping Construct or Statements. Introduction of looping constructs In looping,a sequence of statements are executed until some condition for termination.
CPS120 Introduction to Computer Science Iteration (Looping)
Structured Programming The Basics. Control structures They control the order of execution What order statements will be done in, or whether they will.
Control Flow Statements
CSI 3125, Preliminaries, page 1 Control Statements.
COMP Loop Statements Yi Hong May 21, 2015.
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
Loops causes program to execute the certain block of code repeatedly until some conditions are satisfied. Suppose you want to execute some code/s 10 times.
Fundamentals of PL/SQL part 2 (Basics)
Chapter 6: Loops.
Chapter 4 Repetition Statements (loops)
Program with PL/SQL Lesson 4.
Warm-up Program Use the same method as your first fortune cookie project and write a program that reads in a string from the user and, at random, will.
Lecture 4 - Loops UniMAP EKT120 Sem 1 08/09.
Branching Constructs Review
CiS 260: App Dev I Chapter 4: Control Structures II.
The nested repetition control structures & Continue Statements
Control Structures.
Database Management Systems 2
Chapter 5 Structures.
The Linux Command Line Chapter 29
جمل التحكم المحاضرة التاسعة T.Eman Alsqour.
جمل التحكم.
Conditinoal Constructs Review
FLOW OF CONTROL.
For & do/while Loops.
Conditinoal Constructs Review
Iteration: Beyond the Basic PERFORM
for, do-while and switch statments
CSC215 Lecture Flow Control.
CSC215 Lecture Control Flow.
Lab5 PROGRAMMING 1 Loop chapter4.
JavaScript: Control Statements II
PROGRAM FLOWCHART Iteration Statements.
More Loops Topics Counter-Controlled (Definite) Repetition
More Loops Topics Counter-Controlled (Definite) Repetition
Conditional Loops Counted Loops
Department of Computer Science
CSC215 Lecture Control Flow.
Database Programming Using Oracle 11g
Database Programming Using Oracle 11g
Database Programming Using Oracle 11g
Presentation transcript:

Database Programming Using Oracle 11g Iterative Control-II

Iterative Control-II Iterative Control-II: Continue Statement Conditionally Exit from current iteration of loop Statements after continue are skipped Control is transfer to next iteration Must be inside loop

Iterative Control-II Implementing Continue Statement with Basic Loop

Iterative Control-II DECLARE x NUMBER := 0; BEGIN LOOP DBMS_OUTPUT.PUT_LINE ('Inside loop: x = ' || TO_CHAR(x)); x := x + 1; IF x < 3 THEN CONTINUE; END IF;

Iterative Control-II DBMS_OUTPUT.PUT_LINE ('Inside loop, after CONTINUE: x = ' || TO_CHAR(x)); EXIT WHEN x = 5; END LOOP; DBMS_OUTPUT.PUT_LINE (' After loop: x = ' || TO_CHAR(x)); END;

Iterative Control-II Continue When Statement Unconditionally Exit from current iteration of loop Statements after continue are skipped Control is transfer to next iteration Must be inside loop

Iterative Control-II Implementing Continue WHEN with Loop

Iterative Control-II DECLARE x NUMBER := 0; BEGIN LOOP DBMS_OUTPUT.PUT_LINE ('Inside loop: x = ' || TO_CHAR(x)); x := x + 1; CONTINUE WHEN x < 3;

Iterative Control-II DBMS_OUTPUT.PUT_LINE ('Inside loop, after CONTINUE: x = ' || TO_CHAR(x)); EXIT WHEN x = 5; END LOOP; DBMS_OUTPUT.PUT_LINE (' After loop: x = ' || TO_CHAR(x)); END;

Iterative Control-II Implementing Continue WHEN with For Loop

Iterative Control-II declare val number(3):=3; BEGIN FOR i IN 1 .. 10 LOOP dbms_output.put_line('i=' || TO_CHAR(i)); CONTINUE WHEN (i+1) = val; dbms_output.put_line('Did not jump to the top of the loop'); END LOOP; END;

Iterative Control-II Nested Loops Loop within loop Any type of loop can be nested within any other or same type of loop Again one iteration of main loop complete inner loop is executed

Iterative Control-II Syntax for Nested Loops

Iterative Control-II LOOP – Main Loop Sequence of statements1 LOOP – Nested or inner loop Sequence of statements2 END LOOP; END

Iterative Control-II Implementing Nested Loops-I

Iterative Control-II BEGIN FOR v_outerloopcounter IN 1..2 LOOP FOR v_innerloopcounter IN 1..4 DBMS_OUTPUT.PUT_LINE('Outer Loop counter is ' || v_outerloopcounter || ' Inner Loop counter is ' || v_innerloopcounter); END LOOP; END LOOP; END;

Iterative Control-II Implementing Nested Loops-II

Iterative Control-II DECLARE v_counter1 INTEGER:=0; BEGIN WHILE v_counter1 < 3 LOOP DBMS_OUTPUT.PUT_LINE('v_counter1 : ' || v_counter1); LOOP DBMS_OUTPUT.PUT_LINE('v_counter2: ' || v_counter2);

Iterative Control-II v_counter2 := v_counter2 + 1; EXIT WHEN v_counter2 >= 2; END LOOP; v_counter1 := v_counter1+1; END;