Databases| SQL| MySQL| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Until Loop In a Procedure 
 

Until Loop In a Procedure is used to execute a set of statements repeatedly until a certain condition is reached.

 

Until Loop In a Procedure

                         

Until Loop In a Procedure is used to execute a set of statements repeatedly until a certain condition is reached.

Understand with Example

Many Beginners trapped with the problem of  execution of loop in a procedure. This Tutorial provides you an example to understand 'Until Loop In a Procedure'. To grasp this example, we create a procedure 'proce' that accept variable 'a' as input parameter. The data type specified for variable is integer type.

The set @ a is initialized to 0 initial.

The repeat loop does not evaluate the condition at the beginning ,unlike while loop. If the evaluate condition in the beginning of loop is false, the loop will be executed, until the final line of code in loop. 

 

Create Procedure

delimiter $$
create procedure proce(a int)
begin
	set @a = 0;
	repeat set @a = @a + 1; 
		select @a;
	
	until @a>a
	end repeat;
END$$
delimiter ;

Call Procedure

To call a procedure proce, we use a Call proce that execute the loop five times and return you the value into @. 

Call proce(5);

Result

+------+
| @a   |
+------+
| 1    |
+------+
1 row in set (0.00 sec)
+------+
| @a   |
+------+
| 2    |
+------+
1 row in set (0.03 sec)
+------+
| @a   |
+------+
| 3    |
+------+
1 row in set (0.08 sec)
+------+
| @a   |
+------+
| 4    |
+------+
1 row in set (0.11 sec)
+------+
| @a   |
+------+
| 5    |
+------+
1 row in set (0.11 sec)
+------+
| @a   |
+------+
| 6    |
+------+
1 row in set (0.11 sec)

                         

» View all related tutorials
Related Tags: sql mysql c string oop com function fun io sed char padding length oo character case cas if ie unc

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.