Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Sql Use DEFAULT Statement in Procedure

Related Tutorials


 
 

Share on Google+Share on Google+

Use DEFAULT Statement in Procedure

Advertisement
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

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 20, 2008

Related Tutorials

Discuss: Use DEFAULT Statement in Procedure  

Post your Comment


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