首页 新闻 会员 周边

谁能给我看一下这个PL/SQL代码

0
悬赏园豆:10 [已解决问题] 解决于 2014-02-23 18:14

这是报的错

代码在这里:

declare
fname varchar2(39);
iid number;
urows Users%rowtype;
cursor cUsers is
select * from Users where u_id=1;

begin

open cUsers;
if cUsers%Notfound then
dbms_output.put_line('没有找到');
else
fetch cUsers into urows;
for tt in cUsers loop
dbms_output.put_line('姓名:'||tt.name||'艾迪'||tt.U_id);
end loop;
end if;
close cUsers;
end;

康大头的主页 康大头 | 初学一级 | 园豆:25
提问于:2014-01-18 15:44
< >
分享
最佳答案
0

在使用 FOR 循环时,不能显式的使用 open、colse 和 FETCH 语句,他会自动完成

改为下面这样试试

declare
fname varchar2(39);
iid number;
urows Users%rowtype;
cursor cUsers is
select * from Users where u_id=1;

begin
for tt in cUsers loop
dbms_output.put_line('姓名:'||tt.name||'艾迪'||tt.U_id);
end loop;
end;
收获园豆:10
诶碧司 | 小虾三级 |园豆:1912 | 2014-01-19 00:46
其他回答(1)
0

for tt in cUsers loop

 

你可以看一下for循环的语法介绍。 oracle的循环是隐式打开游标的

bitbug | 园豆:470 (菜鸟二级) | 2014-01-20 08:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册