一、false、true、null 的逻辑运算 如上图所示;
二、循环语句LOOP
Syntax:
LOOP
statement1;
......................
exit [ where condition ];
end LOOP;
三、while 循环
WHILE CONDITION LOOP
STATEMENT1;
STATEMENT2;
END LOOP;
四、for循环
for counter in [ reverse ]
lower_bound..upper_bound LOOP
STATEMENTS1;
STATEMENTS2;
....
end loop;
1) User a FOR loop to shortcut the test for the number of iterations
2) Do not declare the counter ; it is declared implicity.
3) DECLARE
V_countryid locations.country_id %type := 'CA';
v_loc_id locations.location_id %TYPE ;
v_new_city locations.city%type := 'Montreal';
BEGIN
SELECT MAX( location_id ) into v_loc_id FROM locations
where country_id = v_countryid;
FOR i IN 1...3 LOOP ---i 只能递增1,如果不想则请使用其他的循环如while 设置
INSERT INTO locations (location_id ,city, country_id)
VALUES ( (v_loc_id +i) , v_new_city , v_countryid);
END LOOP;
END;