How to call stored procedure taking array using odbc:param_query in Erlang

故事扮演 提交于 2019-12-05 09:07:18

It looks like there is no OBDC data type (at least with a corresponding Erlang one) for a list of integer (see erlang obdc documentation). I don't know how the the final query should look like (the syntax for int array) but I think that you can achieve what you want by creating your query as a string:

Query = io_lib:format("CALL sum (~p , ~p)",[int_array_syntax([1,2,3,4]),1])

and then use odbc:sql_query(Ref, Query).

I believe you need to have an equal amount of arguments in both lists of arguments, meaning add three 1s in your 2nd list or arguments.

odbc:param_query(Ref,  "CALL sum (?, ?)", [{sql_integer, [1,2,3,4]}, {sql_integer, out, [1,1,1,1]}]).
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!