CREATE OR REPLACE PROCEDURE PROD.TASK_MONITOR_INSERT_PROC(
    task_name STRING, 
    start_time TIMESTAMP,
    row_count number,
    status STRING,
    type STRING
)
RETURNS STRING
LANGUAGE SQL
AS 
$$
begin
    insert into PROD.TASK_MONITOR
    select
        :task_name as name,
        :type as type,
        :status as status,
        :start_time as start_time,
        current_timestamp() as end_time,
        datediff(second, :start_time, current_timestamp()) as duration,
        :row_count as row_affected,
        date(start_time) as p_date,
        hour(start_time) as p_hour;
end;
$$;
