2017-07-20 07:52
浏览 188

sqlx + Go:存储过程中的输出参数

I have mssql stored procedure that contains output parameter and can be called like this

    @Input = N'Some Text',
    @Result = @Result OUTPUT

Do you know if it's possible to access this @Result in jmoiron/sqlx after sp call?

图片转代码服务由CSDN问答提供 功能建议

我有包含输出参数并且可以这样调用的mssql存储过程 < pre> EXEC [SP_NAME] @Input = N'Some Text', @Result = @Result OUTPUT

您是否知道 可以在sp调用后在 jmoiron / sqlx 中访问此 @Result

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douxiong2999 2017-07-20 09:27

    sqlx is just a wrapper around database/sql package. The query you're trying to perform is driver specific. Thus, it depends on the driver you're using to connect to the MSSQL server. If you're using, based on issue #78, you can try the following:

    rows, err := db.Queryx(`EXEC [SP_NAME] @Input, @Result OUTPUT; 
              SELECT Result = @Result;`, sql.Named("Input", "Some Text"))
    //do something with rows...
    解决 无用
    打赏 举报

相关推荐 更多相似问题