--一异常处理的代码
--sqlcode 异常编号
--sqlerrm 信号字符串 /* 在plsql 块中格式 Declare
变量
Begin
代码块 EXCEPTION
when 异常的名称 then
如生上面的异常时做的具体工作。
End; */ set serveroutput on;
create or replace procedure pr12
as
--定义一个int变liang
v_age integer;
v_name varchar(30);
begin
v_age:=89;
--通过select给v_name设置值
--修改成过程
select name into v_name from stud where id=1;
DBMS_OUTPUT.PUT_LINE('没有出错');
exception
when value_error then
SYS.DBMS_OUTPUT.PUT_LINE('数值错误');
when no_data_found then
SYS.DBMS_OUTPUT.PUT_LINE('没有数据');
when others then
SYS.DBMS_OUTPUT.PUT_LINE(sqlcode||'你出错了'||sqlerrm);
end; exec pr12();
-----------------------------------------
--自定义异常自己抛出异常/
/*
定义一个自己的异常
myException Exception;
抛出异常
RAISE myException; 处理自己的异常:
Exception
When myException then
....
*/
set serveroutput on;
declare
myEx exception;
begin
DBMS_OUTPUT.PUT_LINE('这里没错');
raise myEx;
DBMS_OUTPUT.PUT_LINE('不会输出,前面抛出异常');
--处理异常
exception
when myEx then
DBMS_OUTPUT.PUT_LINE('自己的异常'||sqlcode||' '||sqlerrm);
when others then
DBMS_OUTPUT.PUT_LINE('不知知道什么错误'||sqlcode||sqlerrm);
END;
---出错直接抛出 declare
begin
DBMS_OUTPUT.PUT_LINE('no errors');
--直接抛出
RAISE_APPLICATION_ERROR(-20000, 'A');
DBMS_OUTPUT.PUT_LINE('go okk....');
exception
when others then
DBMS_OUTPUT.PUT_LINE(sqlcode||' '||sqlerrm);
end;

Oracle异常的抛出处理的更多相关文章

  1. java中异常的抛出:throw throws

    java中异常的抛出:throw throws Java中的异常抛出 语法: public class ExceptionTest{ public void 方法名(参数列表) throws 异常列表 ...

  2. JavaWeb项目中获取对Oracle操作时抛出的异常错误码

    最近在项目中碰到了这么一个需求,一个JavaWeb项目,数据库用的是Oracle.业务上有一个对一张表的操作功能,当时设置了两个字段联合的唯一约束.由于前断没有对重复字段的校验,需要在插入时如果碰到唯 ...

  3. Java throw:异常的抛出怎么回事

    到目前为止,你只是获取了被Java运行时系统抛出的异常.然而,程序可以用throw语句抛出明确的异常.Throw语句的通常形式如下:    throw ThrowableInstance;这里,Thr ...

  4. Java知多少(49)throw:异常的抛出

    到目前为止,你只是获取了被Java运行时系统抛出的异常.然而,程序可以用throw语句抛出明确的异常.Throw语句的通常形式如下:    throw ThrowableInstance;这里,Thr ...

  5. 六. 异常处理7.throw:异常的抛出

    到目前为止,你只是获取了被Java运行时系统抛出的异常.然而,程序可以用throw语句抛出明确的异常.Throw语句的通常形式如下:    throw ThrowableInstance;这里,Thr ...

  6. Python爬虫中的URLError\HTTPError异常类,异常的抛出

    # _*_ coding : utf-8 _*_# @Time : 2021/11/2 14:20# @Author : 秋泊酱 import urllib.request import urllib ...

  7. EXCEPTION_HIJACK(0xe0434f4e)异常的抛出过程

    样例工程 在VS2013里新建一个C#控制台工程,写下如下代码: using System; using System.Collections.Generic; using System.Linq; ...

  8. SpringMvc的 @Valid 拦截到的异常如何抛出

    SpringMvc中,校验参数可以使用 @Valid 注解,同时在相应的对象里使用 @NotBlank( message = "昵称不能为空")@NotNull( message ...

  9. PLSQL_Oracle Exception异常分类、异常抛出、异常处理、异常传播(概念)

    2014-06-03 Created By BaoXinjian

随机推荐

  1. TCP/IP 要点备忘

    1. 3次握手/4次挥手过程,以及状态变化: 2. RTT,TTL,TOS(8位服务类型,最小延时.最大吞吐.最高可用.最小费用). 3. TimeWait(2msl)状态,防止最后一个ack丢失 4 ...

  2. hdu5398 GCD Tree(lct)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud GCD Tree Time Limit: 5000/2500 MS (Java/O ...

  3. mongodb spring

    可参考 http://blog.csdn.net/cuiran/article/details/8287204 我修改后的代码 http://pan.baidu.com/s/1mgJYbaC

  4. 引入css外部样式表

    前言 为什么会有这篇文章,外部引入样式有什么好谈的,不外乎就是 <link rel="stylesheet" href="style.css" /> ...

  5. AngularJS自定义表单控件

    <!doctype html> <html ng-app="myApp"> <head> <script src="G:\\So ...

  6. 一个ajax实现表单上传文件的神器 formdata

    通过传统的form表单提交的方式上传文件: $.ajax({ url : "http://localhost:8080/STS/rest/user", type : "P ...

  7. While reading XXX pngcrush caught libpng error: N

    错误一:   While reading /XXX/XXX/XXX/img1.png pngcrush caught libpng error:   Not a PNG filCould not fi ...

  8. 数据结构&&算法基础知识

    写本篇主要是为了将基础知识梳理一遍,天天加一些基本东西,以后复习时可以返回来看看. 数据结构&&基础算法: 基本算法: 二分查找 二叉树: 二叉树的各种遍历 位操作: 排序: 排序算法 ...

  9. /sbin/ifup: configuration for eth0 not found解决

    /sbin/ifup: configuration for eth0 not found. Usage: ifup <device name> 那么应该是在/etc/sysconfig/n ...

  10. @@ROWCOUNT 含义

    返回受上一语句影响的行数. 如果行数大于 20 亿,请使用 ROWCOUNT_BIG. Transact-SQL 语句可以通过下列方式设置 @@ROWCOUNT 的值: 将 @@ROWCOUNT 设置 ...