| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> mysql >> dai ni qing song jie chu MySQL shu ju ku de yi chang chu li

dai ni qing song jie chu MySQL shu ju ku de yi chang chu li

2008-06-01 03:23:18 编辑來源:互联网 评论
 
 
 
本文为【带你轻松接触MySQL数据库的异常处理】的拼音翻译版
  dui yu MySQL de yi chang chu li , ben ren bu chang yong 。 bu guo wo jiao de huan shi you xie xia lai de bi yao 。
  biao zhun ge shi
  DECLARE handler_type HANDLER FOR condition_value[,...] statement
  handler_type:
  CONTINUE
  | EXIT
  | UNDO -- zan shi bu zhi chi
  condition_value:
  SQLSTATE [VALUE] sqlstate_value
  | condition_name
  | SQLWARNING
  | NOT FOUND
  | SQLEXCEPTION
  | mysql_error_code
  condition_value xi jie
  1、MySQL ERROR CODE lie biao
  ru guo xu yao cha kan geng duo de cuo wu lie biao ke yi zhi jie dao MySQL an zhuang lu jing xia 。
  bi ru wo de /usr/local/mysql/share/mysql/errmsg.txt
  shuo ming :SQLSTATE [VALUE] sqlstate_value zhe zhong ge shi shi zhuan men wei ANSI SQL he ODBC yi ji qi ta de biao zhun .
  bing bu shi suo you de MySQL ERROR CODE dou yang she dao SQLSTATE。
  2、 jia ru bu xu yao cha ru ERROR CODE, ke yi yong su ji tiao jian lai dai ti
  SQLWARNING dai biao suo you yi 01 kai tou de cuo wu dai ma
  NOT FOUND dai biao suo you yi 02 kai tou de cuo wu dai ma , dang ran ye ke yi dai biao yi ge you biao dao da shu ju ji de mo yi 。
  SQLEXCEPTION dai biao chu le SQLWARNING he NOT FOUND de suo you cuo wu dai ma 。
  3、 ju ti shi li :
  CREATE TABLE t (s1 int,primary key (s1));
  mysql> use t_girl
  Database changed
  mysql> CREATE TABLE t (s1 int,primary key (s1));
  Query OK, 0 rows affected (0.00 sec)
  mysql>
  mysql>
  mysql> DELIMITER ||
  mysql> CREATE PROCEDURE handlerdemo ()
  -> BEGIN
  -> DECLARE EXIT HANDLER FOR SQLSTATE '23000' BEGIN END; -- yu dao chong fu jian zhi jiu tui chu
  -> SET @x = 1;
  -> INSERT INTO t VALUES (1);
  -> SET @x = 2;
  -> INSERT INTO t VALUES (1);
  -> SET @x = 3;
  -> END||
  Query OK, 0 rows affected (0.00 sec)
  mysql> DELIMITER ;
  mysql> call handlerdemo();
  Query OK, 0 rows affected (0.00 sec)
  mysql> select @x;
  +------+
  | @x |
  +------+
  | 2 |
  +------+
  1 row in set (0.00 sec)
  mysql> call handlerdemo();
  Query OK, 0 rows affected (0.00 sec)
  mysql> select @x;
  +------+
  | @x |
  +------+
  | 1 |
  +------+
  1 row in set (0.00 sec)
  mysql>
  yu dao cuo wu ji xu de qing kuang
  mysql> truncate table t;
  Query OK, 0 rows affected (0.01 sec)
  mysql> DELIMITER $$
  mysql> DROP PROCEDURE IF EXISTS `t_girl`.`handlerdemo`$$
  Query OK, 0 rows affected (0.00 sec)
  mysql> CREATE DEFINER=`root`@`localhost` PROCEDURE `handlerdemo`()
  -> BEGIN
  -> DECLARE CONTINUE HANDLER FOR SQLSTATE '23000' BEGIN END;
  -> SET @x = 1;
  -> INSERT INTO t VALUES (1);
  -> SET @x = 2;
  -> INSERT INTO t VALUES (1);
  -> SET @x = 3;
  -> END$$
  Query OK, 0 rows affected (0.01 sec)
  mysql> DELIMITER ;
  mysql> call handlerdemo();
  Query OK, 0 rows affected (0.00 sec)
  mysql> select @x;
  +------+
  | @x |
  +------+
  | 3 |
  +------+
  1 row in set (0.00 sec)
  mysql> call handlerdemo();
  Query OK, 0 rows affected (0.00 sec)
  mysql> select @x;
  +------+
  | @x |
  +------+
  | 3 |
  +------+
  1 row in set (0.00 sec)
  mysql>
  wo men ke yi kan dao , shi zhong zhi xing dao zui hou 。
  dang ran , shang mian de SQLSTATE '23000' ke yi ti huan wei 1062。
  jing gao :
  mysql> alter table t add s2 int not null;
  Query OK, 0 rows affected (0.01 sec)
  Records: 0 Duplicates: 0 Warnings: 0
  zhe ge lie mei you mo ren zhi , cha ru de shi hou hui chu xian jing gao huo zhe 1364 cuo wu ti shi 。
  mysql> DELIMITER $$
  mysql> DROP PROCEDURE IF EXISTS `t_girl`.`handlerdemo`$$
  Query OK, 0 rows affected, 1 warning (0.00 sec)
  mysql> CREATE DEFINER=`root`@`localhost` PROCEDURE `handlerdemo`()
  -> BEGIN
  -> DECLARE CONTINUE HANDLER FOR 1062 BEGIN END;
  -> DECLARE CONTINUE HANDLER FOR SQLWARNING
  -> BEGIN
  -> update t set s2 = 2;
  -> END;
  -> DECLARE CONTINUE HANDLER FOR 1364
  -> BEGIN
  -> INSERT INTO t(s1,s2) VALUES (1,3);
  -> END;
  -> SET @x = 1;
  -> INSERT INTO t(s1) VALUES (1);
  -> SET @x = 2;
  -> INSERT INTO t(s1) VALUES (1);
  -> SET @x = 3;
  -> END$$
  Query OK, 0 rows affected (0.00 sec)
  mysql> DELIMITER ;
  mysql> call handlerdemo();
  Query OK, 0 rows affected (0.00 sec)
  mysql> select * from t;
  +----+----+
  | s1 | s2 |
  +----+----+
  | 1 | 3 |
  +----+----+
  1 row in set (0.00 sec)
  yu dao cuo wu shi , cha ru de xin ji lu 。
  mysql> select @x;
  +------+
  | @x |
  +------+
  | 3 |
  +------+
  1 row in set (0.00 sec)【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
