I want to write a function to delete old rows in table Offers and then return the deleted rows.
CREATE OR REPLACE FUNCTION delOldOffers() RETURNS void AS $$
DELETE FROM "public"."Offers"
WHERE created_at < now() - interval '7 days'
$$ LANGUAGE sql STABLE;
I wrote the above function but I am not sure how I can return rows that where deleted? If anyone can help that would be really great!