0
假設我們有員工表,我的目標是編寫declare -blog statment,它將該員工的工資提高10%,在工作部門有更高的工資水平,並且由20 %如果它沒有更多的薪金, 我認爲代碼應該是寫PL/SQL博客陳述
begin
update employees e set e.salary=e.salary+e.salary*0.1;
where e.salary>(select avg(e.salary) from employees e group by e.department_id);
update employees e set e.salary=e.salary+e.salary*0.1;
where e.salary<(select avg(e.salary) from employees e group by e.department_id);
end;
但它返回下列錯誤列表,
Error starting at line 4 in command:
begin
update employees e set e.salary=e.salary+e.salary*0.1;
where e.salary>(select avg(e.salary) from employees e group by e.department_id);
update employees e set e.salary=e.salary+e.salary*0.1;
where e.salary<(select avg(e.salary) from employees e group by e.department_id);
end;
Error report:
ORA-06550: line 3, column 1:
PLS-00103: Encountered the symbol "WHERE" when expecting one of the following:
(begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimited-identifier>
<a bind variable> << continue close current delete fetch lock
insert open rollback savepoint set sql execute commit forall
merge pipe purge
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
請幫幫我,爲什麼?,是有必要的循環statment或?
我可以用IF-THEN做 - 別的我已經改變,但它寫道,0行更新,我認爲第一次更新時,然後在同一時間它試圖更新第二也,但也許沒有這樣的僱員,totaly它不能更新任何行是嗎? – 2012-02-01 19:56:25
你可以直接運行'select'子查詢並查看平均工資。你也可以使用相同的'where ...'子句,從員工e'中取代select'count(*)而不是'update ...',並查看更新會影響多少條記錄。 – 9000 2012-02-01 21:29:17