求助:存储过程执行报错:ORA-06502: PL/SQL: 数字或值错误
ORA-02055: 分布式更新操作失效;要求回退
ORA-06502: PL/SQL: 数字或值错误
ORA-06512: 在"CAP.P_TEST_SHE", line 16
跟踪检查发现,执行Insert没有任何问题,但执行Update操作,无论如何都出错。
检查了好久不得要法,请各位大侠指点!
数据库是oracle 9i v9.2.0.6
create or replace procedure P_TEST_SHE
as
v_IsDouble number;
v_TypeName varchar2(50);
begin
v_TypeName := 't_vorg_employ';
Update e3s.t_imp_e3sif2capif@e3sifdb Set Status='1' Where TypeName=v_TypeName;
Select count(1) into v_IsDouble From e3s.t_imp_e3sif2capif@e3sifdb Where Status='1' And TypeName=v_TypeName;
If v_IsDouble >0 then
For j in (Select a.EMPID,a.cname,a.EmpCode,a.id,a.Sex,a.Birthday,
(Select substrb(Name, 1, 50) From e3s.t_base_data @e3sifdb Where Code = a.Degree and Type = 26) Degree,
a.EMPLOYDATE,a.BusinessDate,a.MPhone,a.PHONE_C,
Substrb(a.ENAME,1,20) EName,Substrb(a.ADDR_H,1,50) Address,SubStrb(a.ZIPCODE,1,6) Zip,
a.mdate,
decode(status,'1',1,0) IsEnabled,
decode(status,'0',1,0) HasCanceled,
1 issystem
FROM e3s.t_vorg_employ @e3sifdb a
WHERE to_char(a.EMPID) in (Select keyvalue from e3s.t_imp_e3sif2capif@e3sifdb where status='1' and TypeName=v_TypeName)
and exists (select 'X' from cap.tSTOU_Employee Where EmployeeID=a.EMPID)
) Loop
update cap.tSTOU_Employee set
Name = substrb(j.CName,1,10),
Code = j.EmpCode,
IDCardNo = Substrb(j.ID,1,18),
Sex = decode(j.Sex,'1','1','0'),
Birthday = j.Birthday,
EducDegree = j.DEGREE,
HireDay = j.EMPLOYDATE,
EnterIndustryTime = j.BusinessDate,
MobilePhone = j.MPhone,
OfficePhone=j.PHONE_C,
EName= j.EName,
Address = j.Address,
Zip = j.Zip,
IsEnabled = j.IsEnabled,
HasCanceled = j.HasCanceled,
tFlag = 0,
stFlag=0
Where EmployeeID=j.EMPID;
End Loop;
-- 如果在表中无记录,直接插入数据
INSERT INTO cap.tSTOU_Employee
(EmployeeID,DutyID,IsPrimary,Name,Code,LogonName,LogonFlag,Password,
IsEnabled,HasCanceled,IDCardNo,Sex,Birthday,
EducDegree,HireDay,EnterIndustryTime,MobilePhone,OfficePhone,
EName,Address,Zip,OrgID,NetCode)
Select a.EMPID,100,1,a.cname,a.EmpCode,a.EMPID,decode(a.status,1,1,0),'',
decode(a.status,'1',1,0) IsEnabled,
decode(a.status,'0',1,0) HasCanceled,
Substrb(a.ID,1,18),decode(a.Sex,'1','1','0'),a.Birthday,
(Select substrb(Name, 1, 50) From e3s.t_base_data @e3sifdb Where Code = a.Degree and Type = 26) Degree,
a.EMPLOYDATE,a.BusinessDate,a.MPhone,a.PHONE_C,
Substrb(a.ENAME,1,20) EName,Substrb(a.ADDR_H,1,50) Address,SubStrb(a.ZIPCODE,1,6) Zip,
a.OrgID,
(Select dealerno from e3s.t_vorg_organization @e3sifdb where orgid= a.OrgID) NetCode
FROM e3s.t_vorg_employ @e3sifdb a
WHERE to_char(a.EMPID) in (Select keyvalue from e3s.t_imp_e3sif2capif@e3sifdb where status='1' and TypeName=v_TypeName)
and not exists (select 'X' from cap.tSTOU_Employee Where EmployeeID=a.EMPID);
delete e3s.t_imp_e3sif2capif@e3sifdb where Status='1' And TypeName=v_TypeName;
end if;
------------------------------------------------------------------------------------
Commit ;
end P_test_SHE;