日期:2014-05-17  浏览次数:20686 次

这个sql块写的有问题,大家帮忙看看
declare
v_result   number(80);
begin
    for   cur   in   (select   distinct   no   from   table   )
    loop
        v_result:=cur.no;
        dbms_output.put_line( '工号为 '||v_result);
    end   loop;
end   ;
大家帮忙看看这有没有错误

就是把所有的员工工号打出来!

------解决方案--------------------
语法没问题,就是number(80)太夸张,一我用的最大才number(19),

80位是什么概念
------解决方案--------------------
建议还是把程序写的规范点吧:(别打我啊)

declare
v_result number(80);
CURSOR curs is
select distinct no from table;
begin
for c_cur in curs loop
v_result:=cur.no;
dbms_output.put_line( '工号为: '||to_char(v_result));
end loop;
exception
when others then
dbms_output.put_line(substr(sqlerrm,1,255));
end ;