Re: How to remove n-first elements from array? - Mailing list pgsql-general

From aasat
Subject Re: How to remove n-first elements from array?
Date
Msg-id 1355736440348-5736866.post@n5.nabble.com
Whole thread Raw
In response to How to remove n-first elements from array?  (aasat <satriani@veranet.pl>)
Responses Re: How to remove n-first elements from array?
List pgsql-general
I found solution

do $$
declare
  v_array integer[] := array[1,2,3,4,5];
  v_array2 integer[];
  v_delete_elements integer :=2;
  v_new_index integer;
begin
  v_new_index := array_lower(v_array, 1) + v_delete_elements;

  v_array2 := array_fill(v_array[v_new_index], ARRAY[1], ARRAY[v_new_index])
||   v_array[v_new_index+1:array_upper(v_array, 1)];
  raise notice '%', v_array2;
end;
$$

NOTICE:  [3:5]={3,4,5}




--
View this message in context:
http://postgresql.1045698.n5.nabble.com/How-to-remove-n-first-elements-from-array-tp5736765p5736866.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


pgsql-general by date:

Previous
From: Albe Laurenz
Date:
Subject: Re: problem with large inserts
Next
From: aasat
Date:
Subject: Re: problem with large inserts