Home Sql Use DEFAULT Statement in Procedure



Use DEFAULT Statement in Procedure
Posted on: December 20, 2008 at 12:00 AM
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   |
+------+

Related Tags for Use DEFAULT Statement in Procedure:
cdefaulttutorialstateriacreateexamplestatementtoexamproceilprocedureuseulcefaultinstamnttremabcmeproratetorxaxampsatllmpleaduandstatstrtutorssrocrithbcstabefaultpleplprndo


More Tutorials from this section

Ask Questions?    Discuss: Use DEFAULT Statement in Procedure  

Post your Comment


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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.