无法通过shell脚本执行sql脚本

时间:2013-06-21 15:42:38

标签: sql database oracle unix

您好我正在尝试通过shell脚本执行SQL脚本。但它给了我一个错误,但是当我在sql developer编辑器中复制粘贴相同的东西时它运行正常。为什么会这样?

下面是我正在执行的声明:

sqlplus -L cimkroger/*******@orcl @CreateViewFinal12.sql

在此之前,我已经执行了一个脚本来执行选择的东西,它适合我。在这我创建视图。那可能是什么原因。下面是CreateViewFinal12.sql脚本。请提供帮助。在此先感谢!!

/*

Run the query to get the Relationship catalogID, Replace the Oraganization name 'yak' with your Oraganization name 
select * from relationshipdefinition where organizationid=(Select id from organization where name='yak') and active='Y' and name like '%USER'

Replace "136209" with your "USER" CATALOGID                                                         136209  Occur=11= 340,276,212,148,84,336,272,208,144,80

Replace "136220" with your "CLASS_CLASS_HAS_USER" CATALOGID         d                               136220  Occur=2=70

Replace "136152" with your "CLASS" CATALOGID                                                        136152  Occur=3=92,88

Replace "136248" with your "SUBCLASS_SUBCLASS_HAS_USER" CATALOGID   d                           136248  Occur=2=134

Replace "136196" with your "SUBCLASS" CATALOGID                                                     136196  Occur=3=156,152

Replace "136227" with your "DEPARTMENT_DEPARTMENT_HAS_USER" CATALOGID   d                           136227  Occur=2=198

Replace "136163" with your "DEPARTMENT" CATALOGID                                                   136163  Occur=3=220,216

Replace "136234" with your "PRIMARY_DEPARTMENT_PRIMARY_DEPARTMENT_HAS_USER" CATALOGID   d           136234  Occur=2=262

Replace "136174" with your "PRIMARY_DEPARTMENT" CATALOGID                                           136174  Occur=3=284,280

Replace "136241" with your "RECAP_DEPARTMENT_RECAP_DEPARTMENT_HAS_USER" CATALOGID       d           136241  Occur=2=326

Replace "136185" with your "RECAP_DEPARTMENT" CATALOGID                                             136185  Occur=3=348,344

Replace "135910" with your "SOURCEORGANIZATIONID"                                                   135910  Occur=6=331,267,203,139,75

*/


grant all prvileges to cimkroger;

