2

尝试使用 Elixir 的Tds库调用存储过程时出现以下错误

存储过程get_account存在且只有一个参数@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)> 

尝试这个Tds.proc(pid, "get_account",[1])也不起作用

4

1 回答 1

1

解决方法:

Tds.query(pid, "get_account 1",[])

使用它的方式与使用EXEC.

更新:

这种格式也适用:

 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)
于 2016-04-17T08:37:08.480 回答