From: Rogan Hamby Date: Fri, 7 Feb 2020 14:37:14 +0000 (-0500) Subject: adding mariadb/mysql functions file starting with split_string X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=57538f92486509faec4ae9b7f1f34c6c552d872c adding mariadb/mysql functions file starting with split_string --- diff --git a/sql/koha/general_functions.sql b/sql/koha/general_functions.sql new file mode 100644 index 0000000..83f2c4c --- /dev/null +++ b/sql/koha/general_functions.sql @@ -0,0 +1,19 @@ +DROP FUNCTION IF EXISTS split_string; +DELIMITER $ +CREATE FUNCTION + split_string (s TEXT, del VARCHAR(10), i INT) + RETURNS TEXT + DETERMINISTIC + BEGIN + DECLARE n INT ; + SET n = LENGTH(s) - LENGTH(REPLACE(s, del, '')) + 1; + IF i > n THEN + RETURN NULL ; + ELSE + RETURN SUBSTRING_INDEX(SUBSTRING_INDEX(s, del, i) , del , -1 ) ; + END IF; + END +$ +DELIMITER ; + +