I want to call rest api in a POST
method from a stored procedure or trigger in mysql server on windows.
How do I perform this solely with MySQL?
You can use 3rd party API Driver and call REST API in SQL Server like this way (Linked Server + OPENQUERY) - See example API data load in stored proc in below image.
MySQL allows you to call a stored procedure from a trigger by using the CALL statement. By doing this, you can reuse the same stored procedure in several triggers. However, the trigger cannot call a stored procedure that has OUT or INOUT parameters or a stored procedure that uses dynamic SQL.
Yes, you can use the File System object to open and process files, and you can read and write to files by using the File System object directly within T-SQL.
Trigger: Trigger can't be called from Store Procedure or Function. Store procedure: Stored Procedures can accept any type of parameter. Stored Procedures also accept out parameter. Function: Function can accept any type of parameter.
You can use a mysql-udf-http and then create a trigger like this:
delimiter $$
CREATE TRIGGER upd_check BEFORE UPDATE ON account
FOR EACH ROW
BEGIN
IF NEW.amount > 0 THEN
set @json = select json_object(account_id,amount)
select http_post('http://restservice.example.com/account/post',@json);
END IF;
END;$$
delimiter;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With