MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Rilawich Ango Date:February 11 2008 7:15am
Subject:Re: 2 cursors in a store procedure
View as plain text  
Thanks for your reply.  Actually, I want to do the following.  But I
have no idea how to do it.

create procedure a()
begin
   declare ...
   declare c1 cursor for select ...
   declare contine handler for not found set x=1;
   declare c2 cursor for select ...
   declare contine handler for not found set y=1;
  create temporary table ....
  insert into temporary table ....

open c1
  (c1 will join table a and temp table to get the result)
close c1

open c2
  (c2 will join table b and temp table to get the result)
close c2

end


On Feb 11, 2008 11:08 AM, Paul DuBois <paul@stripped> wrote:
>
> At 10:57 AM +0800 2/11/08, Rilawich Ango wrote:
> >HI all,
> >
> >   How can a store procedure to contain 2 cursors?  Any advise?
> >
> >ango
> >
> >create procedure a()
> >begin
> >   declare ...
> >   declare c1 cursor for select ...
> >   declare contine handler for not found set x=1;
> >   declare c2 cursor for select ...
> >   declare contine handler for not found set y=1;
> >....
>
> http://dev.mysql.com/doc/refman/5.0/en/cursors.html:
>
> "Cursors must be declared before declaring handlers. Variables and
> conditions must be declared before declaring either cursors or
> handlers."
>
> You have a handler declared before a cursor.
>
> --
> Paul DuBois, MySQL Documentation Team
> Madison, Wisconsin, USA
> MySQL AB, www.mysql.com
>
Thread
2 cursors in a store procedureRilawich Ango11 Feb
  • Re: 2 cursors in a store procedurePaul DuBois11 Feb
Re: 2 cursors in a store procedureRilawich Ango11 Feb