My tables are
create table employee(
id int(10) auto_increment primary key,
name varchar(100),
addressId int(10)
);
go
create table address(
id varchar(10) auto_increment primary key,
name varchar(100)
);
Here is my procedure
create procedure insert_employee(IN emp_name varchar(100),IN emp_address varchar(100))
begin
DECLARE @addressId varchar(10);
SELECT @addressId:=id from address where name LIKE '%'+emp_address+'%';
IF @addressId = ''
THEN
set @addressId= 'DBS-2136';-- It will come form function
INSERT INTO address values(@addressId,emp_address);
END IF
INSERT INTO employee values(emp_name,@addressId);
END
I don't understand what is the problem. If i write this type of if condition in ms sql server there is not error. every time execute the procedure ti say error in end if. I have search in google but there is not idea about this. there is a problem in declare variable. If i copy form mysql documentation that also not work. why is that? please help me 1. What is the proper way to declare variable under mysql stored procedure, 2. how to write if condition in mysql stored procedure. thank you