Loop Sql
时间:2021-07-01 10:21:17
帮助过:5人阅读
Numeric FOR loop --
set serveroutput
on -->> do not use in TOAD --
DECLARE
k NUMBER:
= 0;
BEGIN
FOR i
IN 1..
10 LOOP
k:= k
+1;
dbms_output.put_line(i||‘ ‘||k);
END LOOP;
END;
/
-- Cursor FOR loop --
set serveroutput
on
DECLARE
CURSOR c1
IS SELECT * FROM scott.emp;
i NUMBER:
= 0;
BEGIN
FOR e_rec
IN c1 LOOP
i:= i
+1;
dbms_output.put_line(i||chr(
9)
||e_rec.empno
||chr(
9)
||e_rec.ename);
END LOOP;
END;
/
-- SQL example to generate 10 rows --
SELECT 1 + LEVEL-1 idx
FROM dual
CONNECT BY LEVEL <= 10
/
Loop Sql
标签:rom connect amp bsp font ber cursor for loop --