MERGE INTO problem
558692Jan 29 2007 — edited Mar 28 2007Hi,
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