Direct database query - Array as an statement arg

Options

I´m having trouble to set an integer array as an statement arg to a direct database query

Array:

SQL:

Args:

Error:

The same SQL query without the args works:



Best Answer

  • Cameron B
    Cameron B Member, Administrator

    ADMIN

    Answer ✓
    Options

    You need to format the array (seen as a string) as an array. So we need to deconstruct it, and recombine it, and cast to an int:

    ANY(string_to_array(trim(both '[]' from ?), ',')::int[]);

Answers