Wednesday, May 14, 2025

Breaking News
>> Securing and encrypt View State and Cookies values  >> Page has one or more controls that do not correspond with   >> “The Controls collection cannot be modified because the control contains code blocks”  >> How to fix "Validation(): Element 'xxxx' is not supported  >> How to create a new session in ASP.NET programmatically  >> MySQL Database Backup using mysqldump command    

Editors Picks

Tuesday, March 13, 2012

My SQL Dynamic query execute and get ouput into a variable in stored procedure


DELIMITER $$

DROP PROCEDURE IF EXISTS `enterpriseaccessv2`.`prc_citysummary`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_citysummary`(in cityname varchar (200),in username varchar(200),in city_code varchar(200),
out c_onnet varchar(1000),
out c_section varchar(1000),
out c_rings varchar(1000),
)
BEGIN
                SET @section = '';
                SET @Ring = '';
                SELECT count(*) into c_onnet  FROM ovlcustomerinformation  WHERE CityCode = city_code and customer_type = 'onnet';
               
                 SET @s= CONCAT('select count(section_name) INTO  @section  from ',city_code,'_sectiondetails');
                 PREPARE stmt FROM @s;
                 EXECUTE stmt;

                SET @s1 = CONCAT('select count(distinct BOP_RingName) INTO  @Ring from  ',city_code,'_ringdetails');
                PREPARE stmt FROM @s1;
                EXECUTE stmt;

                DEALLOCATE PREPARE stmt;
                SET c_section = @section;
                SET c_rings = @Ring;
    END$$

DELIMITER ;

Call Procedure

call prc_citysummary('Bhopal','sunil','G004',@c_onnet,@c_section,@c_rings)
select @c_onnet,@c_section,@c_rings

No comments :

Post a Comment

Contact Us

Name

Email *

Message *