set sql_mode=default ;
create role if not exists testrole ;
DELIMITER /
CREATE or replace procedure p1 (IN wobj VARCHAR(10))
BEGIN
  
END;
/
CREATE or replace PROCEDURE fnobjdrt_ok (IN wobj VARCHAR(10),
IN wtyp  VARCHAR(10),
IN wdrt  VARCHAR(10),
IN wgrp  VARCHAR(10))
 BEGIN
  declare wcmd varchar(200);
  -- work fine  
  set wcmd=concat('grant ',wdrt,' on ',wtyp,' ',wobj,' to ',wgrp);
  execute immediate wcmd;
 END;
/
CREATE or replace PROCEDURE fnobjdrt_ko (IN wobj VARCHAR(10),
IN wtyp  VARCHAR(10),
IN wdrt  VARCHAR(10),
IN wgrp  VARCHAR(10))
 BEGIN
   -- assertion failed
   execute immediate concat('grant ',wdrt,' on ',wtyp,' ',wobj,' to ',wgrp);
 END;
/
DELIMITER ;
call fnobjdrt_ok('p1','procedure','execute','testrole');
call fnobjdrt_ko('p1','procedure','execute','testrole');

