I'm writing one postgresql function that executes some update query. I need to make sure that any rows affected or not and return success/failure message accordingly.
If(rows affected)? then 'update success' else 'update failed'
How to RAISE NOTICE the row count??
-- Get count from UPDATE
WITH rows AS (
UPDATE distributors
SET dname = 'JKL Widgets'
WHERE did <= 10
RETURNING 1
)
SELECT count(*) FROM rows;