CREATE OR REPLACE FORCE VIEW "212016" ("CATALOGNAME", "CLASS_PRODUCTID", "CLASS_PRODUCTIDEXT", "SUBCLASS_PRODUCTID", "SUBCLASS_PRODUCTIDEXT", "DEPARTMENT_PRODUCTID", "DEPARTMENT_PRODUCTIDEXT", "RECAP_DEPT_PRODUCTID", "RECAP_DEPT_PRODUCTIDEXT", "PRIMARY_DEPT_PRODUCTID", "PRIMARY_DEPT_PRODUCTIDEXT", "RELATIONSHIPNAME", "USERPRODUCTID", "USERPRODUCTIDEXT", "USERNAME", "IS_A_CATEGORYMANAGER", "IS_A_CORPBRANDCSI", "IS_A_CORPORATELOGISTICS", "IS_A_CORPORATE_DIG", "IS_A_ELMS_TEAM", "IS_A_HAZARDMANAGER", "IS_A_KOMPASSMANAGER", "IS_A_LOYALITYMARKETING", "IS_A_MAX_TEAM", "IS_A_PLANOGRAMANALYST", "IS_A_PROCUREMENTMANAGER", "IS_A_RASC", "IS_A_RDIC", "IS_A_RECLAMATIONMANAGER", "IS_A_SHRINK_EAS_TEAM", "IS_A_TAXMANAGER", "IS_A_WICMANAGER", "IS_LEGAL")
                             AS
  SELECT DISTINCT 'CLASS'    AS CATALOGNAME,
    CLASSS.CPRODUCTID        AS CLASS_PRODUCTID ,
    CLASSS.CPRODUCTIDEXT     AS CLASS_PRODUCTIDEXT,
    NULL                     AS SUBCLASS_PRODUCTID,
    NULL                     AS SUBCLASS_PRODUCTIDEXT ,
    NULL                     AS DEPARTMENT_PRODUCTID ,
    NULL                     AS DEPARTMENT_PRODUCTIDEXT,
    NULL                     AS RECAP_DEPT_PRODUCTID ,
    NULL                     AS RECAP_DEPT_PRODUCTIDEXT,
    NULL                     AS PRIMARY_DEPT_PRODUCTID,
    NULL                     AS PRIMARY_DEPT_PRODUCTIDEXT ,
    'CLASS_HAS_USER'         AS RELATIONSHIPNAME,
    USERR.CPRODUCTID         AS USERPRODUCTID,
    USERR.CPRODUCTIDEXT      AS USERPRODUCTIDEXT,
    USERR.CFIRSTNAME         AS USERNAME,
    upper(CIS_A_CATEGORYMANAGER)    AS IS_A_CATEGORYMANAGER,
    upper(CIS_A_CORPBRANDCSI)       AS IS_A_CORPBRANDCSI,
    upper(CIS_A_CORPORATELOGISTICS) AS IS_A_CORPORATELOGISTICS,
    upper(CIS_A_CORPORATE_DIG)      AS IS_A_CORPORATE_DIG,
    upper(CIS_A_ELMS_TEAM)          AS IS_A_ELMS_TEAM,
    upper(CIS_A_HAZARDMANAGER)      AS IS_A_HAZARDMANAGER,
    upper(CIS_A_KOMPASSMANAGER)     AS IS_A_KOMPASSMANAGER,
    upper(CIS_A_LOYALITYMARKETING)  AS IS_A_LOYALITYMARKETING,
    upper(CIS_A_MAX_TEAM)           AS IS_A_MAX_TEAM,
    upper(CIS_A_PLANOGRAMANALYST)   AS IS_A_PLANOGRAMANALYST,
    upper(CIS_A_PROCUREMENTMANAGER) AS IS_A_PROCUREMENTMANAGER,
    upper(CIS_A_RASC)               AS IS_A_RASC,
    upper(CIS_A_RDIC)               AS IS_A_RDIC,
    upper(CIS_A_RECLAMATIONMANAGER) AS IS_A_RECLAMATIONMANAGER,
    upper(CIS_A_SHRINK_EAS_TEAM)    AS IS_A_SHRINK_EAS_TEAM,
    upper(CIS_A_TAXMANAGER)         AS IS_A_TAXMANAGER,
    upper(CIS_A_WICMANAGER)         AS IS_A_WICMANAGER,
    upper(CIS_LEGAL)                AS IS_LEGAL
  FROM RELATIONSHIP REL
  JOIN
    --CLASS_CLASS_HAS_USER CATALOG id
    RCT_136220 RCT
  ON REL.RELATIONID=RCT.CRELATIONID
  AND TYPE         =
    (SELECT TYPE
    FROM RELATIONSHIPDEFINITION
    WHERE ORGANIZATIONID=135910
    AND NAME            ='CLASS_HAS_USER'
    AND ACTIVE          ='Y'
    )
    --USER CATALOG
  JOIN MCT_136209 USERR
  ON USERR.CPRODUCTKEYID=REL.CHILDID
  AND USERR.CMODVERSION =REL.CHILDVERSION
  JOIN GOLDENCOPY USERGC
  ON USERGC.CATALOGID  =136209
  AND USERGC.PRODUCTKEY=USERR.CPRODUCTKEYID
  AND USERGC.VERSION   =USERR.CMODVERSION
    -- CLAS CATALOG
  JOIN MCT_136152 CLASSS
  ON CLASSS.CPRODUCTKEYID=REL.PARENTID
  AND CLASSS.CMODVERSION =REL.PARENTVERSION
  JOIN GOLDENCOPY GC
  ON GC.CATALOGID  =136152
  AND GC.PRODUCTKEY=CLASSS.CPRODUCTKEYID
  AND GC.VERSION   =CLASSS.CMODVERSION
  UNION

  /* fetch data from subclass */
  SELECT DISTINCT 'SUBCLASS' AS CATALOGNAME,
    NULL                     AS CLASS_PRODUCTID ,
    NULL                     AS CLASS_PRODUCTIDEXT,
    SUBCLASSS.CPRODUCTID     AS SUBCLASS_PRODUCTID,
    SUBCLASSS.CPRODUCTIDEXT  AS SUBCLASS_PRODUCTIDEXT ,
    NULL                     AS DEPARTMENT_PRODUCTID ,
    NULL                     AS DEPARTMENT_PRODUCTIDEXT,
    NULL                     AS RECAP_DEPT_PRODUCTID ,
    NULL                     AS RECAP_DEPT_PRODUCTIDEXT,
    NULL                     AS PRIMARY_DEPT_PRODUCTID,
    NULL                     AS PRIMARY_DEPT_PRODUCTIDEXT ,
    'SUBCLASS_HAS_USER'      AS RELATIONSHIPNAME,
    USERR.CPRODUCTID         AS USERPRODUCTID,
    USERR.CPRODUCTIDEXT      AS USERPRODUCTIDEXT,
    USERR.CFIRSTNAME         AS USERNAME,
    upper(CIS_A_CATEGORYMANAGER)    AS IS_A_CATEGORYMANAGER,
    upper(CIS_A_CORPBRANDCSI)       AS IS_A_CORPBRANDCSI,
    upper(CIS_A_CORPORATELOGISTICS) AS IS_A_CORPORATELOGISTICS,
    upper(CIS_A_CORPORATE_DIG)      AS IS_A_CORPORATE_DIG,
    upper(CIS_A_ELMS_TEAM)          AS IS_A_ELMS_TEAM,
    upper(CIS_A_HAZARDMANAGER)      AS IS_A_HAZARDMANAGER,
    upper(CIS_A_KOMPASSMANAGER)     AS IS_A_KOMPASSMANAGER,
    upper(CIS_A_LOYALITYMARKETING)  AS IS_A_LOYALITYMARKETING,
    upper(CIS_A_MAX_TEAM)           AS IS_A_MAX_TEAM,
    upper(CIS_A_PLANOGRAMANALYST)   AS IS_A_PLANOGRAMANALYST,
    upper(CIS_A_PROCUREMENTMANAGER) AS IS_A_PROCUREMENTMANAGER,
    upper(CIS_A_RASC)               AS IS_A_RASC,
    upper(CIS_A_RDIC)               AS IS_A_RDIC,
    upper(CIS_A_RECLAMATIONMANAGER) AS IS_A_RECLAMATIONMANAGER,
    upper(CIS_A_SHRINK_EAS_TEAM)    AS IS_A_SHRINK_EAS_TEAM,
    upper(CIS_A_TAXMANAGER)         AS IS_A_TAXMANAGER,
    upper(CIS_A_WICMANAGER)         AS IS_A_WICMANAGER,
    upper(CIS_LEGAL)                AS IS_LEGAL
  FROM RELATIONSHIP REL
  JOIN
    --SUBCLASS_SUBCLASS_HAS_USER id
    RCT_136248 RCT
  ON REL.RELATIONID=RCT.CRELATIONID
  AND TYPE         =
    (SELECT TYPE
    FROM RELATIONSHIPDEFINITION
    WHERE ORGANIZATIONID=135910
    AND NAME            ='SUBCLASS_HAS_USER'
    AND ACTIVE          ='Y'
    )
    --USER CATALOG
  JOIN MCT_136209 USERR
  ON USERR.CPRODUCTKEYID=REL.CHILDID
  AND USERR.CMODVERSION =REL.CHILDVERSION
  JOIN GOLDENCOPY USERGC
  ON USERGC.CATALOGID  =136209
  AND USERGC.PRODUCTKEY=USERR.CPRODUCTKEYID
  AND USERGC.VERSION   =USERR.CMODVERSION
    -- SUBCLAS CATALOG
  JOIN MCT_136196 SUBCLASSS
  ON SUBCLASSS.CPRODUCTKEYID=REL.PARENTID
  AND SUBCLASSS.CMODVERSION =REL.PARENTVERSION
  JOIN GOLDENCOPY GC
  ON GC.CATALOGID  =136196
  AND GC.PRODUCTKEY=SUBCLASSS.CPRODUCTKEYID
  AND GC.VERSION   =SUBCLASSS.CMODVERSION
  UNION

  /*DEPARTMENT */
  SELECT DISTINCT 'DEPARTMENT' AS CATALOGNAME,
    NULL                       AS CLASS_PRODUCTID ,
    NULL                       AS CLASS_PRODUCTIDEXT,
    NULL                       AS SUBCLASS_PRODUCTID,
    NULL                       AS SUBCLASS_PRODUCTIDEXT ,
    DEPARTMENT.CPRODUCTID      AS DEPARTMENT_PRODUCTID ,
    DEPARTMENT.CPRODUCTIDEXT   AS DEPARTMENT_PRODUCTIDEXT,
    NULL                       AS RECAP_DEPT_PRODUCTID ,
    NULL                       AS RECAP_DEPT_PRODUCTIDEXT,
    NULL                       AS PRIMARY_DEPT_PRODUCTID,
    NULL                       AS PRIMARY_DEPT_PRODUCTIDEXT ,
    'DEPARTMENT_HAS_USER'      AS RELATIONSHIPNAME,
    USERR.CPRODUCTID           AS USERPRODUCTID,
    USERR.CPRODUCTIDEXT        AS USERPRODUCTIDEXT,
    USERR.CFIRSTNAME           AS USERNAME,
    upper(CIS_A_CATEGORYMANAGER)      AS IS_A_CATEGORYMANAGER,
    upper(CIS_A_CORPBRANDCSI)         AS IS_A_CORPBRANDCSI,
    upper(CIS_A_CORPORATELOGISTICS)   AS IS_A_CORPORATELOGISTICS,
    upper(CIS_A_CORPORATE_DIG)        AS IS_A_CORPORATE_DIG,
    upper(CIS_A_ELMS_TEAM)            AS IS_A_ELMS_TEAM,
    upper(CIS_A_HAZARDMANAGER)        AS IS_A_HAZARDMANAGER,
    upper(CIS_A_KOMPASSMANAGER)       AS IS_A_KOMPASSMANAGER,
    upper(CIS_A_LOYALITYMARKETING)    AS IS_A_LOYALITYMARKETING,
    upper(CIS_A_MAX_TEAM)             AS IS_A_MAX_TEAM,
    upper(CIS_A_PLANOGRAMANALYST)     AS IS_A_PLANOGRAMANALYST,
    upper(CIS_A_PROCUREMENTMANAGER)   AS IS_A_PROCUREMENTMANAGER,
    upper(CIS_A_RASC)                 AS IS_A_RASC,
    upper(CIS_A_RDIC)                 AS IS_A_RDIC,
    upper(CIS_A_RECLAMATIONMANAGER)   AS IS_A_RECLAMATIONMANAGER,
    upper(CIS_A_SHRINK_EAS_TEAM)      AS IS_A_SHRINK_EAS_TEAM,
    upper(CIS_A_TAXMANAGER)           AS IS_A_TAXMANAGER,
    upper(CIS_A_WICMANAGER)           AS IS_A_WICMANAGER,
    upper(CIS_LEGAL)                  AS IS_LEGAL
  FROM RELATIONSHIP REL
  JOIN
    --DEPARTMENT_DEPARTMENT_HAS_USER id
    RCT_136227 RCT
  ON REL.RELATIONID=RCT.CRELATIONID
  AND TYPE         =
    (SELECT TYPE
    FROM RELATIONSHIPDEFINITION
    WHERE ORGANIZATIONID=135910
    AND NAME            ='DEPARTMENT_HAS_USER'
    AND ACTIVE          ='Y'
    )
    --USER CATALOG
  JOIN MCT_136209 USERR
  ON USERR.CPRODUCTKEYID=REL.CHILDID
  AND USERR.CMODVERSION =REL.CHILDVERSION
  JOIN GOLDENCOPY USERGC
  ON USERGC.CATALOGID  =136209
  AND USERGC.PRODUCTKEY=USERR.CPRODUCTKEYID
  AND USERGC.VERSION   =USERR.CMODVERSION
    -- DEPARTMENT CATALOG
  JOIN MCT_136163 DEPARTMENT
  ON DEPARTMENT.CPRODUCTKEYID=REL.PARENTID
  AND DEPARTMENT.CMODVERSION =REL.PARENTVERSION
  JOIN GOLDENCOPY GC
  ON GC.CATALOGID  =136163
  AND GC.PRODUCTKEY=DEPARTMENT.CPRODUCTKEYID
  AND GC.VERSION   =DEPARTMENT.CMODVERSION
  UNION

  /* PRIMARY_DEPARTMENT_HAS_USER */
  SELECT DISTINCT 'PRIMARY_DEPARTMENT' AS CATALOGNAME,
    NULL                               AS CLASS_PRODUCTID ,
    NULL                               AS CLASS_PRODUCTIDEXT,
    NULL                               AS SUBCLASS_PRODUCTID,
    NULL                               AS SUBCLASS_PRODUCTIDEXT ,
    NULL                               AS PDEPARTMENT_PRODUCTID ,
    NULL                               AS PDEPARTMENT_PRODUCTIDEXT,
    NULL                               AS RECAP_DEPT_PRODUCTID ,
    NULL                               AS RECAP_DEPT_PRODUCTIDEXT,
    PDEPARTMENT.CPRODUCTID             AS PRIMARY_DEPT_PRODUCTID,
    PDEPARTMENT.CPRODUCTIDEXT          AS PRIMARY_DEPT_PRODUCTIDEXT ,
    'PRIMARY_DEPARTMENT_HAS_USER'      AS RELATIONSHIPNAME,
    USERR.CPRODUCTID                   AS USERPRODUCTID,
    USERR.CPRODUCTIDEXT                AS USERPRODUCTIDEXT,
    USERR.CFIRSTNAME                   AS USERNAME,
    upper(CIS_A_CATEGORYMANAGER)              AS IS_A_CATEGORYMANAGER,
    upper(CIS_A_CORPBRANDCSI)                 AS IS_A_CORPBRANDCSI,
    upper(CIS_A_CORPORATELOGISTICS)           AS IS_A_CORPORATELOGISTICS,
    upper(CIS_A_CORPORATE_DIG)                AS IS_A_CORPORATE_DIG,
    upper(CIS_A_ELMS_TEAM)                    AS IS_A_ELMS_TEAM,
    upper(CIS_A_HAZARDMANAGER)                AS IS_A_HAZARDMANAGER,
    upper(CIS_A_KOMPASSMANAGER)               AS IS_A_KOMPASSMANAGER,
    upper(CIS_A_LOYALITYMARKETING)            AS IS_A_LOYALITYMARKETING,
    upper(CIS_A_MAX_TEAM)                     AS IS_A_MAX_TEAM,
    upper(CIS_A_PLANOGRAMANALYST)             AS IS_A_PLANOGRAMANALYST,
    upper(CIS_A_PROCUREMENTMANAGER)           AS IS_A_PROCUREMENTMANAGER,
    upper(CIS_A_RASC)                         AS IS_A_RASC,
    upper(CIS_A_RDIC)                         AS IS_A_RDIC,
    upper(CIS_A_RECLAMATIONMANAGER)           AS IS_A_RECLAMATIONMANAGER,
    upper(CIS_A_SHRINK_EAS_TEAM)              AS IS_A_SHRINK_EAS_TEAM,
    upper(CIS_A_TAXMANAGER)                   AS IS_A_TAXMANAGER,
    upper(CIS_A_WICMANAGER)                   AS IS_A_WICMANAGER,
    upper(CIS_LEGAL)                          AS IS_LEGAL
  FROM RELATIONSHIP REL
  JOIN
    --PRIMARY_DEPARTMENT_PRIMARY_DEPARTMENT_HAS_USERID
    RCT_136234 RCT
  ON REL.RELATIONID=RCT.CRELATIONID
  AND TYPE         =
    (SELECT TYPE
    FROM RELATIONSHIPDEFINITION
    WHERE ORGANIZATIONID=135910
    AND NAME            ='PRIMARY_DEPARTMENT_HAS_USER'
    AND ACTIVE          ='Y'
    )
    --USER CATALOG
  JOIN MCT_136209 USERR
  ON USERR.CPRODUCTKEYID=REL.CHILDID
  AND USERR.CMODVERSION =REL.CHILDVERSION
  JOIN GOLDENCOPY USERGC
  ON USERGC.CATALOGID  =136209
  AND USERGC.PRODUCTKEY=USERR.CPRODUCTKEYID
  AND USERGC.VERSION   =USERR.CMODVERSION
    -- PRIMARY_DEPARTMENT CATALOG
  JOIN MCT_136174 PDEPARTMENT
  ON PDEPARTMENT.CPRODUCTKEYID=REL.PARENTID
  AND PDEPARTMENT.CMODVERSION =REL.PARENTVERSION
  JOIN GOLDENCOPY GC
  ON GC.CATALOGID  =136174
  AND GC.PRODUCTKEY=PDEPARTMENT.CPRODUCTKEYID
  AND GC.VERSION   =PDEPARTMENT.CMODVERSION
  UNION

  /* RECAP_DEPARTMENT_HAS_USER */
  SELECT DISTINCT 'RECAP_DEPARTMENT' AS CATALOGNAME,
    NULL                             AS CLASS_PRODUCTID ,
    NULL                             AS CLASS_PRODUCTIDEXT,
    NULL                             AS SUBCLASS_PRODUCTID,
    NULL                             AS SUBCLASS_PRODUCTIDEXT ,
    NULL                             AS RDEPARTMENT_PRODUCTID ,
    NULL                             AS RDEPARTMENT_PRODUCTIDEXT,
    RDEPARTMENT.CPRODUCTID           AS RECAP_DEPT_PRODUCTID ,
    RDEPARTMENT.CPRODUCTIDEXT        AS RECAP_DEPT_PRODUCTIDEXT,
    NULL                             AS PRIMARY_DEPT_PRODUCTID,
    NULL                             AS PRIMARY_DEPT_PRODUCTIDEXT ,
    'RECAP_DEPARTMENT_HAS_USER'      AS RELATIONSHIPNAME,
    USERR.CPRODUCTID                 AS USERPRODUCTID,
    USERR.CPRODUCTIDEXT              AS USERPRODUCTIDEXT,
    USERR.CFIRSTNAME                 AS USERNAME,
    upper(CIS_A_CATEGORYMANAGER)            AS IS_A_CATEGORYMANAGER,
    upper(CIS_A_CORPBRANDCSI)               AS IS_A_CORPBRANDCSI,
    upper(CIS_A_CORPORATELOGISTICS)         AS IS_A_CORPORATELOGISTICS,
    upper(CIS_A_CORPORATE_DIG)              AS IS_A_CORPORATE_DIG,
    upper(CIS_A_ELMS_TEAM)                  AS IS_A_ELMS_TEAM,
    upper(CIS_A_HAZARDMANAGER)              AS IS_A_HAZARDMANAGER,
    upper(CIS_A_KOMPASSMANAGER)             AS IS_A_KOMPASSMANAGER,
    upper(CIS_A_LOYALITYMARKETING)          AS IS_A_LOYALITYMARKETING,
    upper(CIS_A_MAX_TEAM)                   AS IS_A_MAX_TEAM,
    upper(CIS_A_PLANOGRAMANALYST)           AS IS_A_PLANOGRAMANALYST,
    upper(CIS_A_PROCUREMENTMANAGER)         AS IS_A_PROCUREMENTMANAGER,
    upper(CIS_A_RASC)                       AS IS_A_RASC,
    upper(CIS_A_RDIC)                       AS IS_A_RDIC,
    upper(CIS_A_RECLAMATIONMANAGER)         AS IS_A_RECLAMATIONMANAGER,
    upper(CIS_A_SHRINK_EAS_TEAM)            AS IS_A_SHRINK_EAS_TEAM,
    upper(CIS_A_TAXMANAGER)                 AS IS_A_TAXMANAGER,
    upper(CIS_A_WICMANAGER)                 AS IS_A_WICMANAGER,
    upper(CIS_LEGAL)                        AS IS_LEGAL
  FROM RELATIONSHIP REL
  JOIN
    --RECAP_DEPARTMENT_HAS_USER id
    RCT_136241 RCT
  ON REL.RELATIONID=RCT.CRELATIONID
  AND TYPE         =
    (SELECT TYPE
    FROM RELATIONSHIPDEFINITION
    WHERE ORGANIZATIONID=135910
    AND NAME            ='RECAP_DEPARTMENT_HAS_USER'
    AND ACTIVE          ='Y'
    )
    --USER CATALOG
  JOIN MCT_136209 USERR
  ON USERR.CPRODUCTKEYID=REL.CHILDID
  AND USERR.CMODVERSION =REL.CHILDVERSION
  JOIN GOLDENCOPY USERGC
  ON USERGC.CATALOGID  =136209
  AND USERGC.PRODUCTKEY=USERR.CPRODUCTKEYID
  AND USERGC.VERSION   =USERR.CMODVERSION
    -- RECAP_DEPARTMENT CATALOG
  JOIN MCT_136185 RDEPARTMENT
  ON RDEPARTMENT.CPRODUCTKEYID=REL.PARENTID
  AND RDEPARTMENT.CMODVERSION =REL.PARENTVERSION
  JOIN GOLDENCOPY GC
  ON GC.CATALOGID  =136185
  AND GC.PRODUCTKEY=RDEPARTMENT.CPRODUCTKEYID
  AND GC.VERSION   =RDEPARTMENT.CMODVERSION;

