博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
oracle 函数捕获错误模板
阅读量:4686 次
发布时间:2019-06-09

本文共 703 字,大约阅读时间需要 2 分钟。

create or replace function huifunction(i_user_id in number) return varchar2 is

     m_result varchar2(40);
begin
    begin                                           ---勿忘
     select deptname into m_result from dept where id=i_user_id;
     exception when others then
     m_result:='出错';
     end;
     return (m_result);
end huifunction;

 

----另一种实现方法

create or replace function huifunction2(i_user_id in number,o_err out varchar) return varchar2 is

     m_result varchar2(40);
     m_count number;
begin
     m_result:='';
     select count(0) into m_count from dept where id=i_user_id;
     if m_count>0 then
         select deptname into m_result from dept where id=i_user_id;
     else
        o_err:='出错';
     end if;
     return (m_result);
end huifunction2;

转载于:https://www.cnblogs.com/Gracedream/archive/2012/05/10/2493792.html

你可能感兴趣的文章
24@Servlet_day03
查看>>
初级ant的学习
查看>>
redis数据结构--String
查看>>
POJ 3279 Fliptile (二进制枚举)
查看>>
memcached 细究(三)
查看>>
future
查看>>
关于main函数传参数的问题
查看>>
getTickCount()函数 VS GetTickCount()函数
查看>>
嵌入式jetty
查看>>
2017~回顾分享
查看>>
let const var的区别与作用
查看>>
计算出线在屏幕内的最长坐标
查看>>
使用svn——项目的目录布局
查看>>
Linux学习之CentOS(二十五)--Linux磁盘管理:LVM逻辑卷基本概念及LVM的工作原理
查看>>
【bzoj4310/hdu5030-跳蚤】后缀数组
查看>>
深度信任网络的快速学习算法(Hinton的论文)
查看>>
RSA System.Security.Cryptography.CryptographicException
查看>>
s的封装和信息隐蔽
查看>>
excelhttp://www.cnblogs.com/caoyuanzhanlang/p/3591904.html
查看>>
ArrayList和LinkedList和Vector源码分析
查看>>