附件字段数据迁移至附件面板SQL脚本原创
金蝶云社区-宜城小子
宜城小子
3人赞赏了该文章 81次浏览 未经作者许可,禁止转载编辑于2024年11月07日 17:30:44

MYSQL脚本:

INSERT INTO XX_sys.t_bas_attachment(

     FID,FNUMBER,FBILLNO,FBILLTYPE,FINTERID,FENTRYKEY,

     FENTRYINTERID,FCREATETIME,FAUDITTIME,FBILLSTATUS,FAUDITMEN,

     FCREATEMEN,FMODIFYTIME,FMODIFYMEN,FFILESTORAGE,FFILEID,

     FALIASFILENAME,FATTACHMENTNAME,

     FEXTNAME,FATTACHMENTSIZE,FTEMPPAGEID,FATTACHMENTPANEL,FDESCRIPTION,FLOCALID,FSORT,FFILESOURCE)

SELECT 

     Z.FID,Z.FUID AS FNUMBER, A.FBillNO AS FBILLNO,'dev_saleorder' AS FBILLTYPE, A.FID AS FINTERID,' ' AS FENTRYKEY,

     ' ' AS FENTRYINTERID,Z.FCREATETIME AS FCREATETIME, NULL AS FAUDITTIME,' ' AS FBILLSTATUS,'0' AS FAUDITMEN,

     Z.FCREATORID AS FCREATEMEN,Z.FMODIFYTIME AS FMODIFYTIME,0  AS FMODIFYMEN,0 AS FFILESTORAGE, Z.FURL AS FFILEID,

     SUBSTRING(Z.FURL, (LENGTH(Z.FURL)-LENGTH(SUBSTRING_INDEX(REVERSE(Z.FURL),'/',1))+1)) AS FALIASFILENAME,

     SUBSTRING(Z.FURL, (LENGTH(Z.FURL)-LENGTH(SUBSTRING_INDEX(REVERSE(Z.FURL),'/',1))+1)) AS FATTACHMENTNAME,

     Z.FTYPE AS FEXTNAME,Z.FSIZE AS FATTACHMENTSIZE,' ' AS FTEMPPAGEID,'attachmentpanel' AS FATTACHMENTPANEL,

     ' ' AS FDESCRIPTION,' ' AS FLOCALID, NULL AS FSORT,'0' AS FFILESOURCE

FROM XX_secd.t_sd_salesorder

INNER JOIN XX_secd.t_sd_salesorder_atta B ON A.FID=B.FID

INNER JOIN XX_sys.t_bd_attachment Z ON Z.FID=B.FBasedataId


说明:

1、XX_ 为数据库标识

2、A表为要迁移的单据对应表,B表为单据中附件字段对应的表

3、dev_saleorder 为 要迁移的单据 实体标识,attachmentpanel 为 单据中附件面板的标识

4、SUBSTRING(Z.FURL, (LENGTH(Z.FURL)-LENGTH(SUBSTRING_INDEX(REVERSE(Z.FURL),'/',1))+1)) 用于从附件字段的文件路径中截取文件名部分


效果:

上传图片


图标赞 3
3人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!