大家看看这段oracle代码有哪些错误

bluecarrife 2011-08-19 08:39:03
程序已经实现功能,但是感觉写的很差,希望指正:

-----function一定要有返回值,否则报错
CREATE OR REPLACE function sortbyregion_temp
return real
as
v_code integer;
p_number integer := 12;
p_error_info exception;
cursor type1_cur
is
select code from sys_dict where code like '404%' order by name;
BEGIN
------定义游标查找配置记录
open type1_cur;
loop
fetch type1_cur into v_code;
------当查找没有记录时退出
exit when type1_cur%notfound;
update sys_dict set bysort = p_number where code =v_code;
p_number := p_number + 2;
end loop;
close type1_cur;
return 0;
END;
...全文
43 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
UPC子夜 2011-08-20
  • 打赏
  • 举报
回复
函数是一定要有返回值的 要不然 用函数干啥?
看你的功能 定义一个存储过程更合适
Rotel-刘志东 2011-08-20
  • 打赏
  • 举报
回复
自定义函数是很灵活的。
Rotel-刘志东 2011-08-20
  • 打赏
  • 举报
回复
CREATE OR REPLACE function sortbyregion_temp
return real
as
v_code integer;
p_number integer := 12;
p_error_info exception;
cursor type1_cur
is
select code from sys_dict where code like '404%' order by name;
BEGIN
------定义游标查找配置记录
open type1_cur;
loop
fetch type1_cur into v_code;
------当查找没有记录时退出
exit when type1_cur%notfound;
update sys_dict set bysort = p_number where code =v_code;
p_number := p_number + 2;
end loop;
close type1_cur;
return 0;
END;
有情男 2011-08-19
  • 打赏
  • 举报
回复
就是个的练习题,你的异常信息变量没有用上,而且你应该处理一下游标查询无结果的时候应该怎么办

17,078

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