Skip to content

Commit 05e9e4a

Browse files
[ADD] Raise exception
1 parent e51d347 commit 05e9e4a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

classes/32-functions.sql

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,22 @@ BEGIN
8383
-- Calculations
8484
possible_raise = job_max_salary - current_salary;
8585

86+
IF (possible_raise < 0) THEN
87+
RAISE EXCEPTION 'Person with salary greater than max_salary: %', empl_id;
88+
-- possible_raise = 0;
89+
END IF;
90+
8691
RETURN possible_raise;
8792
END;
8893
$$ LANGUAGE plpgsql;
8994

9095
SELECT *
9196
FROM max_raise_2(206);
9297

93-
SELECT *
98+
SELECT
99+
employee_id,
100+
first_name,
101+
salary,
102+
max_raise_2(employee_id)
94103
FROM employees
95104
WHERE employee_id = 206;

0 commit comments

Comments
 (0)