次の値を含む1つのステージテーブル' STAGE_TABLE
'があります(列はIDを除くvarchar2です)-
+-------------------------------------------------------------------------------------------------------------------------
¦ STAGE_ID ¦ EMP_ID ¦ ATTR1_OLD_VAL ¦ ATTR1_NEW_VAL ¦ ATTR2_OLD_VAL ¦ ATTR2_NEW_VAL ¦ ATTR3_OLD_VAL ¦ ATTR3_NEW_VAL ¦
¦-----------+------------+---------------+---------------+---------------+---------------+---------------+---------------¦
¦ 1 ¦ E001 ¦ xyz ¦ pqr ¦ mmm ¦ nnn ¦ zzz ¦ aaa ¦
¦ 2 ¦ E001 ¦ ¦ ¦ ¦ ¦ ¦ ¦
¦ 3 ¦ E001 ¦ pqr ¦ abc ¦ xxx ¦ yyy ¦ ¦ ¦
¦ 4 ¦ E002 ¦ aaa ¦ ccc ¦ bbb ¦ ttt ¦ ¦ ¦
¦ 5 ¦ E002 ¦ ¦ ¦ ¦ ¦ fff ¦ ppp ¦
¦ 6 ¦ E002 ¦ ¦ ¦ kkk ¦ jjj ¦ ¦ ¦
+-------------------------------------------------------------------------------------------------------------------------
同じ従業員に属する上記のテーブルの複数の行を1つにマージしたい-
+-------------------------------------------------------------------------------------------------------------
¦ EMP_ID ¦ ATTR1_OLD_VAL ¦ ATTR1_NEW_VAL ¦ ATTR2_OLD_VAL ¦ ATTR2_NEW_VAL ¦ ATTR3_OLD_VAL ¦ ATTR3_NEW_VAL ¦
¦------------+---------------+---------------+---------------+---------------+---------------+---------------¦
¦ E001 ¦ pqr ¦ abc ¦ xxx ¦ yyy ¦ zzz ¦ aaa ¦
¦ E002 ¦ aaa ¦ ccc ¦ kkk ¦ jjj ¦ fff ¦ ppp ¦
+-------------------------------------------------------------------------------------------------------------
私はMERGEステートメントについて知りましたが、それが機能するかどうかはわかりません。oracle pl/sqlは初めてです。