Comments - Upgrading fomr MySQL to MariaDB, stored procedure with union

 
5 years, 10 months ago Ian Gilfillan

This appears to work fine, with no need to remove the BEGIN or END:

DELIMITER //

CREATE OR REPLACE DEFINER=`root`@`%` PROCEDURE `sp_s_persoon_bedrijf_werknemer`(
  IN  In_param1  varchar(30),
  IN  in_param2  varchar(30),
  IN  in_param3  varchar(30),
  IN  in_param4  varchar(30),
  IN  in_param5  varchar(30),
  IN  in_param6  varchar(30)
)
BEGIN
(select * from `v_bedrijf`          
where (zoekveld like concat('%',in_param1,'%') or in_param1 = '')
and   (zoekveld like concat('%',in_param2,'%') or in_param2 = '')
and   (zoekveld like concat('%',in_param3,'%') or in_param3 = '')
or    (zoekveld like concat('%',in_param4,'%') and in_param4 <> '')
or    (zoekveld like concat('%',in_param5,'%') and in_param5 <> '')
or    (zoekveld like concat('%',in_param6,'%') and in_param6 <> '') limit 1000)
union
(select * from `v_personen`          
where (zoekveld like concat('%',in_param1,'%') or in_param1 = '')
and   (zoekveld like concat('%',in_param2,'%') or in_param2 = '')
and   (zoekveld like concat('%',in_param3,'%') or in_param3 = '')
or    (zoekveld like concat('%',in_param4,'%') and in_param4 <> '')
or    (zoekveld like concat('%',in_param5,'%') and in_param5 <> '')
or    (zoekveld like concat('%',in_param6,'%') and in_param6 <> '')  limit 1000)
union
(select * from `v_werknemer`          
where (zoekveld like concat('%',in_param1,'%') or in_param1 = '')
and   (zoekveld like concat('%',in_param2,'%') or in_param2 = '')
and   (zoekveld like concat('%',in_param3,'%') or in_param3 = '')
or    (zoekveld like concat('%',in_param4,'%') and in_param4 <> '')
or    (zoekveld like concat('%',in_param5,'%') and in_param5 <> '')
or    (zoekveld like concat('%',in_param6,'%') and in_param6 <> '')  limit 1000);

END;

//

DELIMITER ;
 
5 years, 10 months ago Jan de Bokx

I tried it in MySQLWorkbench and Heidi, but got:

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'end' at line 38

After this I saw the delimiter change.... This prevents the error. I use the delimiter change only in scripts with multiple statements.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.