Use DEFAULT Statement in Procedure

The Tutorial illustrate an example 'Use DEFAULT Statement in Procedure'. To understand 'Default Statement in Procedure', we create a procedure 'abc'.

Use DEFAULT Statement in Procedure

     

The Tutorial illustrate an example 'Use DEFAULT Statement in Procedure'. To understand 'Default Statement in Procedure', we create a procedure 'abc'. The BEGIN statement  indicate the beginning of an SQL declare section. The Declare is used to define a variable 'x', 'y' and 'z ', whose data type is integer type. The variable x and y set to a default value of '15'.The  variable 'z' assigned the sum  value of variable 'x' and 'y'. An SQL declare variable end with an END statement.

select z  : The select z returns you the sum value of variable 'x' and 'y' into 'z'.

Create Procedure

 

 

delimiter $$
create procedure abc()
BEGIN 
	DECLARE x int DEFAULT 15;
	DECLARE y int DEFAULT 15;
	DECLARE z int;
	set z = x+y;
	select z;
END$$
delimiter ;

 

Call Procedure

To invoke a procedure 'abc', we use call abc ( ) given below:

call abc();

Result

+------+
| z    |
+------+
| 30   |
+------+

Advertisements

Share on Google+Share on Google+

Use DEFAULT Statement in Procedure

Posted on: December 20, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Use DEFAULT Statement in Procedure  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads