Skip to content

Instantly share code, notes, and snippets.

@nkonev
Created October 14, 2015 06:46
Show Gist options
  • Select an option

  • Save nkonev/a6ca90ade2f36fe8851a to your computer and use it in GitHub Desktop.

Select an option

Save nkonev/a6ca90ade2f36fe8851a to your computer and use it in GitHub Desktop.
delimiter $$
CREATE PROCEDURE my_sp7(patch_uuid varchar(36), sql_query varchar(1024))
BEGIN
IF NOT EXISTS (SELECT `uuid` FROM `patch` WHERE `uuid` = patch_uuid) THEN
INSERT INTO `patch` (`uuid`) VALUES (patch_uuid);
SET @mystate = sql_query;
PREPARE stmt FROM @mystate;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END IF;
END
call my_sp7('uuid2', 'INSERT INTO `words` (`word_id`, `spelling`) VALUES (\'2\', \'boss\');');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment