MySQL stored procedure syntax -


i trying create basic stored procedure in mysql. has increment int value in table. want stored procedure dropped if exists. sql inside stored procedure works fine on own btw.

i error:

you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'end' @ line 5

i have tried:

delimiter $$ drop procedure if exists sp_version_increment$$ create procedure `sp_version_increment`() begin     set @ver = (select version version limit 1) + 1;     update version set version = @ver end$$ delimiter   delimiter $$ drop procedure if exists sp_version_increment$$ create procedure `sp_version_increment`() begin     set @ver = (select version version limit 1) + 1;     update version set version = @ver end 

solution:

delimiter $$ drop procedure if exists sp_version_increment$$ create procedure `sp_version_increment`() begin     set @num = (select number version limit 1) + 1;     update version set number = @num; end 

try

drop procedure if exists sp_version_increment; delimiter $$ create procedure `sp_version_increment`() begin     set @ver = (select version version limit 1) + 1;     update version set version = @ver; end $$ delimiter ;  drop procedure if exists sp_version_increment; delimiter $$ create procedure `sp_version_increment`() begin     set @ver = (select version version limit 1) + 1;     update version set version = @ver; end $$ delimiter ; 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -