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
Hello ashutoshs4646,You can pass array values. Try the using {}/{ local!groupIds } in your value parameter.
Have tried this.Even tried by passing 2 values in {}. It's not working.
Also, already a list so no need of {}
How do I pass a list as a parameter in a stored procedure?
Could you please show how your stored Procedure is defined and also try checking what is the type for your local!variable returning when you have the list of Ids
list type is numbers.
Hello ashutoshs4646 , not sure if we can pass list of integers here. Could you please let me know if your stored procedure is being executed for a single integer?
Yes, I also think we cannot pass list of integers. But even if you want to pass list, pass them in a string separated by any delimiter and then split them inside the SP. Refer to the below thread:https://community.appian.com/discussions/f/plug-ins/11690/execute-stored-procedure-is-not-taking-multiple-values-as-input
ashutoshs4646 I think yes. Passing it as a string would work I guess. sorry for the wrong answer above please ignore.
Pass in a list as a comma-separated string, then in the procedure itself you can use functions like FIND_IN_SET (depending on exactly what you need to do with it of course), to act directly on the list.
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() ) ) ) ) ))