找回密码
 注册账号

QQ登录

只需一步,快速开始

手机号码,快捷登录

手机号码,快捷登录

初学者课程:T3自学|T6自学|U8自学软件下载课件下载工具下载资料:通资料|U8资料|NC|培训|年结积分规则 | 使用常见问题Q&A
知识库:U8 | | NC | U9 | OA | 政务U8|U9|NCC|NC65|NC65客开|NCC客开新手必读 | 任务 | 快速增金币用友QQ群[微信群]
查看: 4270|回复: 1

[数据库知识] 在通升级到U851提示错误大家来指点下谢谢

[复制链接]
发表于 2010-2-6 13:16:59 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册账号

×
数据库名: UFDATA_002_2007
应收应付数据, DATA2_AP
错误信息:
-2147217873
违反了 PRIMARY KEY 约束 'PK_VoucherNumber'。不能在对象 'VoucherNumber' 中插入重复键。
执行如下语句时出错:
--预置单据编号
DECLARE @bRemote VARCHAR(10)
DECLARE @RemoteID Varchar(2)
DECLARE @ID int
Set @bRemote=(SELECT Upper(cValue) FROM Accinformation Where cName='bRemote')
IF @bRemote ='TRUE'
Set @RemoteID=(SELECT Isnull(cValue,'') FROM Accinformation Where cName='cID')
ELSE
Set @RemoteID=''
IF NOT EXISTS (Select CardNumber From VoucherNumber Where AppName='应收' and CardNumber='R0')
BEGIN
  insert into VoucherNumber (AppName,CardNumber,CardName) values('应收','R0','其他应收单')
  set @ID=(select Max(iCancelNo) From Ap_CancelNo Where cFlag='AR' and cType='R0')
  IF @ID is not null insert into VoucherHistory (CardNumber,cNumber) values('R0',@ID)
END
IF NOT EXISTS (Select CardNumber From VoucherNumber Where AppName='应付' and CardNumber='P0')
BEGIN
  insert into VoucherNumber (AppName,CardNumber,CardName) values('应付','P0','其他应付单')
  set @ID=(select Max(iCancelNo) From Ap_CancelNo Where cFlag='AP' and cType='P0')
  IF @ID is not null insert into VoucherHistory (CardNumber,cNumber) values('P0',@ID)
END
IF NOT EXISTS (Select CardNumber From VoucherNumber Where AppName='应收' and CardNumber='RR')
IF @bRemote='TRUE'
  BEGIN
   insert into VoucherNumber (AppName,CardNumber,CardName,iSize,dStartDate,Prefix1,Prefix1Len)
   values('应收','RR','收款单',10,getdate(),'远程号',2)
   set @ID=(select Max(iCancelNo) From Ap_CancelNo Where cFlag='AR' and cType='R')
   IF @ID is not null insert into VoucherHistory (CardNumber,cNumber) values('RR',@ID)
  END
ELSE
  BEGIN
   insert into VoucherNumber (AppName,CardNumber,CardName) values('应收','RR','收款单')
   set @ID=(select Max(iCancelNo) From Ap_CancelNo Where cFlag='AR' and cType='R')
   IF @ID is not null insert into VoucherHistory (CardNumber,cNumber) values('RR',@ID)
  END
IF NOT EXISTS (Select CardNumber From VoucherNumber Where AppName='应收' and CardNumber='RP')
IF @bRemote='TRUE'
  BEGIN
   insert into VoucherNumber (AppName,CardNumber,CardName,iSize,dStartDate,Prefix1,Prefix1Len)
   values('应收','RP','付款单',10,getdate(),'远程号',2)
   set @ID=(select Max(iCancelNo) From Ap_CancelNo Where cFlag='AR' and cType='P')
   IF @ID is not null insert into VoucherHistory (CardNumber,cNumber) values('RP',@ID)
  END
ELSE
  BEGIN
   insert into VoucherNumber (AppName,CardNumber,CardName) values('应收','RP','付款单')
   set @ID=(select Max(iCancelNo) From Ap_CancelNo Where cFlag='AR' and cType='P')
   IF @ID is not null insert into VoucherHistory (CardNumber,cNumber) values('RP',@ID)
  END
IF NOT EXISTS (Select CardNumber From VoucherNumber Where AppName='应付' and CardNumber='PP')
IF @bRemote='TRUE'
  BEGIN
   insert into VoucherNumber (AppName,CardNumber,CardName,iSize,dStartDate,Prefix1,Prefix1Len)
   values('应付','PP','付款单',10,getdate(),'远程号',2)
   set @ID=(select Max(iCancelNo) From Ap_CancelNo Where cFlag='AP' and cType='P')
   IF @ID is not null insert into VoucherHistory (CardNumber,cNumber) values('PP',@ID)
  END
ELSE
  BEGIN
   insert into VoucherNumber (AppName,CardNumber,CardName) values('应付','PP','付款单')
   set @ID=(select Max(iCancelNo) From Ap_CancelNo Where cFlag='AP' and cType='P')
   IF @ID is not null insert into VoucherHistory (CardNumber,cNumber) values('PP',@ID)
  END
IF NOT EXISTS (Select CardNumber From VoucherNumber Where AppName='应付' and CardNumber='PR')
IF @bRemote='TRUE'
  BEGIN
   insert into VoucherNumber (AppName,CardNumber,CardName,iSize,dStartDate,Prefix1,Prefix1Len)
   values('应付','PR','收款单',10,getdate(),'远程号',2)
   set @ID=(select Max(iCancelNo) From Ap_CancelNo Where cFlag='AP' and cType='R')
   IF @ID is not null insert into VoucherHistory (CardNumber,cNumber) values('PR',@ID)
  END
ELSE
  BEGIN
   insert into VoucherNumber (AppName,CardNumber,CardName) values('应付','PR','收款单')
   set @ID=(select Max(iCancelNo) From Ap_CancelNo Where cFlag='AP' and cType='R')
   IF @ID is not null insert into VoucherHistory (CardNumber,cNumber) values('PR',@ID)
  END
发表于 2012-1-4 18:09:32 | 显示全部楼层
问题解决了没有??  解决了分享一下吧,我这正发愁呢
回复 点赞 拍砖

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

QQ|站长微信|Archiver|手机版|小黑屋|用友之家 ( 蜀ICP备07505338号|51072502110008 )

GMT+8, 2024-11-27 01:28 , Processed in 0.049314 second(s), 9 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表