I have created a stored procedure in MySQL named: inventory_procedure(fromDateTime)
A third party system executes this stored procedure at regular 1 hour interval by passing fromDateTime in dd-mm-yyyy hh:mm:ss format.
Sometimes, third party systems reports that stored procedure didn't returned any data.
When I hit the stored procedure it returns results for me.
is there any way where I can fetch information like:
Create a log table like this one:
create table inventory_procedure_log (
id int unsigned auto_increment primary key,
ts timestamp,
fromDateTime datetime,
rows_returned int
);
You will probably want to include some indexes for fast searches.
Insert the log entries within your procedure right after the final SELECT:
create procedure inventory_procedure (fromDateTime datetime)
begin
-- random dummy result set
select n
from (select 1 n union select 2 union select 3) as x
where rand() < 0.5;
-- insert log entry
insert into inventory_procedure_log(ts, fromDateTime, rows_returned) values (
now(),
fromDateTime,
found_rows()
);
end
Now you can search in your log table. For example - show all entries for the last 24 hours:
select *
from inventory_procedure_log
where ts > now() - interval 24 hour;
Se demo on dbfiddle.uk
You can extend the log table for more info (like session ID) as needed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.