oracle mached then,merge: WHEN MATCHED THEN "do nothing"

隗星驰
2023-12-01

Please refine this query if possible

MERGE INTO M_GRP N1

*

ERROR at line 1:

ORA-38101: Invalid column in the INSERT VALUES Clause: "N1"."HOSPITALNAME"

SQL> select * from v$version;

BANNER

----------------------------------------------------------------

Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product

PL/SQL Release 10.2.0.1.0 - Production

CORE 10.2.0.1.0 Production

TNS for 32-bit Windows: Version 10.2.0.1.0 - Production

NLSRTL Version 10.2.0.1.0 - Production

SQL> desc m_grp

Name Null? Type

----------------------------------------- -------- ---------------------

MC_CODE VARCHAR2(20)

NAME VARCHAR2(200)

ADDRESS VARCHAR2(300)

CITY VARCHAR2(20)

STATE VARCHAR2(10)

ZIP VARCHAR2(10)

PHONE VARCHAR2(20)

HOSPITALNAME VARCHAR2(800)

AREA VARCHAR2(30)

--query

MERGE INTO M_GRP N1

USING M_GROUP E1

ON (N1.NAME=E1.NAME)

WHEN MATCHED THEN

UPDATE SET N1.HOSPITALNAME=E1.HOSPITALNAME||','||E1.HOSPITALNAME

WHEN NOT MATCHED THEN

INSERT

(MC_CODE,NAME,ADDRESS,CITY,STATE,ZIP,PHONE,HOSPITALNAME,AREA)

VALUES

(E1.MC_CODE,

E1.NAME,

E1.ADDRESS,

E1.CITY,

E1.STATE,

E1.ZIP,

E1.PHONE,

TRIM (BOTH ' ' FROM HOSPITALNAME),

AREA)

/

 类似资料:

相关阅读

相关文章

相关问答