root/sql/sprocs/prism.remove_graph_tags.sql

Revision a27cd9b462a686609eff744d1e6553da5605090b, 0.9 kB (checked in by Depesz Lubaczewski <depesz@omniti.com>, 4 years ago)

prism procedures, and simple tool to split pg_dump -n prism -s output into many files

  • Property mode set to 100644
Line 
1 CREATE OR REPLACE FUNCTION prism.remove_graph_tags(in_graphid uuid, in_tags text) RETURNS void
2     AS $$
3 DECLARE
4 v_graphid uuid;
5 v_graph_tags text[];
6 new_tags_array text[];
7 i int;
8  BEGIN
9     SELECT graphid,graph_tags into v_graphid,v_graph_tags
10             FROM prism.saved_graphs
11               WHERE graphid =in_graphid;
12      IF NOT FOUND THEN
13                     RAISE EXCEPTION 'GraphID does not exist in saved graphs table.';
14      ELSE
15         FOR i IN array_lower(v_graph_tags, 1)..array_upper(v_graph_tags, 1) LOOP
16            IF NOT v_graph_tags[i] =any(v_graph_tags) THEN
17               new_tags_array = array_append(new_tags_array, v_graph_tags[i]);
18            END IF;
19         END LOOP;
20         UPDATE  prism.saved_graphs SET graph_tags = new_tags_array WHERE graphid=in_graphid;           
21      END IF;
22   RETURN;
23 END
24 $$
25     LANGUAGE plpgsql;
26
27
28 ALTER FUNCTION prism.remove_graph_tags(in_graphid uuid, in_tags text) OWNER TO reconnoiter;
Note: See TracBrowser for help on using the browser.