mysql - My sql query some mistake in stored procedure -
delimiter $$ drop procedure if exists `dinv`.`sp_insertcustomer`$$ create definer=`root`@`localhost` procedure `sp_insertcustomer`( in vcustid varchar(120), in vname varchar(16), in vmobilenumber varchar(120), in vemail varchar(500), in vcountry varchar(120), in vcity varchar(80), in vzipcode date, in vaddress varchar(80), in vremarks date, in vcreatedby varchar(80), in vparam varchar(50) ) begin set @type = vparam; if @type="save" insert customer(custid,name,mobilenumber,emailid,country,city,zipcode,address,remarks,createdby,createddate) values(vcustid,vname,vmobilenumber,vemail,vcountry,vcity,vzipcode,vaddress,vremarks,vcreatedby,getdate()); else update customer set name=vname,mobilenumber=vmobilenumber,emailid=vemail,country=vcountry,city=vcity,zipcode=vzipcode,address=vaddress, remarks=vremarks,modifiedby=vcreatedby,modifieddate=getdate() custid=vcustid; end if; delimiter ;
error code : 1064 have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 23
hi i'm new mysql , trying write procedure if else condition getting error plz help.. thanks
you don't have end
statement terminate begin
block.
basically have structure
delimiter $$ -- drop statement create procedure sp_insertcustomer(..parameter list..) begin set @type = vparam; if @type = "save" -- mysql accepts double quotes , single quotes -- insert statement else -- update statememt end if; end $$ -- <<== lacking part delimiter ;