Search
 
SCRIPT & CODE EXAMPLE
 

SQL

pl/sql loop example

DECLARE
  l_counter NUMBER := 0;
BEGIN
  LOOP
    l_counter := l_counter + 1;
    IF l_counter > 3 THEN
      EXIT;
    END IF;
    dbms_output.put_line( 'Inside loop: ' || l_counter )  ;
  END LOOP;
  -- control resumes here after EXIT
  dbms_output.put_line( 'After loop: ' || l_counter );
END;Code language: SQL (Structured Query Language) (sql)
Comment

loop example PL/SQL

DECLARE
   n NUMBER;
   average NUMBER :=0 ;
   sum NUMBER :=0 ;
   count NUMBER :=0 ;
BEGIN
   -- Take input from user
   n := &input_number;
   WHILE(n<>0)
       LOOP
           -- Increment count to find total elements
           count := count+1;
           -- Sum of elements entered
           sum := sum+n;
           -- Take input from user
           n := &input_number;
       END LOOP;
   -- Average calculation
   average := sum/count;
   DBMS_OUTPUT.PUT_LINE(‘Average of entered numbers is ’||average);
END;
Comment

PREVIOUS NEXT
Code Example
Sql :: SHOW COLUMNS Statement 
Sql :: query less than datetime sql 
Sql :: create user sql server 
Sql :: oracle drop temporary table 
Sql :: get all tables using like 
Sql :: oracle insert or update 
Sql :: backup a table in sql 
Sql :: Query the list of CITY names from STATION that either do not start with vowels or do not end with vowels. Your result cannot contain duplicates. 
Sql :: sql common columns 
Sql :: postgresql find duplicates 
Sql :: oracle create table auto generated primary key 
Sql :: declare variables sql 
Sql :: How do I modify a MySQL column to allow NULL? 
Sql :: oracle nextval insert 
Sql :: how to drop a table in mysql 
Sql :: recently updated stored procedure in sql server 
Sql :: sql only five first row 
Sql :: show the colums of table sql 
Sql :: mysql datetime to date 
Sql :: sql server select first day of previous year 
Sql :: import all databases mysql 
Sql :: mysql milliseconds 
Sql :: oracle tablespace tables list 
Sql :: oracle list grants on procedure 
Sql :: sql server case sensitive search 
Sql :: psql select database 
Sql :: run postgresql dump to csv 
Sql :: mysql version 
Sql :: sql count unique values in one column 
Sql :: how to set up a trigger in sql 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =