ubuntu 12.04 - MySql- Stored Procedure with cursor issue -


i have created following stored procedure mysql throws error 1064. need every user exists in table logbackup, find date of first action, date of last action , calculate duration. though, know in different way, syntax errors may have since new in mysql.

 edit:               use 'databasename'             drop procedure if exists `userengagementcalc`;             delimiter $$             use `databasename`$$             create definer=`root`@`%localhost` procedure `userengagementcalc`()             create procedure userengagementcalc()             begin              declare v_username varchar(50);             declare startdate datetime;             declare enddate datetime;             declare duration int;             declare done int default false;              declare cur1 cursor                      select distinct username                     logbackup;             declare continue handler not found set done=true;                   open cur1;                  igmloop: loop                     fetch cur1 v_username;                     if done leave igmloop; end if;                      set @startdate:=(select str_to_date(created_date, '%a %b %d %y %h:%i:%s') logbackup username=v_username order str_to_date(created_date, '%a %b %d %y %h:%i:%s') asc limit 1);                     set @enddate:=(select str_to_date(created_date, '%a %b %d %y %h:%i:%s') logbackup username=v_username order str_to_date(created_date, '%a %b %d %y %h:%i:%s') desc limit 1);                     set @duration:= time_to_sec(timediff(@startdate,@enddate));                      insert  userengagement (username,startdate,enddate,duration) values (v_username,@startdate,@enddate,@duration);                 end loop igmloop;                     close cur1;             end$$             delimiter; 

i trying execute scipt on ubuntu mysql terminal. need special manipulation>? receive mysql except error messages following:

display 813 possibilities? (y or n) ?                            day_minute                   innodb                            multilinestringfromwkb       session_user                 variance abs                          day_second                   inout                        multipoint                   set                          varying acos                         deallocate                   insensitive                  multipointfromtext           sha                          var_pop action                       dec 

i appreciate kind help.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -