mysql - Error in procedure with cursor -
sorry pasting such ugly code.but couldnt it.here procedure uses cursor.
delimiter ## create procedure myproced() begin declare arpt varchar(10); declare cur cursor select distinct name lookup.airport; open cur; read_loop: loop fetch cur arpt; select distinct c.star_ident, c.fix_ident corept.std_star_leg c inner join (select star_ident, transition_ident, max(sequence_num) seq, route_type corept.std_star_leg data_supplier = 'j' , airport_ident = apt group star_ident, transition_ident )b on c.sequence_num=b.seq , c.star_ident=b.star_ident , c.transition_ident=b.transition_ident c.data_supplier='j' , c.airport_ident=arpt , not exists (select name, trans skyplan_deploy.deploy_stars d d.apt = arpt , d.name != d.trans , c.star_ident = d.name , c.fix_ident = d.trans) union select name, trans skyplan_deploy.deploy_stars d apt = arpt , name != trans , not exists (select distinct c.star_ident, c.fix_ident corept.std_star_leg c inner join (select star_ident, transition_ident, max(sequence_num) seq, route_type corept.std_star_leg data_supplier = 'j' , airport_ident = arpt group star_ident, transition_ident) b on c.sequence_num = b.seq , c.star_ident = b.star_ident , c.transition_ident = b.transition_ident c.data_supplier = 'j' , c.airport_ident = arpt , d.name = c.star_ident , d.trans = c.fix_ident); if done leave read_loop; end if; end loop; close cur1; end ##
actually said cursors in real time environment not encouraged.while executing above procedure iam getting no database selected error.and can please provide efficient way loop around result set other cursors in mysql.the cursor in above query contain around 30000 entries.
thank you.
if selecting database giving error 1064
you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'end ##' @ line 1
Comments
Post a Comment