sql - Postgresql record to array -


I need to change back into an array to change lines from the array and filter the records. I am using info_schema._pg_expandarray in a SELECT query to get a line copy value in the array.

Looking at the following array:

  "four" [] {i, i, o, t, b}   

_pg_expandarray leaves 5 rows with 1 row type record:

  records (I, 1) (i, 2) (o, 3) (t, 4)   

I have to filter this result set 't' to exclude record records.

How can I do this? Should I convert back to the array? What is a way to filter the array directly?

Thanks in advance.

If your purpose is to create one set of the above rows, but remove the 't' in the line So, this is the trick:

  test => Information (i), 'o', 't', 'b' i. N --- --- --- i | 1 mother 2 o | 3b 5 (4 lines)   

As a side, unless you specifically want to return the index as a second column, then I unnest () < / Code> information_schema._pg_expandarray () , which does not appear in the document and is probably for internal use by the name '_'.

It does not appear that your question made in any function to filter the filter array indicates that you can see the result in an array form - if this is the case then writing simple tasks is trivial. An example is given:

  Create a function array filter (by any means, anyway) announces $ $ $ $ for $ 1; FiltValue ALIAS for $ 2; Outierra Alles for $ 0; outIndex int = 0; RAR for RAR (ARE, 1) .. ARAYPAPER (ARE, 1) Loop if IArray [I]! = FiltValue comes out [outIndex]: = inArray [I]; outIndex = outIndex + 1; end if; End loop; Return outrage; End; $$ Language plpgsql Fixed input tap on reverse tap;   

Usage:

  test = & gt; Select array_filter (array ['i', 'i', 'o', 't', 'b'], 't'); Array_filter ----------------- [0: 3] = {i, i, o, b} (1 line)    < / Html>

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -