MT.Checks/DB/chk/functions/chk_check_delete.sql

23 lines
627 B
PL/PgSQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- chk.chk_check_delete: удаление проверки по id.
-- На основе: новая.
-- Параметры: p_id — идентификатор проверки.
-- Возвращает: int — число удалённых строк (db-m-3).
CREATE OR REPLACE FUNCTION chk.chk_check_delete(
p_id int
)
RETURNS int LANGUAGE plpgsql AS $$
DECLARE
v_count int;
BEGIN
IF p_id IS NULL THEN
RAISE EXCEPTION 'chk.chk_check_delete: не задан p_id';
END IF;
DELETE FROM chk.chk_check t
WHERE t.id = p_id;
GET DIAGNOSTICS v_count = ROW_COUNT;
RETURN v_count;
END;
$$;