plsqlÖÐelseµÄÓ÷¨
pl/sql ÖÐ else ×Ó¾äÔÚ if-then-else Óï¾äÖÐÖ¸¶¨Ìõ¼þΪ¼ÙʱµÄÌæ»»Ö´Ðз¾¶£¬Ó﷨Ϊ£ºif condition then ´úÂë¿é 1 else ´úÂë¿é 2 end if¡£ËüµÄÓ÷¨°üÀ¨£ºÖ¸¶¨Ìõ¼þΪ¼ÙʱµÄ²Ù×÷¡¢´¦Àí²î±ðЧ¹ûºÍ´¦ÀíÌØÊâÇéÐΡ£
PL/SQL ÖÐ ELSE ×Ó¾äµÄÓ÷¨
ELSE ×Ó¾äÓÃÓÚÔÚ PL/SQL ¿ØÖÆÓï¾ä£¨Èç IF-THEN-ELSE£©ÖÐÖ¸¶¨µ±Ìõ¼þΪ¼ÙʱµÄÌæ»»Ö´Ðз¾¶¡£
Óï·¨
IF condition THEN -- ´úÂë¿é 1 -- ÈôÊÇÌõ¼þΪÕ棬ÔòÖ´ÐÐ ELSE -- ´úÂë¿é 2 -- ÈôÊÇÌõ¼þΪ¼Ù£¬ÔòÖ´ÐÐ END IF;
µÇ¼ºó¸´ÖÆ
Ó÷¨
ELSE ×Ó¾äÔÚÒÔÏÂÇéÐÎÏÂʹÓãº
µ±ÐèÒªÔÚÌõ¼þ²»Öª×ãʱִÐÐÌض¨²Ù×÷ʱ¡£
µ±ÐèÒªÔÚÁ½ÖÖ»ò¸ü¶àÖÖ¿ÉÄܵÄЧ¹ûÖ®¼ä¾ÙÐÐÑ¡Ôñʱ¡£
µ±ÐèÒª´¦ÀíÌõ¼þΪ¼ÙµÄÌØÊâÇéÐÎʱ¡£
ʾÀý
-- ¼ì²éÒ»¸öÊý×ÖÊÇ·ñÊÇżÊý DECLARE number NUMBER := 10; BEGIN IF number MOD 2 = 0 THEN DBMS_OUTPUT.PUT_LINE('¸ÃÊý×ÖÊÇżÊý¡£'); ELSE DBMS_OUTPUT.PUT_LINE('¸ÃÊý×ÖÊÇÆæÊý¡£'); END IF; END;
µÇ¼ºó¸´ÖÆ
Êä³ö:
¸ÃÊý×ÖÊÇżÊý¡£
µÇ¼ºó¸´ÖÆ
×¢ÖØ:
ELSE ×Ó¾äÊÇ¿ÉÑ¡µÄ¡£ÈôÊDz»Ìṩ£¬Ôòµ±Ìõ¼þΪ¼Ùʱ£¬¿ØÖÆÁ÷³Ì½«¼ÌÐøÖ´ÐкóÐø´úÂë¡£
ELSE ×Ó¾äÖ»ÄÜÓë IF Óï¾äÒ»ÆðʹÓá£
ELSE ×Ó¾ä¿ÉÒÔǶÌ×ÔÚÆäËû IF Óï¾äÖС£
ELSE ×Ó¾ä¿ÉÒÔÓë ELSIF ×Ó¾äÒ»ÆðʹÓã¬ÒÔʵÏÖ¸üÖØ´óµÄ·ÖÖ§Âß¼¡£
ÒÔÉϾÍÊÇplsqlÖÐelseµÄÓ÷¨µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