Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-00947: not enough values

xi`tinAug 26 2009 — edited Aug 28 2009
Hi everyone,

I'm using MERGE statement to INSERT or UPDATE data. My table have 7 fields and I'm already input enough, but when I was executed, I'm received an error message: "ORA-00947: not enough values".

My query like this:

MERGE INTO chitiethoadon h
USING (
SELECT '200906' thang_nam, CASE WHEN m.ma_ttoan IS NOT NULL THEN m.ma_ttoan ELSE t.ma_kh END ma_ttoan,
somay, CASE WHEN SUBSTR(somay,5,2) IN ('50','60','70','91') AND loai_dv = 1 THEN 7 ELSE loai_dv END loai_dv, 23 khoanmucps,
t.tien_ntin AS tien, vat_ntin AS vat
FROM hoadon_20090601 t
LEFT JOIN anhxa_makh m ON m.ma_kh = t.ma_kh AND t.somay = m.so_may
AND (m.thang_nam = '200906' OR m.thang_nam IS NULL)
WHERE t.tien_ntin <> 0
) t ON (h.thang_nam = t.thang_nam AND h.ma_ttoan = t.ma_ttoan AND h.so_may = t.somay AND h.makhoanmuc = t.khoanmucps)
WHEN MATCHED THEN
UPDATE SET h.thang_nam = t.thang_nam,
h.ma_ttoan = t.ma_ttoan,
h.so_may = t.somay,
h.kieu_sdung = t.loai_dv,
h.makhoanmuc = t.khoanmucps,
h.tien = t.tien,
h.vat = t.vat
WHEN NOT MATCHED THEN
INSERT (h.thang_nam, h.ma_ttoan, h.so_may, h.kieu_sdung, h.makhoanmuc, h.tien, h.vat)
VALUES (t.thang_nam, t.ma_ttoan, t.somay, t.loai_dv, t.khoanmucps, t.tien. t.vat)

Please tell me the reason why?

Thanks a lot!!!

Xi`tin
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 25 2009
Added on Aug 26 2009
4 comments
1,960 views