Skip to content

Instantly share code, notes, and snippets.

@franciscohanna92
Created April 28, 2019 02:25
Show Gist options
  • Save franciscohanna92/c78a48eb739a833cc9102b7ea1f71436 to your computer and use it in GitHub Desktop.
Save franciscohanna92/c78a48eb739a833cc9102b7ea1f71436 to your computer and use it in GitHub Desktop.
Stored procedure with error handling live template for Intellij Datagrip
use $database$
DELIMITER $$
drop procedure if exists $procedureName$ $$
create procedure $procedureName$()
begin
declare exit handler for sqlexception
begin
get diagnostics condition 1 @sqlstate = returned_sqlstate , @errno = mysql_errno , @text = message_text ;
set @full_error = concat('ERROR ', @errno, @`sqlstate`, @text);
select @full_error;
end;
start transaction ;
$END$
select concat('yay') as success;
commit;
end$$
/* Finally, reset the delimiter to the default ; */
DELIMITER ;
call $procedureName$();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment