需要在游标中传递参数值 [英] Need To Pass Parameter Value inside Cast in Cursor
本文介绍了需要在游标中传递参数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
declare cursor_deci cursor
for select SOuD_CuBal,uom_noofdecimal,sm_code from #itm
declare @sm_code int,@UoM_NoofDecimal int
declare @SOuD_CuBal as numeric(21,6)
declare @newSOuD_CuBal as numeric(21,6)
open cursor_deci
fetch next from cursor_deci into @SOuD_CuBal,@Uom_Noofdecimal,@sm_code
while (@@FETCH_STATUS =0)
begin
''update #tmp2 SET cubal = CAST((@SOuD_CuBal) as decimal(18,@Uom_Noofdecimal)
where sm_code = @sm_code
fetch next from cursor_deci into @SOuD_CuBal,@Uom_Noofdecimal,@sm_code
end
close cursor_deci
deallocate cursor_deci
更新声明附近给出错误
欢迎任何建议
谢谢和问候
Harsha
its giving error near update statement
any suggestions are welcome
Thanks and Regards
Harsha
推荐答案
Hay Harsha,
见下面的代码,如果你能正确查询,那么你可以得到int的结果。
Hay Harsha,
See below code and if you can make your query proper then you can get result as int.
declare @aa as decimal(18,2) =25000.545
select cast(@aa as int)
如果您对上述内容有任何疑问,请告诉我们。)
Let me know if you have any query for above :)
这篇关于需要在游标中传递参数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文