Nishant Dongare Nishant Dongare - 2 months ago 9
MySQL Question

Having issue while creating procedure in MariaDB

I am trying to write procedure for my database.Here is the procedure



CREATE PROCEDURE getServiceProviderByServiceId(IN serviceId INT) BEGIN
declare servicename varchar(255);

SET servicename = (SELECT servicename FROM services WHERE id = serviceId);

SELECT * FROM service_providers INNER JOIN servicename ON servicename.serviceid = service_providers.serviceid;

END;





But MariaDb is showing following syntax error.
enter image description here

Answer

Try this one it's working fine in my local

-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `getServiceProviderByServiceId`(IN serviceId INT)
BEGIN
declare servicename varchar(255);
SET servicename = (SELECT servicename FROM services WHERE id = serviceId);

SELECT * FROM service_providers INNER JOIN servicename ON servicename.serviceid = service_providers.serviceid;
END
Comments