2013-09-25 69 views
0
set serveroutput on; 

begin 
for rec in (select * from emp) loop 
    insert into emp (stars) values (rpad(' ', salary/1000, '*')); 
end loop; 
end; 
/

返回以下错误:错误而执行PL/SQL块

Error report: 
ORA-06550: line 3, column 45: 
PL/SQL: ORA-00984: column not allowed here 
ORA-06550: line 3, column 3: 
PL/SQL: SQL Statement ignored 
06550. 00000 - "line %s, column %s:\n%s" 
*Cause: Usually a PL/SQL compilation error. 
*Action: 

我想在starsemp表的(同employees),星号一个的每一个的字符串添加1000的工资。

有人可以请解释错误是关于什么。谢谢

+1

你不需要一个游标来做到这一点,只需要一条SQL语句。 –

回答

0

对不起刚刚发现我的错误。

update emp set stars = rpad('*', salary/1000, '*'); 

是正确的说法。