I get the following error trying to call a stored procedure using the Tds library for Elixir
The stored procedure get_account
exists and has exactly one parameter @id
iex(5)>Tds.Connection.query(pid, "get_account",[%Tds.Parameter{name: "@id", value: 1}])
{:error,
%Tds.Error{message: nil,
mssql: %{class: 16, length: 252, line_number: 0, msg_text: "Procedure or function 'get_account' expects parameter '@id', which was not supplied.", number: 201, proc_name: "get_account",
server_name: "localhost\\SQLEXPRESS", state: 4}}}
iex(6)>
Trying this with Tds.proc(pid, "get_account",[1])
does not work either
Workaround:
Tds.query(pid, "get_account 1",[])
Use this the same way you would pass parameters directly to a stored proc using EXEC
.
Updated:
This format also works:
params = [
%Tds.Parameter{name: "@1", value: 100, type: :integer},
%Tds.Parameter{name: "@2", value: 100, type: :integer},
%Tds.Parameter{name: "@3", value: <<0 ,0 ,0 ,0>>, type: :binary},
]
Conn.query(s.db, "save_auth_key @1, @2, @3", params)