具有输出参数的tored过程

编程入门 行业动态 更新时间:2024-10-28 06:24:28
本文介绍了具有输出参数的tored过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Hello开发人员, 我有一个存储过程有输出参数,我想知道它们是否是一个更好的方法将返回值存储在变量中,因为我需要将它们分配给一个对象。该过程还接受两个参数并返回3个值。 我可以使用一个接收2个参数的方法并返回值 ALTER PROCEDURE [dbo]。[GetPurchaseUnitINDefaultUnit] - 在这里添加存储过程的参数 @quantity as decimal(20 ,4), @PurchaseUnitID为int, @TranslatedQuantity为十进制(20,4)输出, @DefaultUnitID as int输出, @DefaultUnitDesc as varchar(50)输出 谢谢

解决方案

如果您在存储过程中使用SELECT语句,结果将返回给调用程序。这样结果将作为结果集处理,而不是作为输出参数处理。 例如,看看 www.sqlteam/article/stored-procedures-returning-data [ ^ ]

如果要返回多个值,那么你只有三个选项: 1)用你正在做的参数。 2)通过SELECT语句返回值。 或 3)将您的值转换为VARCHAR并将它们连接在一起。 我不会使用最后一个。

Hello developers, I have a stored procedure that has output parameter and i was wondering if their is a better way to store the returned values in a variable because i need to assign them to an object. the procedure also takes in two parameters and returns 3 values. can i have a method that takes in 2 arguments and returns me the values ALTER PROCEDURE [dbo].[GetPurchaseUnitINDefaultUnit] -- Add the parameters for the stored procedure here @quantity as decimal(20,4), @PurchaseUnitID as int, @TranslatedQuantity as decimal(20,4) output, @DefaultUnitID as int output, @DefaultUnitDesc as varchar(50) output thanks

解决方案

If you use a SELECT statement inside the stored procedure, the result is returned to the calling program. This way the result is handled as a result set, not as output parameters. For example have a look at www.sqlteam/article/stored-procedures-returning-data[^]

If you are returning more than one value, then you have three options only: 1) Use out parameters as you are doing. 2) Return values via a SELECT statement. or 3) Convert your values to VARCHAR and concatenate them together. I wouldn''t use the last one.

更多推荐

具有输出参数的tored过程

本文发布于:2023-11-09 05:11:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571472.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:参数   过程   tored

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!