FUNCTION sal_ok (rank INT, salary REAL)
RETURN BOOLEAN IS
min_sal REAL;
max_sal REAL;
BEGIN
SELECT losal, hisal INTO min_sal, max_sal FROM
salgrade WHERE grade = rank;
RETURN(salary >= min_sal) AND (salary <= max_sal);
END sal_ok;
PROCEDURE raise_salary (emp_id INT, grade INT, amountREAL)
IS salary REAL;
BEGIN
SELECT sal INTO salary FROM emp
WHERE empno = emp_id;
IF sal_ok(grade, salary + amount) THEN UPDATE emp
SET sal = sal + amount WHERE empno = emp_id;
ELSERAISE invalid_salary;
END IF;
END raise_salary;