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; |