oracle 使用完全外部联接和Union All时出现缺少关键字错误

qni6mghb  于 2023-08-03  发布在  Oracle
关注(0)|答案(1)|浏览(171)

我有我的脚本来创建3个视图,并将它们与完整的外部连接和联合所有查询相结合。但是当我运行这个查询时,我得到了一个缺少关键字的错误;各个视图对每个select语句都工作正常。
我的查询有什么问题?

CREATE OR replace force VIEW "VW_RANGE_REPORT_Jul2023"

WITH    live_str AS (        SELECT ------- from ---------- ),
        pend_str AS     (     SELECT  ----------from -----------),
        pend_only AS ( Select      --------from ---------)

SELECT  
NVL(lp.StoreNumber,pp.StoreNumber) AS StoreNumber, 
NVL(lp.StoreName,pp.StoreName) AS StoreName, 
lp.floorplanDBkey AS LiveFLRkey, 
lp.floorplanName As LiveFloorplanName, 
lp.FLRPENDDATE As LiveFLRPendDate, 
lp.FLRLIVEDATE AS LiveFLRLiveDate, 
lp.PlanogramKey AS LivePOGKey, 
lp.PlanogramName AS LivePOGName, 
lp.PlanogramPendingDate AS LivePOGPendDate, 
lp.PlanogramLiveDate AS LivePOGLiveDate, 
pp.floorplanDBkey AS PendFLkey, 
pp.floorplanName As PendFloorplanName, 
pp.FLRPENDDATE As PendFLRPendDate, 
pp.FLRLIVEDATE AS PendFLRLiveDate, 
pp.PlanogramKey AS PendPOGKey, 
pp.PlanogramName AS PendPOGName, 
pp.PlanogramPendingDate AS PendPOGPendDate, 
pp.PlanogramLiveDate AS PendPOGLiveDate

FROM    live_str lp

FULL OUTER JOIN pend_str pp ON pp.PlanogramVersionKey = lp.PlanogramVersionKey 
        AND pp.floorplanversionkey = lp.floorplanversionkey         
        AND pp.StoreNumber = lp.StoreNumber
        And pp.StorrDBKEy=lp.storedbkey

UNION ALL
    SELECT  po.StoreNumber,
            po.StoreName,
           NULL AS LiveFLRKey,
           NULL AS LiveFloorplanName,
           NULL AS LiveFLRPendDate,
            NULL AS LiveFLRLiveDate,
            NULL AS LivePOGKey,
            NULL AS LivePOGName,
            NULL AS LivePOGPendDate,
            NULL AS LivePOGLiveDate,
                 po.FloorplanDBKey AS PendFLKey,
                  po.FloorplanName as PendFloorplanName,
                  po.FLRPENDDATE as PendFLRPendDate,
                  po.FLRLIVEDATE as PendFLRLiveDate,
                  po.PlanogramKey AS PendPOGKey,
                po.PlanogramName AS PendPOGName,
            po.PlanogramPendingDate AS PendPOGPendDate,
            po.PlanogramLiveDate AS PendPOGLiveDate
FROM    pend_only po
ORDER BY 1,3;

字符串

wn9m85ua

wn9m85ua1#

这显然是错误的;我不知道你想用这段代码做什么:

WITH    live_str AS (        SELECT ------- from ---------- ),
        pend_str AS     (     SELECT  ----------from -----------),
        pend_only AS ( Select      --------from ---------)

字符串
也许你想做这样的事情?

CREATE OR REPLACE FORCE VIEW "VW_RANGE_REPORT_Jul2023"
AS
   WITH
      live_str
      AS
         (SELECT NVL (lp.storenumber, pp.storenumber) AS storenumber,
                 NVL (lp.storename, pp.storename) AS storename,
                 lp.floorplandbkey AS liveflrkey,
                 lp.floorplanname AS livefloorplanname,
                 lp.flrpenddate AS liveflrpenddate,
                 lp.flrlivedate AS liveflrlivedate,
                 lp.planogramkey AS livepogkey,
                 lp.planogramname AS livepogname,
                 lp.planogrampendingdate AS livepogpenddate,
                 lp.planogramlivedate AS livepoglivedate,
                 pp.floorplandbkey AS pendflkey,
                 pp.floorplanname AS pendfloorplanname,
                 pp.flrpenddate AS pendflrpenddate,
                 pp.flrlivedate AS pendflrlivedate,
                 pp.planogramkey AS pendpogkey,
                 pp.planogramname AS pendpogname,
                 pp.planogrampendingdate AS pendpogpenddate,
                 pp.planogramlivedate AS pendpoglivedate
            FROM live_str  lp
                 FULL OUTER JOIN pend_str pp
                    ON     pp.planogramversionkey = lp.planogramversionkey
                       AND pp.floorplanversionkey = lp.floorplanversionkey
                       AND pp.storenumber = lp.storenumber
                       AND pp.storrdbkey = lp.storedbkey
          UNION ALL
          SELECT po.storenumber,
                 po.storename,
                 NULL AS liveflrkey,
                 NULL AS livefloorplanname,
                 NULL AS liveflrpenddate,
                 NULL AS liveflrlivedate,
                 NULL AS livepogkey,
                 NULL AS livepogname,
                 NULL AS livepogpenddate,
                 NULL AS livepoglivedate,
                 po.floorplandbkey AS pendflkey,
                 po.floorplanname AS pendfloorplanname,
                 po.flrpenddate AS pendflrpenddate,
                 po.flrlivedate AS pendflrlivedate,
                 po.planogramkey AS pendpogkey,
                 po.planogramname AS pendpogname,
                 po.planogrampendingdate AS pendpogpenddate,
                 po.planogramlivedate AS pendpoglivedate
            FROM pend_only po)
   SELECT *
     FROM live_str;


另外,您是否确定要将视图名称括在双引号中并在其名称中使用混合字母大小写?你必须这样引用它--使用双引号和匹配字母大小写--每次你使用它。如果我是你我就

CREATE OR REPLACE FORCE VIEW vw_range_report_jul2023

相关问题