我收到错误:PLS-00402:游标的SELECT列表中需要别名,以避免重复的列名称

时间:2012-12-11 11:17:12

标签: oracle10g

  

我已经使用select数据舞会不同的表创建了这个过程   并将其填充到一个表中。我收到错误:“PLS-00402:别名   在SELECT游标列表中需要避免重复的列名“   在编写代码时

create or replace procedure hrps.Employeeall
    is
    cursor EMA_FILL_EMPL_ALL
    IS 
     SELECT  DISTINCT base.eme_perno " EMPL BASE PNO",
             CAR.CAR_COMP_CD "COMP CODE",
             PER.EPR_SALUTATION,
             PER.EPR_FST_NAME,
             PER.EPR_MID_NAME,
             PER.EPR_LST_NAME,
             TRIM(per.EPR_SALUTATION) || ' '||TRIM(per.EPR_FST_NAME) || ' ' || TRIM(per.EPR_MID_NAME) || ' ' || TRIM(per.EPR_LST_NAME) "Name",
             BASE.EME_DOB,
             per.epr_gender "GENDER",
             NULL z1,
             PER.EPR_DIFF_ABLE,
             PER.EPR_DIFF_ABLE_DESC,
             BASE.EME_BLOOD_GRP,
             PER.EPR_AFF_ACT,
             DOJ.idt_dt,
             BASE.EME_CADRE,
             C3.IRC_DESC cd3,
             car.car_emp_class,
             CAR.CAR_EMP_TYP,
             BASE.EME_EMPL_STATUS,
             BASE.EME_SOURCE_EMPLMNT,
             CAR.CAR_PYRL,
             PYRL.IPY_PYRL_DESC,
             car.car_dept_cd "DEPT CODE",
             org_dept.oro_desc "DEPT DESC", 
             car.car_sec_cd "SECTION CODE",
             org_sec.oro_desc "SECTION DESC",
             car.car_desgn_cd "DESGN CODE",
             DES.IDS_DESGN_DESC "DESGN DESC",
             CAR.CAR_PER_GRADE_CD,
             CAR.CAR_SUB_GRADE_CD,
             NULL z2,
             NULL z3,
             NULL z4,
             NULL z5,
             CAR.CAR_PYRL_AREA,
             C1.IRC_DESC cd1,
             CAR.CAR_COST_CENT_CD,
             C2.IRC_DESC cd2,
             NULL z6,
             NULL z7,
             DOS.IDT_DT,
             CAR_SEP.CAR_ACTION_RSN,
             C4.IRC_DESC cd4,
             PDT.IDT_DT,
             EDR.IDT_DT,
             NULL z8,
             PROM.IDT_DT,
             INC.IDT_DT,
             NULL z9,
             NULL z10,
             C5.IRC_DESC cd5,
             car.car_exec_cd "EXEC HEAD",
             org_exe.oro_desc "EXEC HEAD DESC",
             car.car_grp_cd "GROUP CODE",
             org_grp.oro_desc "GROUP DESC",
             car.car_pu_cd " PU CODE",
             org_pu.idp_pu_desc "PU DESC",
             car.car_position_id "POSITION ID",
             NULL z11,
             NULL z12,
             NULL z13,
             NULL z14,
             FATHER.FML_FSTNAME || ' ' || FATHER.FML_MIDNAME || ' ' || FATHER.FML_LSTNAME F_NAME,
             SPOUCE.FML_FSTNAME || ' ' || SPOUCE.FML_MIDNAME || ' ' || SPOUCE.FML_LSTNAME S_NAME,
             TRGSD.IDT_DT,
             TRGED.IDT_DT,
             NULL z15,
             NULL z16,
             NULL z17,
             NULL z18,
             PAN.EID_ID,
             PHONE.EMC_CONTACT,
             EMAIL.EMC_CONTACT,
             PER.EPR_RELIGION,
             PER.EPR_NATIVE_STATE,
             PER.EPR_NATIONALITY,
             NULL z19,
             NULL  z20,
             NULL  z21,
             SYSDATE date1,
             '157068' num1,
             SYSDATE date2,
             '157068' num2
        fROM t_empl_base base
             LEFT OUTER JOIN 
             t_ir_em_career_dtls car
             ON base.eme_perno = car.car_eme_perno
             AND car.car_end_dt = '31-dec-9999'

             LEFT OUTER JOIN 
             t_ir_em_career_dtls car_SEP
             ON base.eme_perno = car_SEP.car_eme_perno
             AND CAR_SEP.CAR_ACTION_TYPE ='SP'

             LEFT OUTER JOIN
             t_ir_em_personal per
             ON base.eme_perno = per.epr_eme_perno 
             AND per.epr_end_dt = '31-dec-9999'

             LEFT OUTER JOIN
             T_IR_DESGN DES
             ON DES.IDS_DESGN_CODE= CAR.CAR_DESGN_CD
             AND DES.IDS_LOCATION = CAR.CAR_LOC_CD
             AND DES.IDS_END_DT='31-DEC-9999'

             LEFT OUTER JOIN
             t_ir_em_impdt pdt
             ON base.eme_perno = pdt.idt_eme_perno 
             AND pdt.idt_type = '03'

             LEFT OUTER JOIN
             t_ir_em_impdt DOJ
             ON base.eme_perno = DOJ.idt_eme_perno 
             AND DOJ.idt_type = '02'

             LEFT OUTER JOIN
             t_ir_em_impdt DOS
             ON base.eme_perno = DOS.idt_eme_perno 
             AND DOS.idt_type = '04'

             LEFT OUTER JOIN
             t_ir_em_impdt EDR
             ON base.eme_perno = EDR.idt_eme_perno 
             AND EDR.idt_type = '07'

             LEFT OUTER JOIN
             t_ir_em_impdt PROM
             ON base.eme_perno = PROM.idt_eme_perno 
             AND PROM.idt_type = '08'

             LEFT OUTER JOIN
             t_ir_em_impdt INC
             ON base.eme_perno = INC.idt_eme_perno 
             AND INC.idt_type = '09'

             LEFT OUTER JOIN
             t_ir_em_impdt TRGSD
             ON base.eme_perno = TRGSD.idt_eme_perno 
             AND TRGSD.idt_type = '12'

             LEFT OUTER JOIN
             t_ir_em_impdt TRGED
             ON base.eme_perno = TRGSD.idt_eme_perno 
             AND TRGSD.idt_type = '13'

             LEFT OUTER JOIN
             T_IR_EM_FAMILY FATHER
             ON FATHER.FML_EME_PERNO= BASE.EME_PERNO
             AND FATHER.FML_TYPE ='06' 

             LEFT OUTER JOIN
             T_IR_EM_FAMILY SPOUCE
             ON SPOUCE.FML_EME_PERNO= BASE.EME_PERNO
             AND SPOUCE.FML_TYPE IN ('01','02')         

             LEFT OUTER JOIN
             T_IR_PYRL PYRL
             ON CAR.CAR_PYRL = PYRL.IPY_PYRL_NO
             AND PYRL.IPY_END_DATE = '31-DEC-9999'
             AND PYRL.IPY_LOCN_CD = CAR.CAR_LOC_CD
             AND PYRL.IPY_VALID_TAG ='Y'

             LEFT OUTER JOIN
             t_ir_codes c2
             ON TRIM (CAR.CAR_COST_CENT_CD ) = c2.irc_code
             AND c2.irc_type = 'COSTC'

             LEFT OUTER JOIN
             t_ir_codes c1
             ON TRIM (CAR.CAR_PYRL_AREA ) = c1.irc_code
             AND c1.irc_type = 'PYARA'

             LEFT OUTER JOIN
             t_ir_codes c3
             ON BASE.EME_CADRE = c3.irc_code
             AND c3.irc_type = 'CADRE'

             LEFT OUTER JOIN
             t_ir_codes c4
             ON CAR_SEP.CAR_ACTION_RSN = c4.irc_code
             AND c4.irc_type = 'SEPAR'

             LEFT OUTER JOIN
             t_ir_codes c5
             ON CAR.CAR_COMP_CD = c5.irc_code
             AND c5.irc_type = 'COMP'

             LEFT OUTER JOIN 
             T_IR_EM_ID PAN
             ON PAN.EID_EME_PERNO=BASE.EME_PERNO
             AND PAN.EID_ID_CODE= '02'

             LEFT OUTER JOIN 
             T_IR_EM_CONTACT PHONE
             ON PHONE.EMC_EME_PERNO =BASE.EME_PERNO
             AND PHONE.EMC_CONTACT_TYPE= '04'
             AND PHONE.EMC_END_DATE='31-DEC-9999'

             LEFT OUTER JOIN 
             T_IR_EM_CONTACT EMAIL
             ON EMAIL.EMC_EME_PERNO =BASE.EME_PERNO
             AND EMAIL.EMC_CONTACT_TYPE= '03'
             AND EMAIL.EMC_END_DATE='31-DEC-9999'


             LEFT OUTER JOIN
             (SELECT DISTINCT oro_object_id, oro_desc
                         FROM t_org_object o
                        WHERE o.oro_str_type = 'IRSTR'
                          AND o.oro_end_date = '31-DEC-9999'
                          AND o.oro_type = 'EX') org_exe
             ON org_exe.oro_object_id = car.car_exec_cd

             LEFT OUTER JOIN
             (SELECT DISTINCT oro_object_id, oro_desc
                         FROM t_org_object o
                        WHERE o.oro_str_type = 'IRSTR'
                          AND o.oro_end_date = '31-DEC-9999'
                          AND o.oro_type = 'GR') org_grp
             ON org_grp.oro_object_id = car.car_grp_cd

             LEFT OUTER JOIN
             (SELECT DISTINCT oro_object_id, oro_desc
                         FROM t_org_object o
                        WHERE o.oro_str_type = 'IRSTR'
                          AND o.oro_end_date = '31-DEC-9999'
                          AND o.oro_type = 'DP') org_dept
             ON org_dept.oro_object_id = car.car_dept_cd

             LEFT OUTER JOIN
             (SELECT DISTINCT oro_object_id, oro_desc
                         FROM t_org_object o
                        WHERE o.oro_str_type = 'IRSTR'
                          AND o.oro_end_date = '31-DEC-9999'
                          AND o.oro_type = 'SE') org_sec
             ON org_sec.oro_object_id = car.car_sec_cd

             LEFT OUTER JOIN
             (SELECT DISTINCT idp_pu_code, idp_pu_desc
                         FROM t_ir_dept_pu o
                        WHERE o.idp_end_dt = '31-DEC-9999') org_pu
             ON org_pu.idp_pu_code = car.car_pu_cd
       WHERE base.eme_empl_status = '1';


     ct  EMA_FILL_EMPL_ALL%ROWTYPE;

    BEGIN

     FOR CT IN EMA_FILL_EMPL_ALL
     LOOP

      INSERT INTO T_EMPL_COMN  (
      EMA_PERNO,
    EMA_COMP_CD,
    EMA_SALUTATION,
    EMA_FST_NAME,
    EMA_MID_NAME,
    EMA_LST_NAME,
    EMA_ENAME,
    EMA_BIRTH_DT,
    EMA_GENDER,
    EMA_MARITAL_STATUS,
    EMA_DIFF_ABLE_CD,
    EMA_DIFF_ABLE_DESC,
    EMA_BLOODGRP,
    EMA_AFFIRMATIVE_ACTION_CD,
    EMA_JOINING_DT,
    EMA_CADRE,
    EMA_CADRE_DESC,
    EMA_EMP_CLASS,
    EMA_EMP_TYPE,
    EMA_EMPL_STATUS,
    EMA_SOURCE_EMPLMNT,
    EMA_PYRL,
    EMA_PYRL_DESC,
    EMA_DEPT_CD,
    EMA_DEPT_DESC,
    EMA_SECTION_CD,
    EMA_SECTION_DESC,
    EMA_DESGN_CD,
    EMA_DESGN_DESC,
    EMA_EMPL_PGRADE,
    EMA_EMPL_SGRADE,
    EMA_PERS_AREA,
    EMA_PERS_AREA_DESC,
    EMA_PERS_SUBAREA,
    EMA_PERS_SUBAREA_DESC,
    EMA_PYRL_AREA,
    EMA_PYRL_AREA_DESC,
    EMA_COST_CENTER_CD,
    EMA_COST_CENTER_DESC,
    EMA_PROFIT_CENTER_CD,
    EMA_PROFIT_CENTER_DESC,
    EMA_DISCH_DT,
    EMA_DISCH_RSN_CD,
    EMA_DISCH_RSN_DESC,
    EMA_CS_DATE,
    EMA_EXP_RETIRE_DT,
    EMA_TRF_DT,
    EMA_PROM_DT,
    EMA_INCR_DT,
    EMA_UNION_IND,
    EMA_UNION_DESC,
    EMA_COMP_DESC,
    EMA_EXEC_HEAD,
    EMA_EXEC_HEAD_DESC,
    EMA_GROUP,
    EMA_GROUP_DESC,
    EMA_PU,
    EMA_PU_DESC,
    EMA_POSITION_ID,
    EMA_REPORTING_TO_PNO,
    EMA_DEPT_HEAD_PNO,
    EMA_PERS_EXEC_PNO,
    EMA_REF_PNO,
    EMA_FATHERS_NAME,
    EMA_SPOUSE_NAME,
    EMA_TRG_ST_DT,
    EMA_TRG_EN_DT,
    EMA_FPF_ACNO,
    EMA_EFBS_IND,
    EMA_BANK_ACNO,
    EMA_BANK_CD,
    EMA_PANNO,
    EMA_PHONE_NO,
    EMA_EMAIL_ID,
    EMA_RELIGION,
    EMA_NATIVE_STATE,
    EMA_NATIONALITY,
    EMA_CHK_HOUSE,
    EMA_WRK_CHK_HOUSE,
    EMA_PYRL_STOP_DATE,
    EMA_ENTRY_DATE,
    EMA_ENTRY_USER,
    EMA_LAST_UPDATE_DATE,
    EMA_LAST_UPDATE_USER
    )

     VALUES( CT.base.eme_perno ,
             CT.CAR.CAR_COMP_CD,
             CT.PER.EPR_SALUTATION,
             CT.PER.EPR_FST_NAME,
             CT.PER.EPR_MID_NAME,
             CT.PER.EPR_LST_NAME,
             CT.HRPS.POP_NAME_FETCH(BASE.EME_PERNO),
             CT.BASE.EME_DOB,
             CT.per.epr_gender,
             NULL,
             CT.PER.EPR_DIFF_ABLE,
             CT.PER.EPR_DIFF_ABLE_DESC,
             CT.BASE.EME_BLOOD_GRP,
             CT.PER.EPR_AFF_ACT,
             CT.DOJ.idt_dt,
             CT.BASE.EME_CADRE,
             CT.C3.IRC_DESC,
             CT.car.car_emp_class,
             CT.CAR.CAR_EMP_TYP,
             CT.BASE.EME_EMPL_STATUS,
             CT.BASE.EME_SOURCE_EMPLMNT,
             CT.CAR.CAR_PYRL,
             CT.PYRL.IPY_PYRL_DESC,
             CT.car.car_dept_cd ,
             CT.org_dept.oro_desc , 
             CT.car.car_sec_cd ,
             CT.org_sec.oro_desc ,
             CT.car.car_desgn_cd ,
             CT.DES.IDS_DESGN_DESC ,
             CT.CAR.CAR_PER_GRADE_CD,
             CT.CAR.CAR_SUB_GRADE_CD,
             NULL,
             NULL,
             NULL,
             NULL,
             CT.CAR.CAR_PYRL_AREA,
             CT.C1.IRC_DESC,
             CT.CAR.CAR_COST_CENT_CD,
             CT.C2.IRC_DESC,
             NULL,
             NULL,
             CT.DOS.IDT_DT,
             CT.CAR_SEP.CAR_ACTION_RSN,
             CT.C4.IRC_DESC,
             CT.PDT.IDT_DT,
             CT.EDR.IDT_DT,
             NULL,
             CT.PROM.IDT_DT,
             CT.INC.IDT_DT,
             NULL,
             NULL,
             CT.C5.IRC_DESC,
             CT.car.car_exec_cd,
             CT.org_exe.oro_desc ,
             CT.car.car_grp_cd ,
             CT.org_grp.oro_desc ,
             CT.car.car_pu_cd ,
             CT.org_pu.idp_pu_desc ,
             CT.car.car_position_id,
             NULL,
             NULL,
             NULL,
             NULL,
             CT.F_NAME,
             CT.S_NAME,
             CT.TRGSD.IDT_DT,
             CT.TRGED.IDT_DT,
             NULL,
             NULL,
             NULL,
             NULL,
             CT.PAN.EID_ID,
             CT.PHONE.EMC_CONTACT,
             CT.EMAIL.EMC_CONTACT,
             CT.PER.EPR_RELIGION,
             CT.PER.EPR_NATIVE_STATE,
             CT.PER.EPR_NATIONALITY,
             NULL,
             NULL,
             NULL,
             SYSDATE,
             '157068',
             SYSDATE,
             '157068');

     END LOOP;

    END Employeeall;

1 个答案:

答案 0 :(得分:4)

你必须确保每个列在存储过程中具有不同的别名。

即我看到重复:

         DOJ.idt_dt,
         DOS.IDT_DT,
         PDT.IDT_DT,
         EDR.IDT_DT,
         PROM.IDT_DT,
         INC.IDT_DT,
         TRGSD.IDT_DT,
         TRGED.IDT_DT,

只需为每个列添加一个唯一的别名,就像你为其他一些列所做的那样。