Stored Procedure Array Input

Can we pass a list of numbers to input parameter of SP? Is it possible.

a!storedProcedureInput(
name: "group_ids",
value:local!groupids (It is a list of number)

),

It's not working as input parameter is defined as INT on DB side but we are passing list of integers.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    1st Approach -  you can pass in string format and can split the string by the seprator or find_in_set

    2nd approach: 

    create one expression rule in which use forEach Expression and pass your array of input as items and in expression call your stored procedure smart function (executeStoredProcedureForQuery) to execute. see eg below - 

    a!localVariables(
    local!groupsIds: {},
    reject(
    a!isNullOrEmpty,
    a!flatten(
    a!forEach(
    items: local!groupsIds,
    expression: a!localVariables(
    local!resp: a!executeStoredProcedureForQuery(
    dataSource: "dataource_name",
    procedureName: "procedure_name_in_db",
    inputs: {
    a!storedProcedureInput(name: "group_ids", value: fv!item)
    }
    ),
    if(
    local!resp.success,
    local!resp.results,
    null()
    )
    )
    )
    )
    )
    )

Reply
  • 0
    Certified Senior Developer

    1st Approach -  you can pass in string format and can split the string by the seprator or find_in_set

    2nd approach: 

    create one expression rule in which use forEach Expression and pass your array of input as items and in expression call your stored procedure smart function (executeStoredProcedureForQuery) to execute. see eg below - 

    a!localVariables(
    local!groupsIds: {},
    reject(
    a!isNullOrEmpty,
    a!flatten(
    a!forEach(
    items: local!groupsIds,
    expression: a!localVariables(
    local!resp: a!executeStoredProcedureForQuery(
    dataSource: "dataource_name",
    procedureName: "procedure_name_in_db",
    inputs: {
    a!storedProcedureInput(name: "group_ids", value: fv!item)
    }
    ),
    if(
    local!resp.success,
    local!resp.results,
    null()
    )
    )
    )
    )
    )
    )

Children
No Data