I’m working on a project and I need to pass some values to the table with stored procedure in MySQL. So I made my procedure like this.
create procedure KullanıcıKayıt(
IN kullaniciAd nvarchar(50),
IN kullaniciSoyad nvarchar(50),
IN kullaniciSifre int(10),
IN kullaniciMail nvarchar(50),
IN kullaniciTelNo int(10),
IN kullaniciAdres nvarchar(100),
IN kullaniciSehirAd nvarchar(50),
IN kullaniciSehirIlceAd nvarchar(50)
)
and these are the rest of my procedure
BEGIN
DECLARE sehirId INT DEFAULT 0;
DECLARE ilceId INT DEFAULT 0;
Select @sehirId=sehirId from sehir
where kullaniciSehirAd=sehirAd;
Select @ilceId=sehirIlceId from sehirIlce
where kullaniciSehirIlceAd=sehirIlceAd;
Insert Into kullanici(kullaniciAd, kullaniciSoyad, kullaniciSifre, kullaniciMail,
kullaniciTelNo, kullaniciAdres, kullaniciSehir, kullaniciSehirIlce) values (kullaniciAd,
kullaniciSoyad, kullaniciSifre, kullaniciMail, kullaniciTelNo, kullaniciAdres,
kullaniciSehir, kullaniciSehirIlce)
END
then I got three syntax errors. One of them is on the “0” after the sehirId
2nd of them on the DECLARE vefore ilceId
and the last one on the END.
What’s wrong with my syntax?
Thanks.
You are missing a delimiter after
END, add ; there as well as after your insert statement:If you are executing it in a client of some sort, you might need to add DELIMITER statements above and below your create proc statement: