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

36 lines
1.0 KiB
PL/PgSQL
Raw Permalink 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_get: выборка одной проверки по идентификатору.
-- На основе: новая.
-- Параметры: p_id — идентификатор проверки.
-- Возвращает: TABLE — строка chk_check; несуществующий id — пустая таблица.
CREATE OR REPLACE FUNCTION chk.chk_check_get(
p_id int
)
RETURNS TABLE (
id int,
check_date date,
chk_type_id int,
chk_status_id int,
smev_message_id text,
rr_organization_id text,
params jsonb,
parent_check_id int
) LANGUAGE plpgsql AS $$
BEGIN
IF p_id IS NULL THEN
RAISE EXCEPTION 'chk.chk_check_get: не задан p_id';
END IF;
RETURN QUERY
SELECT t.id,
t.check_date,
t.chk_type_id,
t.chk_status_id,
t.smev_message_id,
t.rr_organization_id,
t.params,
t.parent_check_id
FROM chk.chk_check t
WHERE t.id = p_id;
END;
$$;