我有三个游标声明为 CUR_AD1、CUR_AD1_C、CUR_AD_2。它们所包含的只是来自 3 个运行良好的选择语句的结果。
后来我有以下陈述:
BEGIN
FOR AD1_REC IN CUR_AD1 LOOP
V_ORG_NAME := AD1_REC.ADDRESS_LINE1;
IF V_ORG_NAME = AD1_REC.ADDRESS_LINE1 THEN
INSERT INTO DSOPI_PERSON_ADDR_RULE
(CCTR_PERSON_ADDRESS_ID, CCTR_PERSON_ID, SRC_ADDRESS_LINE1, SRC_ADDRESS_LINE2, SRC_ADDRESS_LINE3, SRC_ADDRESS_LINE4,
ORG_NAME, DEPT_NAME, TGT_ADDRESS_LINE1, TGT_ADDRESS_LINE2, TGT_ADDRESS_LINE3, TGT_ADDRESS_LINE4,
STATE, CITY, COUNTRY_NAME, ZIP_CODE, EXTRACT_DATE)
VALUES
(AD1_REC.CCTR_PERSON_ADDRESS_ID, AD1_REC.CCTR_PERSON_ID, AD1_REC.ADDRESS_LINE1, AD1_REC.ADDRESS_LINE2, AD1_REC.ADDRESS_LINE3, AD1_REC.ADDRESS_LINE4,
V_ORG_NAME, '', '', AD1_REC.ADDRESS_LINE2, AD1_REC.ADDRESS_LINE3, AD1_REC.ADDRESS_LINE4,
AD1_REC.STATE, AD1_REC.CITY, AD1_REC.COUNTRY_NAME, AD1_REC.ZIP_CODE, SYSDATE);
ELSIF V_ORG_NAME = AD1_REC.ADDRESS_LINE2 THEN
FOR AD2_REC IN CUR_AD2 LOOP
INSERT INTO DSOPI_PERSON_ADDR_RULE
(CCTR_PERSON_ADDRESS_ID, CCTR_PERSON_ID, SRC_ADDRESS_LINE1, SRC_ADDRESS_LINE2, SRC_ADDRESS_LINE3, SRC_ADDRESS_LINE4,
ORG_NAME, DEPT_NAME, TGT_ADDRESS_LINE1, TGT_ADDRESS_LINE2, TGT_ADDRESS_LINE3, TGT_ADDRESS_LINE4,
STATE, CITY, COUNTRY_NAME, ZIP_CODE, EXTRACT_DATE)
VALUES
(AD2_REC.CCTR_PERSON_ADDRESS_ID, AD2_REC.CCTR_PERSON_ID, AD2_REC.ADDRESS_LINE1, AD2_REC.ADDRESS_LINE2, AD2_REC.ADDRESS_LINE3, AD2_REC.ADDRESS_LINE4,
AD2_REC.ADDRESS_LINE2, NULL, AD2_REC.TGT_ADDRESS_LINE1, NULL, AD2_REC.ADDRESS_LINE3, AD2_REC.ADDRESS_LINE4,
AD2_REC.STATE, AD2_REC.CITY, AD2_REC.COUNTRY_NAME, AD2_REC.ZIP_CODE, SYSDATE);
END LOOP;
END IF;
END LOOP;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR' || SQLERRM);
RAISE;
END;
当我编译正文时,我不断收到以下错误:
PL/SQL:忽略 SQL 语句 PLS-00302:必须声明组件“ZIP_CODE” PL/SQL:ORA-00984:此处不允许列
桌子没有任何问题。我认为这与我如何放置控制语句有关。非常感谢任何帮助。
表 DSOPI_PERSON_ADDR_RULE 的 DDL
CREATE TABLE "CALSEED_OWNER"."DSOPI_PERSON_ADDR_RULE"
( "CCTR_PERSON_ADDRESS_ID" NUMBER(12,0),
"CCTR_PERSON_ID" NUMBER(12,0),
"SRC_ADDRESS_LINE1" VARCHAR2(100 BYTE),
"SRC_ADDRESS_LINE2" VARCHAR2(100 BYTE),
"SRC_ADDRESS_LINE3" VARCHAR2(100 BYTE),
"SRC_ADDRESS_LINE4" VARCHAR2(100 BYTE),
"ORG_NAME" VARCHAR2(100 BYTE),
"DEPT_NAME" VARCHAR2(100 BYTE),
"TGT_ADDRESS_LINE1" VARCHAR2(100 BYTE),
"TGT_ADDRESS_LINE2" VARCHAR2(100 BYTE),
"TGT_ADDRESS_LINE3" VARCHAR2(100 BYTE),
"TGT_ADDRESS_LINE4" VARCHAR2(100 BYTE),
"STATE" VARCHAR2(100 BYTE),
"CITY" VARCHAR2(100 BYTE),
"COUNTRY_NAME" VARCHAR2(100 BYTE),
"ZIP_CODE" VARCHAR2(100 BYTE),
"EXTRACT_DATE" DATE,
"STREET" VARCHAR2(100 BYTE),
"STREET_CONTD" VARCHAR2(100 BYTE)
CURSOR CUR_AD2 IS
SELECT CCTR_PERSON_ADDRESS_ID, 'AL2' AL,ADDRESS_LINE2
FROM STG_RT2_PERSON_ADDRESS WHERE UPPER(ADDRESS_LINE2) IN
( SELECT UPPER(ORG_NAME) FROM STG_RT2_ORGANIZATION
WHERE NOT REGEXP_LIKE(ORG_NAME, '[0-9]')
AND NOT (LOWER(ORG_NAME) LIKE 'unknown' OR LOWER(ORG_NAME) LIKE 'no address%'
OR ORG_NAME ='-' OR ORG_NAME=' '));