Home Sql Use DECLARE Statement in Procedure



Use DECLARE Statement in Procedure
Posted on: December 20, 2008 at 12:00 AM
Use DECLARE Statement in Procedure is used to define variable and its data type.

Use DECLARE Statement in Procedure

     

Use DECLARE Statement in Procedure is used to define variable and its data type.

Understand with Example

The Tutorial illustrate an example from 'Use Declare Statement in Procedure'. To grasp this Example, we create a procedure 'abc'. The Query start with the BEGIN Section that include DECLARE statement which define a variable x ,y and z and data type is integer kind. The SET variable set the value of ' x' to 10 and 'y' to 20.The set z set the compute value of variable x and y respectively.

  select z :The select z return you the sum value of x and y variable in z.

 

Create Procedure

delimiter $$
create procedure abc()
BEGIN 
	DECLARE x int;
	DECLARE y int;
	DECLARE z int;
	SET x = 10;
	SET y = 20;
	set z = x+y;
	select z;
END$$
delimiter ;

Call Procedure

To invoke a procedure, we use call abc ( ).The below syntax show you to call procedure :

call abc()

Result

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

Related Tags for Use DECLARE Statement in Procedure:
cdatavariablesedtypestateriadefinestatementtoproceitprocedurevarusepeceinstamntcldeclareemmeprosatisduandarstatvassrocristabableclfinprndo


More Tutorials from this section

Ask Questions?    Discuss: Use DECLARE 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.