WEB开发网
开发学院数据库Oracle 从SQL SERVER 向ORACLE 8迁移的技术实现方案(2) 阅读

从SQL SERVER 向ORACLE 8迁移的技术实现方案(2)

 2008-09-08 12:52:54 来源:WEB开发网   
核心提示: (2)WHILE循环语句:语法:WHILE condition LOOP{ statement | statement_block } ;END LOOP ;示例1:v_Counter BINARY_INTEGER := 1;BEGIN-- Test the loop counter be

(2)WHILE循环语句:

语法:

WHILE condition LOOP
{ statement | statement_block } ;
END LOOP ;

示例1:

v_Counter BINARY_INTEGER := 1;
BEGIN
-- Test the loop counter before each loop iteration to
-- insure that it is still less than 50.
WHILE v_Counter <= 50 LOOP
INSERT INTO temp_table
VALUES (v_Counter, 'Loop index');
v_Counter := v_Counter + 1;
END LOOP;
END;

示例2:

v_Counter BINARY_INTEGER;
BEGIN
-- This condition will evaluate to NULL, since v_Counter
-- is initialized to NULL by default.
WHILE v_Counter <= 50 LOOP
INSERT INTO temp_table
VALUES (v_Counter, 'Loop index');
v_Counter := v_Counter + 1;
END LOOP;
END;

(3)数字式FOR循环语句:

语法:

FOR loop_counter IN [REVERSE] low_bound..high_bound LOOP
{ statement | statement_block } ;
END LOOP ;

这里,loop_counter是隐式声明的索引变量。

示例1:

FOR循环的循环索引被隐式声明为BINARY_INTEGER。在循环前面没有

必要声明它,如果对它进行了声明,那么循环索引将屏蔽外层的声明,

如下所示

v_Counter NUMBER := 7;
BEGIN
-- Inserts the value 7 into temp_table.
INSERT INTO temp_table (num_col)
VALUES (v_Counter);
-- This loop redeclares v_Counter as a BINARY_INTEGER, which
-- hides the NUMBER declaration of v_Counter.
FOR v_Counter IN 20..30 LOOP
-- Inside the loop, v_Counter ranges from 20 to 30.
INSERT INTO temp_table (num_col)
VALUES (v_Counter);
END LOOP;
-- Inserts another 7 into temp_table.
INSERT INTO temp_table (num_col)
VALUES (v_Counter);
END;

上一页  4 5 6 7 8 9 10  下一页

Tags:SQL SERVER ORACLE

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接