#2
风飘无殇2021-10-22 11:04
|
程序代码:
UPDATE Files x
SET ( x.Filename ) = nvl(
(
SELECT DISTINCT
T7.lastfile
FROM-- Files T1,-- 附件文件名表
Version T2,-- 版本表
Version_File_Map T3,-- 版本文件名映射表
Attachment T4,-- 附件表
Item T5,-- 物料表
Attachment_Map T6,-- 附件跟物料, 附件跟版本映射
FILENAME_P T7 -- 物料,原名,新名,版本号
WHERE
x.Id = T3.File_Id
AND T2.Id = T3.Version_Id
AND T2.Attach_Id = T4.Id
AND T4.Id = T6.Attach_Id -- AND T2.Attach_Id = T6.Attach_Id
AND T5.Id = T6.Parent_Id
AND T2.Attach_Id = T6.Attach_Id
AND x.File_Type = 'PDF'
AND T7.id = T5.Item_Number -- AND T5.ITEM_NUMBER = '110103000967'
AND T7.firstfile = x.Filename -- AND T1.FILENAME = '110103000967_初始.PDF'
AND T2.VERSION_NUM = T7.version -- AND T7.version = '1'
-- AND T1.id = x.id -- ) T WHERE lastfile = T.lastfile
),
x.filename
)
SET ( x.Filename ) = nvl(
(
SELECT DISTINCT
T7.lastfile
FROM-- Files T1,-- 附件文件名表
Version T2,-- 版本表
Version_File_Map T3,-- 版本文件名映射表
Attachment T4,-- 附件表
Item T5,-- 物料表
Attachment_Map T6,-- 附件跟物料, 附件跟版本映射
FILENAME_P T7 -- 物料,原名,新名,版本号
WHERE
x.Id = T3.File_Id
AND T2.Id = T3.Version_Id
AND T2.Attach_Id = T4.Id
AND T4.Id = T6.Attach_Id -- AND T2.Attach_Id = T6.Attach_Id
AND T5.Id = T6.Parent_Id
AND T2.Attach_Id = T6.Attach_Id
AND x.File_Type = 'PDF'
AND T7.id = T5.Item_Number -- AND T5.ITEM_NUMBER = '110103000967'
AND T7.firstfile = x.Filename -- AND T1.FILENAME = '110103000967_初始.PDF'
AND T2.VERSION_NUM = T7.version -- AND T7.version = '1'
-- AND T1.id = x.id -- ) T WHERE lastfile = T.lastfile
),
x.filename
)
运行
ORA-01427: 单行子查询返回多个行
查询出来的是结果集,但是这就是我需要的啊,一张表的字段批量更新另一张表的一个字段,各位大神们,怎么搞啊