**这里我首先创建奖励表,当我调用execute immediate create_table和fill_table然后光标i从中获取数据时, 但它给我一个表或视图错误不存在 **。
declare --My table create_table VARCHAR2( 100 ) := ' create table bonuses ( employee_id NUMBER(6), bonus NUMBER DEFAULT 100 )'; ---String query that fetch data from hr and oe tables to fill bonus table fill_table VARCHAR2( 200 ) := 'INSERT INTO bonuses(employee_id) (SELECT employee_id FROM hr.employees e, oe.orders o WHERE e.employee_id = o.sales_rep_id GROUP BY e.employee_id) '; CURSOR foo is select A.employee_id, A.salary FROM HR.employees A JOIN HR.DEPARTMENTS B ON A.department_id = B.DEPARTMENT_ID JOIN HR.LOCATIONS C ON B.location_id = C.location_id JOIN HR.COUNTRIES D ON C.COUNTRY_ID = D.COUNTRY_ID JOIN HR.REGIONS E ON D.REGION_ID = E.REGION_ID WHERE E.REGION_NAME = 'Europe'; begin execute immediate create_table; execute immediate fill_table; commit; ---here happens the error FOR i IN ( SELECT employee_id FROM bonuses) LOOP FOR j in foo LOOP IF i.employee_id = j.employee_id THEN dbms_output.put_line( 1 ); -- UPDATE bonuses set bonus = bonus + j.salary * 0.01; ELSE dbms_output.put_line( 2 ); -- UPDATE bonuses set bonus = j.salary * 0.01; END IF; END LOOP; END LOOP; end;
[这是执行后得到的错误。我正在使用一个系统 顺便说一下。] [1]