Skip to content

Instantly share code, notes, and snippets.

@glassresistor
Last active March 8, 2018 20:02
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 glassresistor/2c1e5c4a999eb9d48b555f129eb2aad2 to your computer and use it in GitHub Desktop.
Save glassresistor/2c1e5c4a999eb9d48b555f129eb2aad2 to your computer and use it in GitHub Desktop.
CREATE OR REPLACE FUNCTION remove_words(message text) RETURNS SETOF text AS $$
BEGIN
RETURN QUERY select * from regexp_split_to_table(message, E'\\s+') except select boring_words.word from boring_words where boring_words.word = ANY(regexp_split_to_array(message, E'\\s+'));
END;
$$ LANGUAGE plpgsql;
@glassresistor
Copy link
Author

ERROR: relation "allowed_words" does not exist
LINE 1: ...t_to_table(message, E'\s+') except select * from allowed_wo...
^
QUERY: select * from regexp_split_to_table(message, E'\s+') except select * from allowed_words
CONTEXT: PL/pgSQL function remove_words(text) line 6 at RETURN QUERY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment