FUNCTION

기본형

CREATE FUNCTION function_name(param1 type, param2 type)
 RETURNS return_type AS
BEGIN
 -- code
END;
LANGUAGE language_name;

PROCEDURE

기본형

CREATE PROCEDURE deactivate_unpaid_accounts()

LANGUAGE SQL

AS $$

  UPDATE accounts SET active = false WHERE balance < 0;

$$;

오류상황 처리

참고자료