Spring Deals - hours only!Up to 70% off on all courses and bundles.-Close
Introduction
Syntax of PL/pgSQL
Function parameters
Handling exceptions
Summary
28. Exercise 3

Instruction

Brilliant! Now, let's complete the last recap exercise.

Exercise

Create a scalar function with a signature of get_employees_salary(emp_id integer) that returns the salary value corresponding to a given employee ID.
The function should return the related salary value (of NUMERIC type) from the salary table for a given emp_id.

If the given emp_id doesn't exist in the person or salary table, we should raise an exception in the following format:

'Employee with ID XXX doesn't exist!'