Ibm midrange IBMi上的此视图有一个错误

Ibm midrange IBMi上的此视图有一个错误,ibm-midrange,crystal-reports-xi,db2-400,Ibm Midrange,Crystal Reports Xi,Db2 400,我在这里所做的,是使用Crystal报表创建的SQL,并尝试从中创建一个视图 Initially, I am getting an error " Column qualifier or table OEINDLID undefined. " 您可以在这里看到Crystal是如何创建T01关联名称的: CREATE VIEW astccdta.acsusage AS

我在这里所做的,是使用Crystal报表创建的SQL,并尝试从中创建一个视图

Initially, I am getting an error " Column qualifier or table OEINDLID undefined. "

您可以在这里看到Crystal是如何创建T01关联名称的:

     CREATE VIEW astccdta.acsusage                                       
AS                                                                  
SELECT ICPRTMIA.IARCC9, OEINDLID.IDDOCD, OEINDLID.IDCOM#,           
ADRESSAD.ADSFX#, OEINDLID.IDPRT#, OEINDLID.IDGRC#, OEINDLID.IDENT#, 
OEINDLID.IDSFX#, OEINDLID.IDPRLC, OEINDLID.IDNTU$, OEINDLID.IDSHP#, 
ADRESSAD.ADFNM, ADRESSAD.ADLNM, OEINHDIH.IHVIAC, ADRESSAD.ADSTTC,   
OEINDLID.IDINV#, (                                                  
SELECT                                                              
    SUM (T01.IDNTU$)                                                
FROM                                                                
    ASTDTA.OEINDLID T01                                             
WHERE                                                               
    T01.IDCOM# = '001' AND                                          
    T01.IDDOCD = OEINDLID.IDDOCD AND                                
    T01.IDINV# = OEINDLID.IDINV# AND                                
    T01.IDPRLC LIKE 'F%'                                            

)
 FROM   (ASTDTA.OEINDLID                                      
INNER JOIN ASTDTA.ICPRTMIA ON OEINDLID.IDPRT#=ICPRTMIA.IAPRT#)
INNER JOIN (ASTDTA.ADRESSAD                                   
INNER JOIN ASTTRN.OEINHDIH ON ADRESSAD.ADENT#=OEINHDIH.IHENT#)
ON OEINDLID.IDIDC#=OEINHDIH.IHIDC#                            
 WHERE  ICPRTMIA.IARCC9='ACS'                                 
OEINDLID.IDCOM#='001'                                         
AND OEINDLID.IDPRT# LIKE 'ACS%'           
您在下面添加的代码不使用关联名称:

SELECT                                                              
    SUM (T01.IDNTU$)                                                
FROM                                                                
    ASTDTA.OEINDLID T01                           

它有很多。添加一个相关名称,如T01,并在引用oIndlid.some_column_name的所有位置使用该名称,而不是oIndlid,然后查看是否有帮助。

出现了大量语法错误,但请尝试此方法

 FROM   (ASTDTA.OEINDLID                                      
INNER JOIN ASTDTA.ICPRTMIA ON OEINDLID.IDPRT#=ICPRTMIA.IAPRT#)
注意,我去掉了连接上的括号。让优化器完成它的工作

CREATE or REPLACE VIEW astccdta.acsusage  AS                                     
  SELECT M.IARCC9
       , D.IDDOCD, D.IDCOM#           
       , A.ADSFX#
       , D.IDPRT#, D.IDGRC#, D.IDENT# 
       , D.IDSFX#, D.IDPRLC, D.IDNTU$, D.IDSHP# 
       , A.ADFNM, A.ADLNM
       , H.IHVIAC
       , A.ADSTTC   
       , OEINDLID.IDINV#
       ,(SELECT SUM (T.IDNTU$)                                                
           FROM ASTDTA.OEINDLID AS T                                             
           WHERE T.IDCOM# = '001'                                           
             AND T.IDDOCD = D.IDDOCD
             AND T.IDINV# = D.IDINV#                                 
             AND T.IDPRLC LIKE 'F%'                                            
        )
    FROM ASTDTA.OEINDLID AS D                                     
    JOIN ASTDTA.ICPRTMIA AS M   ON D.IDPRT# = M.IAPRT#
    JOIN ASTTRN.OEINHDIH AS H   ON D.IDIDC# = H.IHIDC#
    JOIN ASTDTA.ADRESSAD AS A   ON A.ADENT# = H.IHENT#
    WHERE  M.IARCC9 = 'ACS'                                 
      AND  D.IDCOM# = '001'                                         
      AND  D.IDPRT# LIKE 'ACS%'