Oracle 简单异常实例
来源:互联网 发布:网络炒作公司价格 编辑:程序博客网 时间:2024/05/16 18:41
1.预定义异常(预知遇到的异常情况:no_data_found)
declarev_sal employees.salary % type;
begin
select salary into v_sal from employees where employee_id = 1001;
dbms_output.put_line(v_sal);
exception
when no_data_found then dbms_output.put_line('查无此人');
end;
2.非预定义异常
declare--定义异常
temp_exception exception;
--将其定义好的异常情况,与标准的oracle错误联系起来,使用exception_int语句
pragma exception_init(temp_exception,-2292);---2292违反一致性约束的错误代码
begin
delete from employees where employee_id = 100;
exception
--处理异常
when temp_exception
then dbms_output.put_line('违反完整性约束');
end;
3.自定义异常
declareno_result exception;
begin
update employees set salary = salary +100 where employee_id = 1001;
--使用隐式游标,抛出自定义异常
if sql % notfound
then raise no_result;
end if;
exception
when no_result
then dbms_output.put_line('工资太高了');
end;
0 0
- Oracle 简单异常实例
- c++异常简单实例
- 自定义异常简单实例
- JAVA内存异常简单实例
- oracle 触发器简单实例
- oracle简单触发器 实例
- ORACLE GOTO简单实例
- Oracle触发器简单实例
- oracle中简单处理异常
- Oracle存储过程简单实例
- Oracle存储过程简单实例
- Oracle Job 定时器简单实例
- Oracle存储过程简单实例
- Oracle存储过程简单实例:
- qt5 使用oracle简单实例
- oracle触发器实例及异常处理
- 用JAVA连接ORACLE的简单实例
- oracle的简单优化实例分析
- github上传、git不存在git init选项、本地更新到远程的解决办法
- 移动端侧滑显示删除按钮(与VUE框架整合)
- mysql中bigint、int、mediumint、smallint 和 tinyint的取值范围
- 理解OAuth 2.0
- PHP慢日志 ELK+FileBeat收集
- Oracle 简单异常实例
- Excel-乘法表
- WebView下载文件
- Qt5.8 + VS2015 环境搭建
- Spring-cloud Eureka 集群
- 隐藏自己的小秘密
- 1.5 网页下载器与urllib2模块(核心)
- 广播监听系统切换语言变换
- 去除UITabBar底部的一条线