Skip to content

Instantly share code, notes, and snippets.

@subssn21
Created July 10, 2014 01:43
Show Gist options
  • Select an option

  • Save subssn21/e9e121f6fd5ff50f688d to your computer and use it in GitHub Desktop.

Select an option

Save subssn21/e9e121f6fd5ff50f688d to your computer and use it in GitHub Desktop.
backport array_remove to postgres 9.2
create or replace function array_remove(a anyarray, e anyelement) returns anyarray as $$
BEGIN
return array(
select x from unnest(a) x where x <> e
);
END;
$$ LANGUAGE plpgsql;
@ghiculescu

Copy link
Copy Markdown

note to self

select array(select x from unnest(regexp_split_to_array(',text', ',')) x where x <> '')

this works fine, if you want to avoid the new function

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