Loop with label : LOOP « Procedure Function « SQL / MySQL

Home
SQL / MySQL
1.Aggregate Functions
2.Backup Load
3.Command MySQL
4.Cursor
5.Data Type
6.Database
7.Date Time
8.Engine
9.Event
10.Flow Control
11.FullText Search
12.Function
13.Geometric
14.I18N
15.Insert Delete Update
16.Join
17.Key
18.Math
19.Procedure Function
20.Regular Expression
21.Select Clause
22.String
23.Table Index
24.Transaction
25.Trigger
26.User Permission
27.View
28.Where Clause
29.XML
PostgreSQL
MySQL Tutorial
SQL / MySQL » Procedure Function » LOOP 
Loop with label
     

CREATE   TABLE PENALTIES
        (PAYMENTNO      INTEGER      NOT NULL,
         EmployeeNO       INTEGER      NOT NULL,
         PAYMENT_DATE   DATE         NOT NULL,
         AMOUNT         DECIMAL(7,2NOT NULL,
         PRIMARY KEY    (PAYMENTNO)          );
         
INSERT INTO PENALTIES VALUES (1,  6'1980-12-08',100);
INSERT INTO PENALTIES VALUES (244'1981-05-05', 75);
INSERT INTO PENALTIES VALUES (327'1983-09-10',100);
INSERT INTO PENALTIES VALUES (4,104'1984-12-08', 50);
INSERT INTO PENALTIES VALUES (544'1980-12-08', 25);
INSERT INTO PENALTIES VALUES (6,  8'1980-12-08', 25);
INSERT INTO PENALTIES VALUES (744'1982-12-30', 30);
INSERT INTO PENALTIES VALUES (827'1984-11-12', 75);

DELIMITER $$

CREATE PROCEDURE WAIT(IN WAIT_SECONDS INTEGER)
BEGIN
   DECLARE END_TIME INTEGER
      DEFAULT NOW() + INTERVAL WAIT_SECONDS SECOND;
   WAIT_LOOP: LOOP
      IF NOW() > END_TIME THEN
         LEAVE WAIT_LOOP;
      END IF;
   END LOOP WAIT_LOOP;
END$$

DELIMITER ;

CALL WAIT ((SELECT COUNT(*FROM PENALTIES));

drop table penalties;

   
    
    
    
    
  
Related examples in the same category
1.Simple LOOP
2.Nesting if statement with LOOP statement
3.LOOP with LEAVE
4.LOOP with ITERATE
5.LOOP Statement with LEAVE
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.