它给了我错误(我知道这是会话或授予访问权限的问题。我无法做那些事情。想要建议)

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SP2-0734: unknown command beginning "sqlplus ci..." - rest of line ignored.
  UNION
      *
ERROR at line 62:
ORA-00928: missing SELECT keyword



no rows selected

SQL>

2 个答案:

答案 0 :(得分:0)

似乎你在文件中有'特殊',可能是窗口,字符。在执行sqlplus之前,尝试从输入文件中删除所有“特殊”不可打印字符(即使用notepad ++)。

答案 1 :(得分:0)

默认情况下,SQL * Plus treats a blank line as the end of the statement

  

SQL语句或脚本中的空行告诉SQL * Plus您有   完成输入命令,但不想再运行它。

您的声明部分如下:

...
AND GC.VERSION =SUBCLASSS.CMODVERSION
UNION

/*DEPARTMENT */
SELECT DISTINCT 'DEPARTMENT' AS CATALOGNAME,
...

空白行被视为语句的结尾,而/来自/*评论标记,位于下一行runs that command;它给你ORA-00928,因为它在联合之后期望select(它将会看到,但作为单独命令的开始)。

只有声明的最后一部分(RECAP_DEPARTMENT_HAS_USER注释)才会正确执行,而这会给你no rows returned。目前还不清楚第一个SP2-0734错误来自哪里;在您展示的内容之前,这看起来像是在您的脚本中进行了额外的sqlplus调用。

您可以通过在脚本开头添加set sqlblanklines on来删除空白行,或更改SQL * Plus对待它们的方式。

至少在声明中使用--注释表示法也可能有助于避免混淆,尽管两者通常都是允许的。