0

This little one gives me syntax problem, i cant solve that i'll appreciate that.

DELIMITER $$

CREATE procedure kullanicibilgicek
(
p_kadi varchar(50)
)
begin
declare v_sonuc INT;
if(CHAR_LENGTH(RTRIM(p_kadi)) > 4)
then
    if exists (select kullanicilar.kullaniciadi, kullanicilar.sifre from kullanicilar where kullaniciadi = p_kadi)
    then
    select id, upper(left(ad,1))+ right(ad, char_length(rtrim(ad)) -1), upper(left(soyad,1))+ right(soyad, char_length(rtrim(soyad)) -1), yetki, upper(left(kullaniciadi,1))+ right(kullaniciadi, char_length(rtrim(kullaniciadi)) -1), kullanicilar.sifre from kullanicilar where kullaniciadi = p_kadi;
    else
    set v_sonuc = 0;
    select v_sonuc;
    end if;

else
    if exists (select kullanicilar.kullaniciadi, kullanicilar.sifre from kullanicilar where id = Cast(p_kadi as int))
    then
    select id, upper(left(ad,1))+ right(ad, char_length(rtrim(ad)) -1), upper(left(soyad,1))+ right(soyad, char_length(rtrim(soyad)) -1), yetki, upper(left(kullaniciadi,1))+ right(kullaniciadi, char_length(rtrim(kullaniciadi)) -1), kullanicilar.sifre from kullanicilar where id = cast(p_kadi as int);

    else
    set v_sonuc = 0;
    select v_sonuc;
    end if;
end if;
END;
$$

DELIMITER ;

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'int)) then select id, upper(left(ad,1))+ right(ad, char_length(rtrim(ad)) -1' at line 18

PM 77-1
  • 12,933
  • 21
  • 68
  • 111
  • 1
    Possible duplicate of [Cast from VARCHAR to INT - MySQL](http://stackoverflow.com/questions/12126991/cast-from-varchar-to-int-mysql) – PM 77-1 Mar 05 '16 at 18:12
  • As the in the linked question suggests, use `UNSIGNED` instead of `int`. – PM 77-1 Mar 05 '16 at 18:13

0 Answers0