如果游标没有找到数据,即游标锁查的数据到头了,就把之前定义的标记变量done该为1。
DECLARE EXIT HANDLER FOR SQLEXCEPTION, SQLWARNING SET stmt = 'ABORTED'; DECLARE UNDO HANDLER FOR NOT FOUND; 如果预定义异常集不能满足需求,就可以为特定的SQLSTATE值声明定制异常,然后再为这个定制异常声明处理器。语法如下: 清单4:定制异常处理器 DECLARE unique-name CONDITION FOR SQLSATE 'sqlstate' 处理...
DECLARE handler-type Handler for Condition SQL-procedure-statement; 如:DECLARE EXIT HANDLER FOR SQLEXCEPTION ...或 DECLARE CONTINUE HANDLER FOR NOT FOUND ... 2)解释: 当DB2触发一个满足定义的条件时(发生异常情况时),就会将控制权交给条件处理器(Condition Handler), 条件处理器根据指定的处理类型(HANDLER ...
CREATE PROCEDURE insertStudentData() BEGIN #处理的方法一: DECLARE CONTINUE HANDLER FOR 1364 SE...
2、如果定义了handler action,会在continue或exit之前执行 发生错误的条件有: 1、MYSQL错误代码 2、ANSI-standard SQLSTATE code 3、命名条件。可使用系统内置的SQLEXCEPTION,SQLWARNING和NOT FOUND 例1: 当错误代码为1062时将duplicate_key的值设为1,并继续执行当前任务 ...
-- SQLWARNING捕获所有以01开头的sqlstate_value值,然后执行EXIT DECLARE EXIT HANDLER FOR SQLWARNING SET @info='ERROR'; -- NOT FOUND 捕获所有以02开头的sqlstate_value值,然后执行EXIT操作,并且输出"CAN NOT FIND"信息 DECLARE EXIT HANDLER FOR FOUND SET @info='CAN NOT FIND'; ...
handler_type: CONTINUE | EXIT | UNDO condition_value: SQLSTATE [VALUE] sqlstate_value | condition_name | SQLWARNING | NOT FOUND | SQLEXCEPTION | mariadb_error_code 描述 DECLARE ... HANDLER语句定义一个handler,它可以处理一个或多个条件。当一个或多个条件被触发时,将执行指定的语句。所执行的语...
处理程序声明必须出现在变量或条件声明之后。DECLARE ... HANDLER语句的语法如下: DECLAREhandler_actionHANDLERFORcondition_value[,condition_value]...statement handler_action: {CONTINUE|EXIT|UNDO } condition_value: { mysql_error_code|SQLSTATE[VALUE]sqlstate_value|condition_name|SQLWARNING|NOTFOUND|SQLEXCEPTIO...
DELIMITER $$ CREATE PROCEDURE xxx.proc_reuters_dss_equity_price(OUT p_result BOOLEAN) BEGIN -- 错误处理 DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN TRUNCATE TABLE reuters_interface.reuters_dss_equity_price; SET p_result = FALSE; END; -- 处理数据 ...
13.6.7.2 DECLARE ... HANDLER Statement DECLAREhandler_actionHANDLERFORcondition_value[,condition_value]...statementhandler_action: {CONTINUE|EXIT|UNDO}condition_value: {mysql_error_code|SQLSTATE[VALUE]sqlstate_value|condition_name|SQLWARNING|NOTFOUND|SQLEXCEPTION} ...