It's Autumn! Prices fall like leaves! - hours only!Up to 80% off on all courses and bundles.-Close
Returning tables and sets
Summary
9. Exercise 1

Instruction

Awesome! Let's get to the first one!

Exercise

Create a function named lock_user(user_id int) that updates the record with the given ID in the user_account table and sets the is_locked column to TRUE and the locked_date column to the current date. The new function shouldn't return any value.

If there is no user with the given user_id in the user_account table, you should raise an exception:

'Nonexistent user ID --> %', user_id

With the following hint:

'Please check the user ID'

We've removed the template code, but check out the hint below if you need it.

Stuck? Here's a hint!

CREATE FUNCTION /* function name */(/* argument */)
RETURNS /* return type */ AS $$
BEGIN
  /* add your logic here */
END;
$$ LANGUAGE plpgsql;