0
一個PL/SQL代碼,我需要輸出總銷售額的每個員工,但recieving錯誤創建具有光標
ORA-06550: line 7, column 1:
PLS-00103: Encountered the symbol "CURSOR" when expecting one of the following:
:= (; not null range default character
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
這裏是我的代碼,我相信這與我的分組功能做的,但我清楚地知道他們受人尊敬的桌子上的coulmns。任何幫助將不勝感激
SET SERVEROUTPUT ON
Declare
v_employee_fname employees2.first_name%TYPE;
v_employee_lname employees2.last_name%TYPE;
v_amount all_sales.amount%TYPE
CURSOR v_fullcount_cursor IS
SELECT e2.first_name, e2.last_name, sum(alls.amount) as total_sales
FROM employees2 e2 join all_sales alls on e2.employee_id = alls.EMP_ID
GROUP BY e2.first_name, sum(alls.amount);
BEGIN
OPEN v_fullcount_cursor;
LOOP
FETCH v_fullcount_cursor
INTO v_employee_fname, v_employee_lname, v_amount;
EXIT WHEN v_fullcount_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(v_employee_fname ||' '|| v_employee_lname ||' total sales are $'||
v_amount);
END LOOP;
CLOSE v_fullcount_cursor;
END;
/
隱式遊標for循環更快,更簡單,且不易出錯。你幾乎不應該再使用關鍵字'cursor'。 –