Skip to content

Instantly share code, notes, and snippets.

@dlangille

dlangille/query Secret

Created July 2, 2016 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlangille/3f464ac2537028f0602551f1bf4db2ba to your computer and use it in GitHub Desktop.
Save dlangille/3f464ac2537028f0602551f1bf4db2ba to your computer and use it in GitHub Desktop.
I have this query in a plpgsql function, and I want to discard the result set, and I think I need to do that via PERFORM.
WITH RECURSIVE all_descendents AS (
SELECT id, name, parent_id, directory_file_flag, status
FROM element
WHERE id = (select pathname_id('/ports/head/' || a_category_name || '/' || a_port_name || '/'))
UNION
SELECT E.id, E.name, E.parent_id, E.directory_file_flag, E.status
FROM element E
JOIN all_descendents AD
ON (E.parent_id = AD.id)
)
SELECT element_add(replace(element_pathname(id), '/ports/head/', '/ports/branches/' || a_branch_name || '/'), directory_file_flag),
replace(element_pathname(id), '/ports/head/', '/ports/branches/' || a_branch_name || '/'), directory_file_flag
FROM all_descendents
WHERE status = 'A';
PERFORM
WITH RECURSIVE all_descendents AS (
SELECT id, name, parent_id, directory_file_flag, status
FROM element
WHERE id = (select pathname_id('/ports/head/' || a_category_name || '/' || a_port_name || '/'))
UNION
SELECT E.id, E.name, E.parent_id, E.directory_file_flag, E.status
FROM element E
JOIN all_descendents AD
ON (E.parent_id = AD.id)
)
SELECT element_add(replace(element_pathname(id), '/ports/head/', '/ports/branches/' || a_branch_name || '/'), directory_file_flag),
replace(element_pathname(id), '/ports/head/', '/ports/branches/' || a_branch_name || '/'), directory_file_flag
FROM all_descendents
WHERE status = 'A';
ERROR: syntax error at or near "PERFORM"
LINE 1: PERFORM
^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment