日期:2014-05-16  浏览次数:21247 次

导入视图时,报错, ORA-00933:SQL命令未正确结束
代码如下
create or replace view final_chief_diagnosis as
select
patient_id,
visit_id,
diagnosis_no,
diagnosis_desc,
diagnosis_date,
treat_days,
treat_result,
oper_treat_indicator
from diagnosis
where diagnosis_type='3' and diagnosis_no='1'

create or replace view v_emr_qc_patient_operation as
select PATIENT_ID,VISIT_ID,COUNT(OPERATION_NO) AS OPERATION_COUNTS
  from OPERATION
  GROUP BY PATIENT_ID,VISIT_ID

CREATE OR REPLACE VIEW V_EMR_QC_MTD_PATIENT AS
SELECT a.PATIENT_ID,
  a.INP_NO,
  a.NAME,
  a.SEX,
  a.DATE_OF_BIRTH,
  b.VISIT_ID,
  b.CHARGE_TYPE,
  b.ADMISSION_DATE_TIME,
  b.DISCHARGE_DATE_TIME,
  c.STATUS,
  c.REQUEST_DOCTOR_ID,
  c.REQUEST_DATE_TIME,
  c.PARENT_DOCTOR_ID,
  c.SUPER_DOCTOR_ID,
  d.WARD_CODE,
  d.DEPT_CODE,
  d.BED_NO,
  d.ADM_WARD_DATE_TIME,
  d.NURSING_CLASS,
  d.PATIENT_CONDITION,
  d.DIAGNOSIS,
  '' as AGE,
  '' as BED_LABEL,
  0 as InHospitalDays,
  0 as CommitMrDays,
  0 as DischargeDays,
  b.DEPT_DISCHARGE_FROM,
  e.OPERATION_COUNTS,
  b.MTD_VALUE
  FROM PAT_MASTER_INDEX a, PAT_VISIT b, MR_ON_LINE c, PATS_IN_HOSPITAL d,V_EMR_QC_PATIENT_OPERATION e
 WHERE (a.PATIENT_ID = b.PATIENT_ID)
  AND (b.PATIENT_ID = c.PATIENT_ID)
  AND (b.VISIT_ID = c.VISIT_ID)
  AND (b.PATIENT_ID = d.PATIENT_ID)
  AND (b.VISIT_ID = d.VISIT_ID)
  AND (b.PATIENT_ID = e.PATIENT_ID(+))
  AND (b.VISIT_ID = e.VISIT_ID(+))
  AND (c.STATUS = '0');

CREATE OR REPLACE VIEW V_EMR_QC_PATIENT AS
SELECT a.PATIENT_ID,
  a.INP_NO,
  a.NAME,
  a.SEX,
  a.DATE_OF_BIRTH,
  b.VISIT_ID,
  b.CHARGE_TYPE,
  b.ADMISSION_DATE_TIME,
  b.DISCHARGE_DATE_TIME,
  c.STATUS,
  c.REQUEST_DOCTOR_ID,
  c.REQUEST_DATE_TIME,
  c.PARENT_DOCTOR_ID,
  c.SUPER_DOCTOR_ID,
  d.WARD_CODE,
  d.DEPT_CODE,
  d.BED_NO,
  d.ADM_WARD_DATE_TIME,
  d.NURSING_CLASS,
  d.PATIENT_CONDITION,
  d.DIAGNOSIS,
  '' as AGE,
  '' as BED_LABEL,
  0 as InHospitalDays,
  0 as CommitMrDays,
  0 as DischargeDays,
  b.DEPT_DISCHARGE_FROM,
  e.OPERATION_COUNTS
  FROM PAT_MASTER_INDEX a, PAT_VISIT b, MR_ON_LINE c, PATS_IN_HOSPITAL d,V_EMR_QC_PATIENT_OPERATION e
 WHERE (a.PATIENT_ID = b.PATIENT_ID)
  AND (b.PATIENT_ID = c.PATIENT_ID)
  AND (b.VISIT_ID = c.VISIT_ID)
  AND (b.PATIENT_ID = d.PATIENT_ID(+))
  AND (b.VISIT_ID = d.VISIT_ID(+))
  AND (b.PATIENT_ID = e.PATIENT_ID(+))
  AND (b.VISIT_ID = e.VISIT_ID(+))
  AND (c.STATUS = '0')



------解决方案--------------------
ORA-00933 SQL command not properly ended

Cause: The SQL statement ends with an inappropriate clause. For example, an ORDER BY clause may have been included in a CREATE VIEW or INSERT statement. ORDER BY cannot be used to create an ordered view or to insert in a certain order.

Action: Correct the syntax by removing the