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 | +------+ |
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.
Ask Questions? Discuss: Use DEFAULT Statement in Procedure
Post your Comment