capturing drop_partitions status
Hi,
I am having a stored procedure for dropping partitions older than 180days which looks like this
`
--/
CREATE OR REPLACE PROCEDURE deleteOldData() LANGUAGE PLvSQL AS '
DECLARE timestamptodrop date := SELECT (GETUTCDATE() -180)::date;
BEGIN
PERFORM
SELECT /+label(myselectquery)/ DROP_Partitions(
''public.mytable'',
timestamptodrop,
timestamptodrop
);
END;
';
/
`
this procedure is executed at 3AM UTC everyday
what I need to do is capture the o/p of DROP_Partitions function so that I can send out an email about the status.
In some cases DROP_Partitions returns 'Partition does not exist' or 'Partition Dropped' or any error message
how can I capture all this?
I know I can query query_requests with request_label and use the data from that table for gettign to know the status of the query execution (failed or succes), duration etc . But I want to capture the actual o/p pf drop_partition
Answers
Please try the following:
Run time output: