BIND_VALUES()

All functions > CORE > BIND_VALUES()

Binds the given array of values to the given feature or features.

Signatures

Returns: A table with the array values unnested into rows and columns

BIND_VALUES( array ) [ WITH ORDINALITY ] → TABLE<T>
sql
ParameterTypeRequiredDescription
arrayARRAY<ROW<T>>YesValues to bind: an array of scalars for one input, or an array of rows for several
ordinalityBOOLEANNoWITH ORDINALITY adds a row number column

Notes

  • Used in the FOR clause: FOR CUSTOMER_ID := BIND_VALUES(ARRAY[1, 2, 3]), or FOR (A, B) := BIND_VALUES(ARRAY[ROW(...), ...]) for several inputs
  • Each array element becomes one row of the result
  • Row fields are matched to the bound inputs in order

See also

Examples

Array of scalars: one input, multiple rows

FeatureQL
DEFINE
    input1 := INPUT(BIGINT),
    calculated := input1 + 1
RETURN
    input1,
    calculated
FOR
    input1 := BIND_VALUES(ARRAY(1, 3, 5))
;
Result
INPUT1 BIGINTCALCULATED BIGINT
12
34
56

Array of rows: multiple inputs in lockstep

FeatureQL
DEFINE
    input1 := INPUT(BIGINT),
    input2 := INPUT(BIGINT),
    calculated := input1 + input2
RETURN
    input1,
    input2,
    calculated
FOR
    (input1, input2) := BIND_VALUES(ARRAY(ROW(1, 2), ROW(3, 4), ROW(5, 6)))
;
Result
INPUT1 BIGINTINPUT2 BIGINTCALCULATED BIGINT
123
347
5611