sql - Use array operators inside postgresql function -


i'm trying create postgresql. keep having error

error: operator not exist: integer[] <@ integer hint: no operator matches given name , argument type(s). might need add explicit type casts.

create or replace function accumulate_cs_order(int[][], int) returns int[][] language sql $f$ select case when array[abs($2)] <@ $1[1] -- if $2 has been closed pass   $1 when $2 < 0 -- elif we're closing $2 add $1[1]   array[array_append($1[1], abs($2)), $1[2]] when $2 < $1[2] -- elif we're not closing $2 , cheaper $1[2], our new cs   array[$1[1], array[$2]] else   $1 end; $f$; 

i can't figure out why not working. have declared variables right types, array[abs($2)] <@ $1[1] makes sense me, because $1[1] array, postgresql seems thinking int.

it has how specific element vs slice of array. slice

when abs($2) = any($1[1:1]) 

should work, but:

select (array[array[1,2,3],array[4,5,6],array[7,8,9]])[1:1];    array    -----------  {{1,2,3}} 

it's rectangular slice of whole array, not 1 dimensional array.

select (array[array[1,2,3],array[4,5,6],array[7,8,9]])[1:1] = array[1,2,3];  ?column?  ----------  f 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -