ERROR ORA-00905:缺少关键字(oracle的microsoft ole db provider)

时间:2016-07-12 11:34:05

标签: sql oracle

任何人都可以看到下面的pl / sql查询中缺少哪些关键字?

我收到错误ORA-00905:缺少关键字(oracle的microsoft ole db provider)

不确定缺少哪个关键字 - 这是对oracle数据库的odbc查询

        SELECT "STAT"."ORD"."SAMPLEID",

MAX(CASE WHEN "STAT"."ORDANAEL"."MC"='QAERS' THEN N"STAT"."ORDANAEL"."RES_TXT" ELSE  
'' END)  AS ERSID,

"STAT"."ORDMCSTP_V"."SEQNB", "STAT"."ORD"."ORDPATNAME",  
"STAT"."ORD"."ORDPATBIRTHDT", "STAT"."ORD"."CORORDNB", "STAT"."ORD"."PROJNB",

Max(CASE WHEN "STAT"."ORDANAEL"."MC"='AMMOL' THEN 'AMMOL' 

WHEN "STAT"."ORDANAEL"."MC"='AMMOLR' THEN 'AMMOLR' ELSE '' END) AS TEST, 


Max(CASE WHEN "STAT"."ORDANAEL"."MC"='AMMOL' THEN N"STAT"."ORDRESMCEL"."MC_RES"

WHEN "STAT"."ORDANAEL"."MC"='AMMOLR' THEN N"STAT"."ORDRESMCEL"."MC_RES" ELSE ''  
END) AS MC_RES, 



Max( CASE WHEN "STAT"."ORDMCSTP_V"."STEPMC"='AMIMI' THEN N"STAT"."ORDMCSTPEL"."RES"  
ELSE '' END) AS IMI, 

Max( CASE WHEN "STAT"."ORDMCSTP_V"."STEPMC"='AMIMP' THEN N"STAT"."ORDMCSTPEL"."RES"  
ELSE '' END)  AS IMP, 

Max( CASE WHEN "STAT"."ORDMCSTP_V"."STEPMC"='AMNDM' THEN N "STAT"."ORDMCSTPEL"."RES"  
ELSE '' END)  AS NDM, 

Max( CASE WHEN "STAT"."ORDMCSTP_V"."STEPMC"='AMOX48' THEN  
N "STAT"."ORDMCSTPEL"."RES" ELSE '' END)  AS OXA48, 

Max( CASE WHEN "STAT"."ORDMCSTP_V"."STEPMC"='AMSPM' THEN N "STAT"."ORDMCSTPEL"."RES"  
ELSE '' END)  AS SPM, 

Max( CASE WHEN "STAT"."ORDMCSTP_V"."STEPMC"='AMVIM' THEN N "STAT"."ORDMCSTPEL"."RES"  
ELSE '' END)  AS VIM, 

Max( CASE WHEN "STAT"."ORDMCSTP_V"."STEPMC"='AMDIM' THEN N "STAT"."ORDMCSTPEL"."RES"  
ELSE '' END)  AS DIM, 

Max( CASE WHEN "STAT"."ORDMCSTP_V"."STEPMC"='AMKPC' THEN N "STAT"."ORDMCSTPEL"."RES"  
ELSE '' END)  AS KPC, 

Max( CASE WHEN "STAT"."ORDMCSTP_V"."STEPMC"='AMGES' THEN N "STAT"."ORDMCSTPEL"."RES"  
ELSE '' END)  AS GES, 

Max( CASE WHEN "STAT"."ORDMCSTP_V"."STEPMC"='AMSME' THEN N "STAT"."ORDMCSTPEL"."RES"  
ELSE '' END)  AS SME, 

Max( CASE WHEN "STAT"."ORDMCSTP_V"."STEPMC"='AMFRI1' THEN  
N "STAT"."ORDMCSTPEL"."RES" ELSE '' END)  AS FRI1, 

Max( CASE WHEN "STAT"."ORDMCSTP_V"."STEPMC"='AMSIM' THEN N "STAT"."ORDMCSTPEL"."RES"  
ELSE '' END)  AS SIM, 

Max( CASE WHEN "STAT"."ORDMCSTP_V"."STEPMC"='AMGIM' THEN N "STAT"."ORDMCSTPEL"."RES"  
ELSE '' END)  AS GIM,



Max( CASE WHEN "STAT"."ORDANAEL"."MC"='AMMOL' THEN N "STAT"."ORDANAEL"."VALMED" ELSE  
'' END)  AS VALMED_AMMOL, 

Max( CASE WHEN "STAT"."ORDANAEL"."MC"='AMMOL' AND  
"STAT"."ORDANAEL_D"."DFIELD"='RR' THEN N "STAT"."ORDANAEL_D"."DVALUE" ELSE '' END)   
AS RPT_DT_AMMOL, 

"STAT"."ORDANAEL"."RES_ST" 



FROM (("STAT"."ORDMCSTPEL" INNER JOIN ("STAT"."ORDMCSTP_V" INNER JOIN  
("STAT"."ORD" INNER JOIN "STAT"."ORDANAEL" ON ("STAT"."ORD"."LID" =  
"STAT"."ORDANAEL"."LID") AND ("STAT"."ORD"."LPERIOD" =  
"STAT"."ORDANAEL"."LPERIOD") AND ("STAT"."ORD"."ORDNB" =  
"STAT"."ORDANAEL"."ORDNB")) ON ("STAT"."ORDMCSTP_V"."LID" = "STAT"."ORD"."LID")  
AND ("STAT"."ORDMCSTP_V"."LPERIOD" = "STAT"."ORD"."LPERIOD") AND  
("STAT"."ORDMCSTP_V"."ORDNB" = "STAT"."ORD"."ORDNB")) ON ("STAT"."ORDMCSTPEL"."BC"  
= "STAT"."ORDMCSTP_V"."BC") AND ("STAT"."ORDMCSTPEL"."CURRENT_STEPNB" =  
"STAT"."ORDMCSTP_V"."CURRENT_STEPNB")) INNER JOIN "STAT"."ORDANAEL_D" ON  
("STAT"."ORDANAEL"."NBINT" = "STAT"."ORDANAEL_D"."DNBINT") AND  
("STAT"."ORDANAEL"."SPSEQ" = "STAT"."ORDANAEL_D"."DSPSEQ") AND  
("STAT"."ORDANAEL"."ORDNB" = "STAT"."ORDANAEL_D"."DORDNB") AND  
("STAT"."ORDANAEL"."LPERIOD" = "STAT"."ORDANAEL_D"."DLPERIOD") AND  
("STAT"."ORDANAEL"."LID" = "STAT"."ORDANAEL_D"."DLID")) INNER JOIN  
"STAT"."ORDRESMCEL" ON ("STAT"."ORDMCSTP_V"."SEQNB" = "STAT"."ORDRESMCEL"."SEQNB")  
AND ("STAT"."ORDANAEL"."ORDNB" = "STAT"."ORDRESMCEL"."ORDNB") AND  
("STAT"."ORDANAEL"."LPERIOD" = "STAT"."ORDRESMCEL"."LPERIOD") AND  
("STAT"."ORDANAEL"."LID" = "STAT"."ORDRESMCEL"."LID")





WHERE (("STAT"."ORD"."LID")='H1')

AND (("STAT"."ORD"."LPERIOD")>'5200') 

AND (("STAT"."ORD"."PROJNB")='ACPOERS')



GROUP BY "STAT"."ORD"."SAMPLEID", "STAT"."ORDMCSTP_V"."SEQNB",  
"STAT"."ORD"."ORDPATNAME", "STAT"."ORD"."ORDPATBIRTHDT", "STAT"."ORD"."CORORDNB",  
"STAT"."ORD"."PROJNB", "STAT"."ORDANAEL"."RES_ST"
HAVING ((("STAT"."ORDMCSTP_V"."SEQNB") Is Not Null) AND (("STAT"."ORD"."PROJNB") 
='ACPOERS') AND (("STAT"."ORDANAEL"."RES_ST")>'4'))

