Home Quartz Use DECLARE Statement in Procedure

Related Tutorials


 
 

Share on Google+Share on Google+

Use DECLARE Statement in Procedure

Advertisement
This page discusses - Use DECLARE Statement in Procedure

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   |
+------+
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: April 18, 2011

Related Tutorials

Discuss: Use DECLARE Statement in Procedure  

Post your Comment


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