3

我想做的是用三个不同的条件编写一个 INSERT 语句。

这是我到目前为止所做的(但是这段代码得到了 ORA-00913 too many values 错误):

INSERT ALL
   WHEN SALARY > 20000 THEN
     INTO SPECIAL_SAL13(EMPLOYEE_ID,HIRE_DATE,MANAGER_ID,SALARY)
   WHEN SALARY <= 20000 THEN
     INTO SAL_HISTORY13(EMPLOYEE_ID,SALARY)
   WHEN SALARY <= 20000 THEN
     INTO MGR_HISTORY13(EMPLOYEE_ID,MANAGER_ID,SALARY)
SELECT EMPLOYEE_ID,HIRE_DATE,MANAGER_ID,SALARY
FROM EMPLOYEES
WHERE EMPLOYEE_ID < 125
4

1 回答 1

5

尝试

INSERT ALL
   WHEN SALARY > 20000 THEN
     INTO SPECIAL_SAL13(EMPLOYEE_ID,HIRE_DATE,MANAGER_ID,SALARY)
     VALUES(EMPLOYEE_ID,HIRE_DATE,MANAGER_ID,SALARY)
   WHEN SALARY <= 20000 THEN
     INTO SAL_HISTORY13(EMPLOYEE_ID,SALARY)
     VALUES(EMPLOYEE_ID,SALARY)
   WHEN SALARY <= 20000 THEN
     INTO MGR_HISTORY13(EMPLOYEE_ID,MANAGER_ID,SALARY)
     VALUES(EMPLOYEE_ID,MANAGER_ID,SALARY)
SELECT EMPLOYEE_ID,HIRE_DATE,MANAGER_ID,SALARY
FROM EMPLOYEES
WHERE EMPLOYEE_ID < 125

参考请看这里

于 2013-05-08T09:42:18.420 回答