I am creating a trigger in SQL, in which I use the UDFs to invoke a JAVA code. This Java code returns a string, from which I have to check the value to allow an action or not. What SQL function can I use to check the contents of that String in an IF condition?
TRIGGER CODE:
CREATE TRIGGER ContentInsert
BEFORE INSERT ON joomladb.joomla_content
FOR EACH ROW
BEGIN
#DECLARE cmd CHAR(255);
DECLARE status CHAR(10);
SET status = sys_exec('java /rutadelarchivo/check_status.jar');
IF status NOT IN ("off") THEN
SIGNAL SQLSTATE '45000' -- "unhandled user-defined exception"
SET MESSAGE_TEXT = ' Cerrado';
END IF;
END
JAVA CODE:
public class check_status {
final static String APP_ID ="CADENADEEJEMPLO";
public static String principal_status(String accountId){
LatchApp latch= new LatchApp(APP_ID,LATCH_SECRET);
LatchResponse response=latch.status(accountId);
String status=response.getData().get("operations").getAsJsonObject().get(APP_ID).getAsJsonObject().get("status").getAsString();
return status;
}
}