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!

MERGE INTO problem

558692Jan 29 2007 — edited Mar 28 2007
Hi,

I am getting a error message "ORA-01008: not all variables bound" by using this statement

MERGE INTO bonuses B
USING (
SELECT employee_id, salary
FROM employee
WHERE dept_no = :1) E
ON (B.employee_id = E.employee_id)
WHEN MATCHED THEN
UPDATE SET B.bonus = E.salary * :2
WHEN NOT MATCHED THEN
INSERT (B.employee_id, B.bonus)
VALUES (E.employee_id, E.salary * :3)

I have tried executing this query using TOAD and java through jdbc. In both the cases it gives me this error.

The suprising part is that it works in the following cases :
1.MERGE INTO bonuses B
USING (
SELECT employee_id, salary
FROM employee
WHERE dept_no = 20) E
ON (B.employee_id = E.employee_id)
WHEN MATCHED THEN
UPDATE SET B.bonus = E.salary * :1
WHEN NOT MATCHED THEN
INSERT (B.employee_id, B.bonus)
VALUES (E.employee_id, E.salary * :2)

2.MERGE INTO bonuses B
USING (
SELECT employee_id, salary
FROM employee
WHERE dept_no = :1) E
ON (B.employee_id = E.employee_id)
WHEN MATCHED THEN
UPDATE SET B.bonus = E.salary * 0.5
WHEN NOT MATCHED THEN
INSERT (B.employee_id, B.bonus)
VALUES (E.employee_id, E.salary * 0.01)

It doesnt work in the case, when we are trying to set a user defined value in the both USING clause and WHEN MATCHED/WHEN NOT MATCHED clauses..

Please help me and point me out what am i doing wrong ?

Thanks
Atul
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 25 2007
Added on Jan 29 2007
5 comments
592 views