Comparison between MySQL and Oracle: Four-condition loop statement: mysqloracle

Source: Internet
Author: User

Comparison between MySQL and Oracle: Four-condition loop statement: mysqloracle

Loop statement

No. Category ORACLE MYSQL Note
1 IF statements use different IF iv_weekly_day = 'mon 'THEN
Ii_weekly_day: = 'mon ';
ELSIF iv_weekly_day = 'tue 'THEN
Ii_weekly_day: = 'tue ';
End if;
IF iv_weekly_day = 'mon 'THEN
Set ii_weekly_day = 'mon ';
ELSEIF iv_weekly_day = 'tue 'THEN
Set ii_weekly_day = 'tue ';
End if;
1. Apart from the keyword differences between mysql and oracle (ELSEIF/ELSIF), the if statement is identical.
2. mysql if statement Syntax: From MySQL 5.1 reference manual limit 2.12.1. IF statement
IF search_condition THEN statement_list
[ELSEIF search_condition THEN statement_list]...
[ELSE statement_list]
END IF
IF implements a basic condition structure. If search_condition is evaluated as true, the corresponding SQL statement list is executed. If no search_condition match exists, the Statement List in the ELSE clause is executed. Statement_list can contain one or more statements.
2 Different FOR statements FOR li_cnt IN 0 .. (ii_role_cnt-1) LOOP
Select count (*) INTO li_role_ik_cnt FROM SD_ROLE
WHERE ROLE_CD = lo_aas_role_upl (li_cnt );
IF li_role_ik_cnt = 0 THEN
RETURN 'n ';
End if;
Li_role_ik_cnt: =-3;
End loop;
LoopLable: LOOP
(Ii_role_cnt-1) THEN
LEAVE looplable;
ELSE
Select count (*) INTO li_role_ik_cnt FROM SD_ROLE
WHERE ROLE_CD = 'admin _ super';/* lo_aas_role_upl (li_cnt );*/
IF li_role_ik_cnt = 0 THEN
RETURN 'n ';
End if;
SET li_role_ik_cnt =-3;
SET I = I + 1;
End if;
End loop loopLable;

1. oracle uses the For statement to implement a loop.
Mysql uses Loop statements to implement loops.
2. oracle uses... Loop keyword.
Mysql uses loopLable: LOOP to implement loops.
3 The while statement is different. WHILE lv_inputstr IS NOT NULL LOOP
...
End loop;
WHILE lv_inputstr IS NOT NULL DO
...
End while;
1. Use the while statement keyword in oracle: while expression loop... End loop;
Mysql uses the while statement Keyword: while expression do... End while;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.