File: ltree_del_col.sql

package info (click to toggle)
goiardi 0.11.10-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,708 kB
  • sloc: sql: 4,994; makefile: 156; sh: 95; python: 30
file content (20 lines) | stat: -rw-r--r-- 616 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- Deploy ltree_del_col

BEGIN;

CREATE OR REPLACE FUNCTION goiardi.delete_search_collection(col text, m_organization_id int) RETURNS VOID AS
$$
DECLARE
	sc_id bigint;
BEGIN
	SELECT id INTO sc_id FROM goiardi.search_collections WHERE name = col AND organization_id = m_organization_id;
	IF NOT FOUND THEN
		RAISE EXCEPTION 'The collection % does not exist!', col;
	END IF;
	DELETE FROM goiardi.search_items WHERE organization_id = m_organization_id AND search_collection_id = sc_id;
	DELETE FROM goiardi.search_collections WHERE organization_id = m_organization_id AND id = sc_id;
END;
$$
LANGUAGE plpgsql;

COMMIT;