Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Side-effects in functions
Invoking functions

Instruction

Okay! There's another option in PL/pgSQL for calling a function: using the PERFORM statement.

When we use SELECT inside a function, we must keep the result of the function.

PERFORM allows us to evaluate an expression or SELECT query but discard the result (e.g., when calling a function that has side effects but no useful return value).

The example below demonstrates how to call a function in PL/pgSQL using the PERFORM statement:

CREATE FUNCTION schedule_event(id integer, name varchar(60), city varchar(60))
RETURNS void AS $$
BEGIN
  PERFORM add_event(id, name, city);
  PERFORM remove_announcement(id);
END;
$$ LANGUAGE plpgsql;

Exercise

Write a function named remove_post_author() that takes one input parameter post_id of type integer. The function should find the ID of the post author and remove their user account with the help of the function remove_user_account(user_id).