0

I have a table which has a column id with bigint type . I need to create function which will take a parameter bigint[] and in function I should check where id in (array)

CREATE OR REPLACE FUNCTION my_function(ids bigint[])
 select * from table where id in ($1)

Function creates successfully , but when I call it

SELECT * FROM my_function(ARRAY [1,2,3,4]);

I get an error:

 ERROR:  operator does not exist: bigint = bigint[]
1
  • 1
    You want the = ANY operator, not in. Commented Jun 5, 2017 at 14:41

1 Answer 1

1

As commented:

where id = any ($1)

https://www.postgresql.org/docs/current/static/functions-comparisons.html#AEN21104

Sign up to request clarification or add additional context in comments.

Comments

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.