2 个答案:

答案 0 :(得分:0)

太大而无法发表评论。刚刚清理了双引号和N,它在SQL格式化程序中变得干净。

SELECT      STAT.ORD.SAMPLEID,
            MAX ( CASE WHEN STAT.ORDANAEL.MC = 'QAERS' THEN STAT.ORDANAEL.RES_TXT ELSE '' END ) AS ersid,
            STAT.ORDMCSTP_V.SEQNB,
            STAT.ORD.ORDPATNAME,
            STAT.ORD.ORDPATBIRTHDT,
            STAT.ORD.CORORDNB,
            STAT.ORD.PROJNB,
            MAX (
                  CASE
                      WHEN STAT.ORDANAEL.MC = 'AMMOL' THEN 'AMMOL'
                      WHEN STAT.ORDANAEL.MC = 'AMMOLR' THEN 'AMMOLR'
                      ELSE ''
                  END )
                AS test,
            MAX (
                  CASE
                      WHEN STAT.ORDANAEL.MC = 'AMMOL' THEN STAT.ORDRESMCEL.MC_RES
                      WHEN STAT.ORDANAEL.MC = 'AMMOLR' THEN STAT.ORDRESMCEL.MC_RES
                      ELSE ''
                  END )
                AS mc_res,
            MAX ( CASE WHEN STAT.ORDMCSTP_V.STEPMC = 'AMIMI' THEN STAT.ORDMCSTPEL.RES ELSE '' END ) AS imi,
            MAX ( CASE WHEN STAT.ORDMCSTP_V.STEPMC = 'AMIMP' THEN STAT.ORDMCSTPEL.RES ELSE '' END ) AS imp,
            MAX ( CASE WHEN STAT.ORDMCSTP_V.STEPMC = 'AMNDM' THEN STAT.ORDMCSTPEL.RES ELSE '' END ) AS ndm,
            MAX ( CASE WHEN STAT.ORDMCSTP_V.STEPMC = 'AMOX48' THEN STAT.ORDMCSTPEL.RES ELSE '' END ) AS oxa48,
            MAX ( CASE WHEN STAT.ORDMCSTP_V.STEPMC = 'AMSPM' THEN STAT.ORDMCSTPEL.RES ELSE '' END ) AS spm,
            MAX ( CASE WHEN STAT.ORDMCSTP_V.STEPMC = 'AMVIM' THEN STAT.ORDMCSTPEL.RES ELSE '' END ) AS vim,
            MAX ( CASE WHEN STAT.ORDMCSTP_V.STEPMC = 'AMDIM' THEN STAT.ORDMCSTPEL.RES ELSE '' END ) AS dim,
            MAX ( CASE WHEN STAT.ORDMCSTP_V.STEPMC = 'AMKPC' THEN STAT.ORDMCSTPEL.RES ELSE '' END ) AS kpc,
            MAX ( CASE WHEN STAT.ORDMCSTP_V.STEPMC = 'AMGES' THEN STAT.ORDMCSTPEL.RES ELSE '' END ) AS ges,
            MAX ( CASE WHEN STAT.ORDMCSTP_V.STEPMC = 'AMSME' THEN STAT.ORDMCSTPEL.RES ELSE '' END ) AS sme,
            MAX ( CASE WHEN STAT.ORDMCSTP_V.STEPMC = 'AMFRI1' THEN STAT.ORDMCSTPEL.RES ELSE '' END ) AS fri1,
            MAX ( CASE WHEN STAT.ORDMCSTP_V.STEPMC = 'AMSIM' THEN STAT.ORDMCSTPEL.RES ELSE '' END ) AS sim,
            MAX ( CASE WHEN STAT.ORDMCSTP_V.STEPMC = 'AMGIM' THEN STAT.ORDMCSTPEL.RES ELSE '' END ) AS gim,
            MAX ( CASE WHEN STAT.ORDANAEL.MC = 'AMMOL' THEN STAT.ORDANAEL.VALMED ELSE '' END )
                AS valmed_ammol,
            MAX ( CASE
                     WHEN     STAT.ORDANAEL.MC = 'AMMOL'
                          AND STAT.ORDANAEL_D.DFIELD = 'RR' THEN
                         STAT.ORDANAEL_D.DVALUE
                     ELSE
                         ''
                 END )
                AS rpt_dt_ammol,
            STAT.ORDANAEL.RES_ST
