我在使用我的postgresql函數調試某些語法問題時遇到了問題。這個錯誤並不表示問題出現,我對Postgres來說太新了,不知道哪裏出了問題。我正在使用SQLFiddle進行測試。 SQLFiddle鏈接http://sqlfiddle.com/#!15/266ef使用Postgres函數的語法問題
功能,我使用
CREATE OR REPLACE FUNCTION updateSalary() RETURNS VOID AS
$BODY$
DECLARE
sum INTEGER := 0;
dep CURSOR FOR SELECT Dno FROM Department;
dep_row Department%ROWTYPE;
emp CURSOR(dept_Dno) CURSOR FOR
SELECT Dno, Salary FROM Employee WHERE Dno = dept_Dno;
emp_row Employee%ROWTYPE;
BEGIN
open dep;
LOOP
FETCH dep into dep_row;
exit when NOT FOUND;
open emp(dep_row.Dno);
LOOP
FETCH emp into emp_row;
exit when NOT FOUND;
SET sum := sum + emp_row.salary;
END LOOP;
UPDATE department SET total_sal = sum WHERE department.dno = emp_row.dno;
close emp;
SET sum := 0;
END LOOP;
close dep;
END;
$BODY$
LANGUAGE plpgsql;
錯誤我收到
Schema Creation Failed: ERROR: missing data type declaration at or near ")":
請鏈接到有問題的SQLFiddle。 –
@CraigRinger我已經包括了鏈接 –