SQL:不存在且 openquery 未按预期工作

发布于 2024-09-08 04:10:38 字数 3025 浏览 2 评论 0原文

我确实有一个 oracle 8 数据库,我想从中获取数据到 SQL Server 2005。如果 SQL Server 2005 上的表为空,则以下语句可以正常工作。如果我运行时缺少一个条目,则它不起作用。如果任何其他信息有用,请告诉我!

SELECT wdmsoracle.NO
FROM (Select * from OPENQUERY(msch,  'select 
                                                actu.NO
                                                , actu.ANNOSEQUENT
                                                , replace(replace(dm.descript, ''Generated by modification request '', ''Modification request''), ''Pseudo ECR for WDMS-SAP interface'', ''New Drawing'')
                                                , actu.APPRDATE
                                                , actu.MADEDATE
                                                , actu.MAINDRW
                                                , actu.DESIGNGRP
                                                , actu.ITEMID
                                                , actu.ISSUE
                                                , actu.DESCRIPT
                                                , actu.DESCRIPT2
                                                , dr.PRODUCTCODE
                                                , mpaths.webpath as asdasd
                                                , vpaths.webpath
                                            FROM 
                                                WDDRAWACTU actu
                                                , wddraw dr
                                                , wddvfilesiss vfiles
                                                , wddvpaths vpaths
                                                , wddmfiles mfiles
                                                , wddmpaths mpaths
                                                , wdanno dm
                                            WHERE actu.apprdate >= to_date(''01-01-05'',''dd-mm-yy'')
                                                and actu.itemid = dr.itemid (+)
                                                and actu.issue = dr.issue (+)
                                                and actu.annosequent = dm.sequent (+)
                                                and actu.itemid = vfiles.itemid (+)
                                                and actu.issue = vfiles.issue (+)
                                                and vfiles.pathid = vpaths.pathid
                                                and actu.annosequent = mfiles.sequent (+)
                                                and mfiles.pathid = mpaths.pathid')) as wdmsoracle
Where NOT EXISTS (
        SELECT wdmsoracle.NO
        FROM [DesignMessage_Workflow].[dbo].[WDMS] wdms, (Select * from OPENQUERY(msch,  'select 
                                                actu.NO
                                            FROM 
                                                WDDRAWACTU actu
                                            WHERE actu.apprdate >= to_date(''01-01-05'',''dd-mm-yy'')')) as wdmsoracle
        WHERE wdms.NO = wdmsoracle.NO)

I do have an oracle 8 database from which I want to fetch data to SQL Server 2005. The following statement works fine, if the table on SQL Server 2005 is empty. If I run with let's say one entry missing, it does not work. Please let me know, if any additional information would be usefull!

SELECT wdmsoracle.NO
FROM (Select * from OPENQUERY(msch,  'select 
                                                actu.NO
                                                , actu.ANNOSEQUENT
                                                , replace(replace(dm.descript, ''Generated by modification request '', ''Modification request''), ''Pseudo ECR for WDMS-SAP interface'', ''New Drawing'')
                                                , actu.APPRDATE
                                                , actu.MADEDATE
                                                , actu.MAINDRW
                                                , actu.DESIGNGRP
                                                , actu.ITEMID
                                                , actu.ISSUE
                                                , actu.DESCRIPT
                                                , actu.DESCRIPT2
                                                , dr.PRODUCTCODE
                                                , mpaths.webpath as asdasd
                                                , vpaths.webpath
                                            FROM 
                                                WDDRAWACTU actu
                                                , wddraw dr
                                                , wddvfilesiss vfiles
                                                , wddvpaths vpaths
                                                , wddmfiles mfiles
                                                , wddmpaths mpaths
                                                , wdanno dm
                                            WHERE actu.apprdate >= to_date(''01-01-05'',''dd-mm-yy'')
                                                and actu.itemid = dr.itemid (+)
                                                and actu.issue = dr.issue (+)
                                                and actu.annosequent = dm.sequent (+)
                                                and actu.itemid = vfiles.itemid (+)
                                                and actu.issue = vfiles.issue (+)
                                                and vfiles.pathid = vpaths.pathid
                                                and actu.annosequent = mfiles.sequent (+)
                                                and mfiles.pathid = mpaths.pathid')) as wdmsoracle
Where NOT EXISTS (
        SELECT wdmsoracle.NO
        FROM [DesignMessage_Workflow].[dbo].[WDMS] wdms, (Select * from OPENQUERY(msch,  'select 
                                                actu.NO
                                            FROM 
                                                WDDRAWACTU actu
                                            WHERE actu.apprdate >= to_date(''01-01-05'',''dd-mm-yy'')')) as wdmsoracle
        WHERE wdms.NO = wdmsoracle.NO)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嗳卜坏 2024-09-15 04:10:38

这个网站的帮助下我能够自己解决这个问题:

SELECT wdmsoracle.NO
        FROM (Select * from OPENQUERY(msch,  'select 
                                                actu.NO
                                                , actu.ANNOSEQUENT
                                                , replace(replace(dm.descript, ''Generated by modification request '', ''Modification request''), ''Pseudo ECR for WDMS-SAP interface'', ''New Drawing'')
                                                , actu.APPRDATE
                                                , actu.MADEDATE
                                                , actu.MAINDRW
                                                , actu.DESIGNGRP
                                                , actu.ITEMID
                                                , actu.ISSUE
                                                , actu.DESCRIPT
                                                , actu.DESCRIPT2
                                                , dr.PRODUCTCODE
                                                , mpaths.webpath as asdasd
                                                , vpaths.webpath
                                            FROM 
                                                WDDRAWACTU actu
                                                , wddraw dr
                                                , wddvfilesiss vfiles
                                                , wddvpaths vpaths
                                                , wddmfiles mfiles
                                                , wddmpaths mpaths
                                                , wdanno dm
                                            WHERE actu.apprdate >= to_date(''01-01-05'',''dd-mm-yy'')
                                                and actu.itemid = dr.itemid (+)
                                                and actu.issue = dr.issue (+)
                                                and actu.annosequent = dm.sequent (+)
                                                and actu.itemid = vfiles.itemid (+)
                                                and actu.issue = vfiles.issue (+)
                                                and vfiles.pathid = vpaths.pathid
                                                and actu.annosequent = mfiles.sequent (+)
                                                and mfiles.pathid = mpaths.pathid')) as wdmsoracle
Where NOT EXISTS (
        SELECT wdms.NO
        FROM [DesignMessage_Workflow].[dbo].[WDMS] wdms
        WHERE wdms.NO = wdmsoracle.NO)

with the help of this website I was able to solve it on my own:

SELECT wdmsoracle.NO
        FROM (Select * from OPENQUERY(msch,  'select 
                                                actu.NO
                                                , actu.ANNOSEQUENT
                                                , replace(replace(dm.descript, ''Generated by modification request '', ''Modification request''), ''Pseudo ECR for WDMS-SAP interface'', ''New Drawing'')
                                                , actu.APPRDATE
                                                , actu.MADEDATE
                                                , actu.MAINDRW
                                                , actu.DESIGNGRP
                                                , actu.ITEMID
                                                , actu.ISSUE
                                                , actu.DESCRIPT
                                                , actu.DESCRIPT2
                                                , dr.PRODUCTCODE
                                                , mpaths.webpath as asdasd
                                                , vpaths.webpath
                                            FROM 
                                                WDDRAWACTU actu
                                                , wddraw dr
                                                , wddvfilesiss vfiles
                                                , wddvpaths vpaths
                                                , wddmfiles mfiles
                                                , wddmpaths mpaths
                                                , wdanno dm
                                            WHERE actu.apprdate >= to_date(''01-01-05'',''dd-mm-yy'')
                                                and actu.itemid = dr.itemid (+)
                                                and actu.issue = dr.issue (+)
                                                and actu.annosequent = dm.sequent (+)
                                                and actu.itemid = vfiles.itemid (+)
                                                and actu.issue = vfiles.issue (+)
                                                and vfiles.pathid = vpaths.pathid
                                                and actu.annosequent = mfiles.sequent (+)
                                                and mfiles.pathid = mpaths.pathid')) as wdmsoracle
Where NOT EXISTS (
        SELECT wdms.NO
        FROM [DesignMessage_Workflow].[dbo].[WDMS] wdms
        WHERE wdms.NO = wdmsoracle.NO)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文