FROM        ((STAT.ORDMCSTPEL
              INNER JOIN (STAT.ORDMCSTP_V
                          INNER JOIN (STAT.ORD
                                      INNER JOIN STAT.ORDANAEL
                                          ON     ( STAT.ORD.LID = STAT.ORDANAEL.LID )
                                             AND ( STAT.ORD.LPERIOD = STAT.ORDANAEL.LPERIOD )
                                             AND ( STAT.ORD.ORDNB = STAT.ORDANAEL.ORDNB ))
                              ON     ( STAT.ORDMCSTP_V.LID = STAT.ORD.LID )
                                 AND ( STAT.ORDMCSTP_V.LPERIOD = STAT.ORD.LPERIOD )
                                 AND ( STAT.ORDMCSTP_V.ORDNB = STAT.ORD.ORDNB ))
                  ON     ( STAT.ORDMCSTPEL.BC = STAT.ORDMCSTP_V.BC )
                     AND ( STAT.ORDMCSTPEL.CURRENT_STEPNB = STAT.ORDMCSTP_V.CURRENT_STEPNB ))
             INNER JOIN STAT.ORDANAEL_D
                 ON     ( STAT.ORDANAEL.NBINT = STAT.ORDANAEL_D.DNBINT )
                    AND ( STAT.ORDANAEL.SPSEQ = STAT.ORDANAEL_D.DSPSEQ )
                    AND ( STAT.ORDANAEL.ORDNB = STAT.ORDANAEL_D.DORDNB )
                    AND ( STAT.ORDANAEL.LPERIOD = STAT.ORDANAEL_D.DLPERIOD )
                    AND ( STAT.ORDANAEL.LID = STAT.ORDANAEL_D.DLID ))
            INNER JOIN STAT.ORDRESMCEL
                ON     ( STAT.ORDMCSTP_V.SEQNB = STAT.ORDRESMCEL.SEQNB )
                   AND ( STAT.ORDANAEL.ORDNB = STAT.ORDRESMCEL.ORDNB )
                   AND ( STAT.ORDANAEL.LPERIOD = STAT.ORDRESMCEL.LPERIOD )
                   AND ( STAT.ORDANAEL.LID = STAT.ORDRESMCEL.LID )
WHERE           ( ( STAT.ORD.LID ) = 'H1' )
            AND ( ( STAT.ORD.LPERIOD ) > '5200' )
            AND ( ( STAT.ORD.PROJNB ) = 'ACPOERS' )
GROUP BY    STAT.ORD.SAMPLEID,
            STAT.ORDMCSTP_V.SEQNB,
            STAT.ORD.ORDPATNAME,
            STAT.ORD.ORDPATBIRTHDT,
            STAT.ORD.CORORDNB,
            STAT.ORD.PROJNB,
            STAT.ORDANAEL.RES_ST
HAVING      (    ( ( STAT.ORDMCSTP_V.SEQNB ) IS NOT NULL )
             AND ( ( STAT.ORD.PROJNB ) = 'ACPOERS' )
             AND ( ( STAT.ORDANAEL.RES_ST ) > '4' ) );

答案 1 :(得分:0)

您可以在字符串文字前面使用N将其标记为nvarchar2。例如:

select N'abc' from dual

但是你不能像你那样在标识符前面使用它。如果您想将某个列值读取为nvarchar2,则需要将其按原样投射。例如:

... THEN cast("STAT"."ORDANAEL"."RES_TXT" as nvarchar2(50)) ...