An example Analysis of conditional Loop statement for comparing the difference between MySQL and Oracle
This article is to share with you the content of an example analysis of conditional loop statements for comparing the differences between MySQL and Oracle. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Loop statement
Numbered category ORACLEMYSQL comment 1IF statement uses a 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. Mysql and oracle use exactly the same if statement except that there is one word difference in keyword (ELSEIF/ELSIF).
2. Mysql if statement syntax: extracted from MySQL 5.1 reference manual 20.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 conditional construct. If the search_condition evaluation is true, the corresponding list of SQL statements is executed. If there is no search_condition match, the list of statements in the ELSE clause is executed. Statement_list can include one or more statements. 2FOR statement is different from 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
IF I > (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 = iTun1
END IF
END LOOP loopLable
1. Oracle uses the Forth statement to implement the loop.
Mysql uses the Loop statement to implement the loop.
2. Oracle uses For... Loop keyword.
Mysql uses loopLable:LOOP to implement loops. 3 while statements are different from WHILE lv_inputstr IS NOT NULL LOOP
...
END LOOP;WHILE lv_inputstr IS NOT NULL DO
...
The keyword of the whilestatement used in END WHILE;1. Oracle is: while expression loop... End loop
The keyword of using whilestatement in mysql is: while expression do … End while;, thank you for your reading! This is the end of the article on "sample Analysis of conditional Loop sentences for the comparison of MySQL and Oracle differences". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!