第一范文网 - 专业文章范例文档资料分享平台

用友T3升级报错列名cMemo无效和对象名dbo.ST - CalBegInvAge无效

来源:用户分享 时间:2025/12/16 15:12:29 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

Begin

Return End

--计算本期当前结存

Set @strNewRecord = N'Insert Into ' +@cDBName+'..STStockAgeTempTable(autoid, iqtty, inum)

values(@autoid, @iTempQtty, @iTempNum) '

set @strLeftQty =

' SELECT cWhCode,

cInvCode,

IsNull(cBatch,'''') As cBatch,

IsNull(cFree1,'''') As cFree1,

IsNull(cFree2,'''') As cFree2,

SUM(case when bRdFlag = 1 then iQuantity else -iQuantity end) as iQtty,

SUM(case when bRdFlag = 1 then iNum else - iNum end) AS iNum

From( Select bRdFlag, cWhCode, cInvCode, iQuantity, INum, cBatch, cFree1, cFree2

From '+ @cDBName+'..ST_BegInvAge

Union ALL

Select R.bRdFlag, R.cWhCode, Rs.cInvCode, Rs.iQuantity, Rs.INum, Rs.cBatch, Rs.cFree1, Rs.cFree2

From ' + @cDBName+ '..RdRecord R inner join '+@cDBName+'..RdRecords Rs on R.id = Rs.id

Where R.dDate >= @StartDate And R.dDate <= @CurrentDate And cVouchType <> ''33'' And cVouchType <> ''34''

) X

group by cWhCode, cInvCode, IsNull(cBatch,''''),IsNull(cFree1,''''), IsNull(cFree2,'''') ' --取入库语句

Set @strSQLIn = ' Select AutoId, iQtty, iNum

From (Select dDate, AutoId, abs(iQuantity) As iQtty, abs(iNum) As iNum

From '+@cDBName+'..ST_BegInvAge

Where cWhCode = @cWhCode and cInvCode = @cInvCode and isnull(cBatch,'''') = @cBatch

and isnull(cFree1,'''') = @cFree1 and isnull(cFree2,'''') = @cFree2

Union ALL

Select d.dDate,ds.autoid, Abs(ds.iQuantity) as iQtty, Abs(ds.iNum) as iNum

from '+@cDBName+'..RdRecord d join ' + @cDBName + '..RdRecords ds on (d.id = ds.id)

where ( (d.bRdFlag = 1 and ds.iQuantity > 0) or (d.bRdFlag <> 1 and ds.iQuantity < 0))

And d.dDate >= @StartDate and d.dDate <= @CurrentDate and d.cWhCode = @cWhCode

and ds.cInvCode = @cInvCode and IsNull(ds.cBatch,'''') = @cBatch and IsNull(ds.cFree1,'''') = @cFree1

and IsNull(ds.cFree2,'''') = @cFree2) X

order by dDate Desc,AutoID Desc for read only '

Set @strSQLIn = N' declare curInvIn insensitive cursor for ' + @strSQLIn

set @strLeftQty = N'declare curRd cursor for ' + @strLeftQty

execute sp_executesql @strLeftQty,

N'@CurrentDate Datetime, @StartDate Datetime',

@CurrentDate, @StockStartDate

open curRd

fetch next from curRd into

@cWhCode,@cInvCode,@cBatch,

@cFree1,@cFree2,@iQtty, @iNum

--建立计算结果临时表

Set @sSQL = N'select @Num = count(1) from ' + @cDBName + '..sysobjects ' + ' Where name = ''STStockAgeTempTable'' '

exec sp_executesql @sSQL,N'@Num int output', @iCou output

If @iCou <> 0

Begin

Exec (' Drop Table ' + @cDBName+'..STStockAgeTempTable') End

Exec (' Create Table '+@cDBName+'..STStockAgeTempTable (autoId int , iQtty float, iNum float)')

--sp_help ST_BegInvAge

while @@fetch_status = 0

begin

if(@iQtty < 0 ) set @iQtty = 0

if(@iNum < 0 or @iNum is null) set @iNum = 0

Set @iTempQtty = 0.0

Set @iTempNum = 0.0

--按降序取入库

execute sp_executesql @strSQLIn,

用友T3升级报错列名cMemo无效和对象名dbo.ST - CalBegInvAge无效.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c71agm01y1g8n6j587kh5_3.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top