首页 > 编程知识 正文

mysql存储过程实例详解,mysql调试存储过程

时间:2023-05-03 19:31:48 阅读:168186 作者:1185

类似语法问题,但其实请参考手册的说明和例子。

MySQL 5.4 reference manual 12.8.6.1.if statement

if search _ conditionthenstatement _ list

END IF

ifimplementsabasicconditionalconstruct.ifthe search _ conditionevaluatestotrue,thecorrespondingsqlstatementlistisexecuted

笔记本

thereisalsoanif(function,whichdiffersfromtheifstatementdescribedhere.see section 11.3,“控制流功能”)。

An IF . END IF block,likeallotherflow-controlblocksusedwithinstoredprograms,must be terminated with a semicolon,asshowninthinthion

DELIMITER //。

createfunctionsimplecompare (nint,m INT )。

返回变量(20 )。

比根

戴尔varchar (20 );

IF n m THEN SET s=' ';

ELSEIF n=m THEN SET s='=';

ELSE SET s='

END IF;

sets=concat(n,',s,',m );

返回s;

结束//

删除器

aswithotherflow-control constructs,if . endifblocksmaybenestedwithinotherflow-control constructs, includingotherifstatements.eachifmustbeterminatedbyitsownendiffollowedbyasemicolon.youcanuseindentationtomakenestedflow-ow ed flow-olblocksmoreeasilyreadablebyhumans (althoughthisisnotrequiredbymysql ),as shown here:

DELIMITER //。

createfunctionverbosecompare (nint,m INT ) )。

返回变量(50 )。

比根

declareSvarchar(50;

IF n=m THEN SET s='equals ';

ELSE

IF n m THEN SET s='greater ';

ELSE SET s='less ';

END IF;

sets=concat('is ',s,' than ' );

END IF;

sets=concat(n,',s,',m,'.');

返回s;

结束//

删除器

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。