2

I'm trying to remove an item from a BIGINT Array, so naturally i tried :

update MyTABLE
set MyBigIntArray= array_remove(MyBigIntArray,1)
where id=10

but Postgresql (tried with 9.5 and 10.0 ) reply me :

HINT: No function matches the given name and argument types. You might need to add explicit type casts. ERROR: function array_remove(bigint[], integer) does not exist

even if it normally accept anyarray : array_remove(anyarray, anyelement) , src : Postgres DOC

The only thing that make it work is to cast my bigint[] to int[] like that :

update MyTABLE
set MyBigIntArray= array_remove(MyBigIntArray::int[],1)
where id=10

so is there a way to do that in a simple way ? (i found some plsql/SQL function)

1 Answer 1

2

You need to cast the 1 to bigint too:

[local] #= SELECT array_remove(ARRAY[1::bigint], 1);
ERROR:  42883: function array_remove(bigint[], integer) does not exist
LINE 1: SELECT array_remove(ARRAY[1::bigint], 1);
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
LOCATION:  ParseFuncOrColumn, parse_func.c:523

[local] #= SELECT array_remove(ARRAY[1::bigint], 1::bigint);
┌──────────────┐
│ array_remove │
├──────────────┤
│ {}           │
└──────────────┘
(1 row)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, damn it was so simple :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.