MYSQL Procure for Executing Multiple queries in single shot

Mysql Procedure produces more than one result sets - This is the sample for those who are searching for the "sample procedure in mysql" , which can be executed to get more than one result set. this can be linked to a data sources in or

In this code snip bit, i tried to explain how we can create the procedure in mysql that can be linked to the datasources of dropdownlist, listbox, gridview etc.,

In many of the samples provided, we dont find the sample for using mysql procedure along with .net, since we people continuosly make use of .net with sql server alone,



CREATE PROCEDURE `tQueries`(Inqry varchar(50000))

declare qry varchar(50000) default 0;

while instr(Inqry,';') > 0 do
set @qry = substring(Inqry,1,instr(Inqry,';'));
prepare stmt from @qry;
execute stmt;
if instr(Inqry,';') < length(Inqry) then
set Inqry = substring(Inqry,instr(Inqry,';')+1);
elseif instr(Inqry,';') = length(Inqry) then
set Inqry = '';
end if;
end while;
end $$

The above given code is a procedure, which is used to dissemble the given queries into single query, here i have used semicolon as a separator for separating the queries, the above procedure can be called or executed as follows

call TQueries("select 100*1;select 100*2;select 100*3;");

which produces, three different result sets, we can also make use of insert statement, update or delete statement to be executed in single shot like

call TQueries("
drop table if exists emp;
create table emp(eno int, ename varchar(10));
insert into emp values(1,'Bala');
insert into emp values(2,'Priya');
insert into emp values(4,'Tamil');
select * from emp;
update emp set eno = 3 where eno=1;
select * from emp;
delete from emp where eno='4';
select * from emp; ");


Author: Priya K17 Jun 2011 Member Level: Silver   Points : 1

Any one find this helpful or Any one has any comments about this or Any one is using .net with MYSQL...?

Your valuable comments are welcome...

Author: Natesan30 Jul 2011 Member Level: Gold   Points : 0

as for as i know, there is very least possibility of using mysql with .net.

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: