| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> mysql >> yong MySQL shi xian SQL Server de sp_executesql

yong MySQL shi xian SQL Server de sp_executesql

2008-08-15 06:29:29 编辑來源:互联网 评论
 
 
 
本文为【用MySQL实现SQL Server的sp_executesql】的拼音翻译版
  cong MySQL 5.0 kai shi , zhi chi le yi ge quan xin de SQL ju fa :
  PREPARE stmt_name FROM preparable_stmt;
  EXECUTE stmt_name [USING @var_name [, @var_name] ...];
  {DEALLOCATE | DROP} PREPARE stmt_name;
  tong guo ta , wo men jiu ke yi shi xian lei si MS SQL de sp_executesql zhi xing dong tai SQL yu ju !
  tong shi ye ke yi fang zhi zhu ru shi gong ji !
  wei le you yi ge gan xing de ren shi ,
  xia mian xian gei ji ge xiao li zi :
  mysql> PREPARE stmt1 FROM 'SELECT SQRT(POW(?,2) + POW(?,2)) AS hypotenuse';
  mysql> SET @a = 3;
  mysql> SET @b = 4;
  mysql> EXECUTE stmt1 USING @a, @b;
  +------------+
  | hypotenuse |
  +------------+
  | 5 |
  +------------+
  mysql> DEALLOCATE PREPARE stmt1;
  mysql> SET @s = 'SELECT SQRT(POW(?,2) + POW(?,2)) AS hypotenuse';
  mysql> PREPARE stmt2 FROM @s;
  mysql> SET @a = 6;
  mysql> SET @b = 8;
  mysql> EXECUTE stmt2 USING @a, @b;
  +------------+
  | hypotenuse |
  +------------+
  | 10 |
  +------------+
  mysql> DEALLOCATE PREPARE stmt2;
  ru guo ni de MySQL ban ben shi 5.0.7 huo zhe geng gao de , ni huan ke yi zai LIMIT zi ju zhong shi yong ta , shi li ru xia :mysql> SET @a=1;mysql> PREPARE STMT FROM "SELECT * FROM tbl LIMIT ?";
  mysql> EXECUTE STMT USING @a;
  mysql> SET @skip=1; SET @numrows=5;
  mysql> PREPARE STMT FROM "SELECT * FROM tbl LIMIT ?, ?";
  mysql> EXECUTE STMT USING @skip, @numrows; shi yong PREPARE de ji ge zhu yi dian :
  A:PREPARE stmt_name FROM preparable_stmt;
  yu ding yi yi ge yu ju , bing jiang ta fu gei stmt_name ,stmt_name shi bu qu fen da xiao xie de 。
  B: ji shi preparable_stmt yu ju zhong de ? suo dai biao de shi yi ge zi fu chuan , ni ye bu xu yao jiang ? yong yin hao bao han qi lai 。
  C: ru guo xin de PREPARE yu ju shi yong le yi ge yi cun zai de stmt_name , na me yuan you de jiang bei li ji shi fang ! ji shi zhe ge xin de PREPARE yu ju yin wei cuo wu er bu neng bei zheng que zhi xing 。
  D: PREPARE stmt_name de zuo yong yu shi dang qian ke hu duan lian jie hui hua ke jian 。
  E: yao shi fang yi ge yu ding yi yu ju de zi yuan , ke yi shi yong DEALLOCATE PREPARE ju fa 。
  F: EXECUTE stmt_name ju fa zhong , ru guo stmt_name bu cun zai , jiang hui yin fa yi ge cuo wu 。
  G: ru guo zai zhong zhi ke hu duan lian jie hui hua shi , mei you xian shi di tiao yong DEALLOCATE PREPARE ju fa shi fang zi yuan , fu wu qi duan hui zi ji dong shi fang ta 。
  H: zai yu ding yi yu ju zhong ,CREATE TABLE, DELETE, DO, INSERT, REPLACE, SELECT, SET, UPDATE, he da bu fen de SHOW ju fa bei zhi chi 。
  G: PREPARE yu ju bu ke yi yong yu cun chu guo cheng , zi ding yi han shu ! dan cong MySQL 5.0.13 kai shi , ta ke yi bei yong yu cun chu guo cheng , reng bu zhi chi zai han shu zhong shi yong ! xia mian gei ge shi li : CREATE PROCEDURE `p1`(IN id INT UNSIGNED,IN name VARCHAR(11))BEGIN lable_exit: BEGIN SET @SqlCmd = 'SELECT * FROM tA '; IF id IS NOT NULL THEN SET @SqlCmd = CONCAT(@SqlCmd , 'WHERE id=?'); PREPARE stmt FROM @SqlCmd; SET @a = id; EXECUTE stmt USING @a; LEAVE lable_exit; END IF; IF name IS NOT NULL THEN SET @SqlCmd = CONCAT(@SqlCmd , 'WHERE name LIKE ?'); PREPARE stmt FROM @SqlCmd; SET @a = CONCAT(name, '%'); EXECUTE stmt USING @a; LEAVE lable_exit; END IF; END lable_exit;END; CALL `p1`(1,NULL);CALL `p1`(NULL,'QQ');DROP PROCEDURE `p1`;【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

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

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

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

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

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

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

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

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

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

 
 
