0

I have a MySQL function as below, but it is generating an error:

BEGIN
DECLARE image1 VARCHAR(250);
select case when
    (
        select COUNT(*)
        from profile_images
        where building_id = bid
        and contractor_id = cid
    ) > 0
    then (
        select distinct (image)
        -- into image1
        from profile_images
        where building_id = bid
             and contractor_id = cid limit 1
    ) else (
        select distinct (image)
        -- into image1
        from profile_images
        where contractor_id = cid limit 1
    )
END into image1;
RETURN image1;
END  

The actual error shown by MySQL is #2014 - Commands out of sync; you can't run this command now.

Arvindh Mani
  • 130
  • 3
  • 12
samjad ps
  • 45
  • 5

1 Answers1

0

It was a mistake.wrong parametername passed to the function.Thank you very much Arvindh Mani.

samjad ps
  • 45
  • 5