0

I have the floowing function signature in PostgreSQL:

func1(plist integer[])

i want to send this function an intager variable. basicly make a call:

select * from func1(var_integer)

How can I do that? It expect integer[] not integer. Is there some sort of conversion?

Edit:

when I do: select * from func1(var_integer::integer[])

I get:

cannot cast type integer to integer[]

2 Answers 2

1

Try:

select * from func1(array_agg(var_integer))

The function array_agg(expression) returns array of the argument type. Thus if var_integer is of type integer the result type of array_agg(var_integer) is integer[]

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

Comments

1

There's no need for array_agg here, and it won't work in more complex contexts.

Use the array constructor syntax.

select * from func1(ARRAY[var_integer])

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.