cong MySQL 5.0 kai shi , zhi chi le yi ge quan xin de SQL ju fa : PREPARE stmt_name FROM preparable_stmt; EXECUTE stmt_name [USING @var_name [, @var_name] ...]; {DEALLOCATE | DROP} PREPARE stmt_name; tong guo ta , wo men jiu ke yi shi xian lei si MS SQL de sp_executesql zhi xing dong tai SQL yu ju ! tong shi ye ke yi fang zhi zhu ru shi gong ji ! wei le you yi ge gan xing de ren shi , xia mian xian gei ji ge xiao li zi : mysql> PREPARE stmt1 FROM 'SELECT SQRT(POW(?,2) + POW(?,2)) AS hypotenuse'; mysql> SET @a = 3; mysql> SET @b = 4; mysql> EXECUTE stmt1 USING @a, @b; +------------+ | hypotenuse | +------------+ | 5 | +------------+ mysql> DEALLOCATE PREPARE stmt1; mysql> SET @s = 'SELECT SQRT(POW(?,2) + POW(?,2)) AS hypotenuse'; mysql> PREPARE stmt2 FROM @s; mysql> SET @a = 6; mysql> SET @b = 8; mysql> EXECUTE stmt2 USING @a, @b; +------------+ | hypotenuse | +------------+ | 10 | +------------+ mysql> DEALLOCATE PREPARE stmt2; ru guo ni de MySQL ban ben shi 5.0.7 huo zhe geng gao de , ni huan ke yi zai LIMIT zi ju zhong shi yong ta , shi li ru xia :mysql> SET @a=1;mysql> PREPARE STMT FROM "SELECT * FROM tbl LIMIT ?"; mysql> EXECUTE STMT USING @a; mysql> SET @skip=1; SET @numrows=5; mysql> PREPARE STMT FROM "SELECT * FROM tbl LIMIT ?, ?"; mysql> EXECUTE STMT USING @skip, @numrows; shi yong PREPARE de ji ge zhu yi dian : A:PREPARE stmt_name FROM preparable_stmt; yu ding yi yi ge yu ju , bing jiang ta fu gei stmt_name ,stmt_name shi bu qu fen da xiao xie de 。 B: ji shi preparable_stmt yu ju zhong de ? suo dai biao de shi yi ge zi fu chuan , ni ye bu xu yao jiang ? yong yin hao bao han qi lai 。 C: ru guo xin de PREPARE yu ju shi yong le yi ge yi cun zai de stmt_name , na me yuan you de jiang bei li ji shi fang ! ji shi zhe ge xin de PREPARE yu ju yin wei cuo wu er bu neng bei zheng que zhi xing 。 D: PREPARE stmt_name de zuo yong yu shi dang qian ke hu duan lian jie hui hua ke jian 。 E: yao shi fang yi ge yu ding yi yu ju de zi yuan , ke yi shi yong DEALLOCATE PREPARE ju fa 。 F: EXECUTE stmt_name ju fa zhong , ru guo stmt_name bu cun zai , jiang hui yin fa yi ge cuo wu 。 G: ru guo zai zhong zhi ke hu duan lian jie hui hua shi , mei you xian shi di tiao yong DEALLOCATE PREPARE ju fa shi fang zi yuan , fu wu qi duan hui zi ji dong shi fang ta 。 H: zai yu ding yi yu ju zhong ,CREATE TABLE, DELETE, DO, INSERT, REPLACE, SELECT, SET, UPDATE, he da bu fen de SHOW ju fa bei zhi chi 。 G: PREPARE yu ju bu ke yi yong yu cun chu guo cheng , zi ding yi han shu ! dan cong MySQL 5.0.13 kai shi , ta ke yi bei yong yu cun chu guo cheng , reng bu zhi chi zai han shu zhong shi yong ! xia mian gei ge shi li : CREATE PROCEDURE `p1`(IN id INT UNSIGNED,IN name VARCHAR(11))BEGIN lable_exit: BEGIN SET @SqlCmd = 'SELECT * FROM tA '; IF id IS NOT NULL THEN SET @SqlCmd = CONCAT(@SqlCmd , 'WHERE id=?'); PREPARE stmt FROM @SqlCmd; SET @a = id; EXECUTE stmt USING @a; LEAVE lable_exit; END IF; IF name IS NOT NULL THEN SET @SqlCmd = CONCAT(@SqlCmd , 'WHERE name LIKE ?'); PREPARE stmt FROM @SqlCmd; SET @a = CONCAT(name, '%'); EXECUTE stmt USING @a; LEAVE lable_exit; END IF; END lable_exit;END; CALL `p1`(1,NULL);CALL `p1`(NULL,'QQ');DROP PROCEDURE `p1`;
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
时尚秀气模特裴裴(8)
时尚秀气模特裴裴(7)
时尚秀气模特裴裴(6)
时尚秀气模特裴裴(5)
白墙黑瓦
广州东郊[原创]
八美至丹巴的东谷天然盆景
不一样的
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有