您好我正在尝试通过 shell 脚本执行 SQL 脚本。但这给了我一个错误,但是当我在 sql 开发人员编辑器中复制粘贴相同的内容时,它运行正常。为什么会这样?
以下是我正在执行的语句:
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>