Complete the code to reference the new record in a trigger function.
RETURN [1];In PostgreSQL triggers, NEW refers to the new record being inserted or updated.
Complete the code to reference the old record in a DELETE trigger.
RAISE NOTICE 'Deleted user: %', [1].username;
In DELETE triggers, OLD contains the record being deleted.
Fix the error in the trigger function to correctly access the old record.
IF [1] IS NULL THEN RAISE EXCEPTION 'Old record missing'; END IF;
To check if the old record exists, use OLD. NEW is not valid here.
Fill both blanks to compare old and new values in an UPDATE trigger.
IF [1].email <> [2].email THEN RAISE NOTICE 'Email changed'; END IF;
Use OLD to access the previous value and NEW for the updated value.
Fill all three blanks to log changes in a trigger function.
INSERT INTO audit_log(user_id, old_email, new_email) VALUES ([1].id, [2].email, [3].email);
Use OLD for previous values and NEW for new values in audit logging.