dui yu MySQL de yi chang chu li , ben ren bu chang yong 。 bu guo wo jiao de huan shi you xie xia lai de bi yao 。 biao zhun ge shi DECLARE handler_type HANDLER FOR condition_value[,...] statement handler_type: CONTINUE | EXIT | UNDO -- zan shi bu zhi chi condition_value: SQLSTATE [VALUE] sqlstate_value | condition_name | SQLWARNING | NOT FOUND | SQLEXCEPTION | mysql_error_code condition_value xi jie 1、MySQL ERROR CODE lie biao ru guo xu yao cha kan geng duo de cuo wu lie biao ke yi zhi jie dao MySQL an zhuang lu jing xia 。 bi ru wo de /usr/local/mysql/share/mysql/errmsg.txt shuo ming :SQLSTATE [VALUE] sqlstate_value zhe zhong ge shi shi zhuan men wei ANSI SQL he ODBC yi ji qi ta de biao zhun . bing bu shi suo you de MySQL ERROR CODE dou yang she dao SQLSTATE。 2、 jia ru bu xu yao cha ru ERROR CODE, ke yi yong su ji tiao jian lai dai ti SQLWARNING dai biao suo you yi 01 kai tou de cuo wu dai ma NOT FOUND dai biao suo you yi 02 kai tou de cuo wu dai ma , dang ran ye ke yi dai biao yi ge you biao dao da shu ju ji de mo yi 。 SQLEXCEPTION dai biao chu le SQLWARNING he NOT FOUND de suo you cuo wu dai ma 。 3、 ju ti shi li : CREATE TABLE t (s1 int,primary key (s1)); mysql> use t_girl Database changed mysql> CREATE TABLE t (s1 int,primary key (s1)); Query OK, 0 rows affected (0.00 sec) mysql> mysql> mysql> DELIMITER || mysql> CREATE PROCEDURE handlerdemo () -> BEGIN -> DECLARE EXIT HANDLER FOR SQLSTATE '23000' BEGIN END; -- yu dao chong fu jian zhi jiu tui chu -> SET @x = 1; -> INSERT INTO t VALUES (1); -> SET @x = 2; -> INSERT INTO t VALUES (1); -> SET @x = 3; -> END|| Query OK, 0 rows affected (0.00 sec) mysql> DELIMITER ; mysql> call handlerdemo(); Query OK, 0 rows affected (0.00 sec) mysql> select @x; +------+ | @x | +------+ | 2 | +------+ 1 row in set (0.00 sec) mysql> call handlerdemo(); Query OK, 0 rows affected (0.00 sec) mysql> select @x; +------+ | @x | +------+ | 1 | +------+ 1 row in set (0.00 sec) mysql> yu dao cuo wu ji xu de qing kuang mysql> truncate table t; Query OK, 0 rows affected (0.01 sec) mysql> DELIMITER $$ mysql> DROP PROCEDURE IF EXISTS `t_girl`.`handlerdemo`$$ Query OK, 0 rows affected (0.00 sec) mysql> CREATE DEFINER=`root`@`localhost` PROCEDURE `handlerdemo`() -> BEGIN -> DECLARE CONTINUE HANDLER FOR SQLSTATE '23000' BEGIN END; -> SET @x = 1; -> INSERT INTO t VALUES (1); -> SET @x = 2; -> INSERT INTO t VALUES (1); -> SET @x = 3; -> END$$ Query OK, 0 rows affected (0.01 sec) mysql> DELIMITER ; mysql> call handlerdemo(); Query OK, 0 rows affected (0.00 sec) mysql> select @x; +------+ | @x | +------+ | 3 | +------+ 1 row in set (0.00 sec) mysql> call handlerdemo(); Query OK, 0 rows affected (0.00 sec) mysql> select @x; +------+ | @x | +------+ | 3 | +------+ 1 row in set (0.00 sec) mysql> wo men ke yi kan dao , shi zhong zhi xing dao zui hou 。 dang ran , shang mian de SQLSTATE '23000' ke yi ti huan wei 1062。 jing gao : mysql> alter table t add s2 int not null; Query OK, 0 rows affected (0.01 sec) Records: 0 Duplicates: 0 Warnings: 0 zhe ge lie mei you mo ren zhi , cha ru de shi hou hui chu xian jing gao huo zhe 1364 cuo wu ti shi 。 mysql> DELIMITER $$ mysql> DROP PROCEDURE IF EXISTS `t_girl`.`handlerdemo`$$ Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> CREATE DEFINER=`root`@`localhost` PROCEDURE `handlerdemo`() -> BEGIN -> DECLARE CONTINUE HANDLER FOR 1062 BEGIN END; -> DECLARE CONTINUE HANDLER FOR SQLWARNING -> BEGIN -> update t set s2 = 2; -> END; -> DECLARE CONTINUE HANDLER FOR 1364 -> BEGIN -> INSERT INTO t(s1,s2) VALUES (1,3); -> END; -> SET @x = 1; -> INSERT INTO t(s1) VALUES (1); -> SET @x = 2; -> INSERT INTO t(s1) VALUES (1); -> SET @x = 3; -> END$$ Query OK, 0 rows affected (0.00 sec) mysql> DELIMITER ; mysql> call handlerdemo(); Query OK, 0 rows affected (0.00 sec) mysql> select * from t; +----+----+ | s1 | s2 | +----+----+ | 1 | 3 | +----+----+ 1 row in set (0.00 sec) yu dao cuo wu shi , cha ru de xin ji lu 。 mysql> select @x; +------+ | @x | +------+ | 3 | +------+ 1 row in set (0.00 sec)
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
时尚秀气模特裴裴(8)
时尚秀气模特裴裴(7)
时尚秀气模特裴裴(6)
时尚秀气模特裴裴(5)
白墙黑瓦
广州东郊[原创]
八美至丹巴的东谷天然盆景
不一样的
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有