Oracle PLSQL Demo - 04.数字FOR LOOP循环[NUMBERABLE (FOR) LOOP]

declare
    v_display varchar2(10);
begin

    for i in 1 .. 100 loop

        for j in reverse 1 .. 10 loop
            dbms_output.put_line(i || ‘ - ‘ || j);
        end loop;

    end loop;

end;
时间: 2024-12-21 01:20:52

Oracle PLSQL Demo - 04.数字FOR LOOP循环[NUMBERABLE (FOR) LOOP]的相关文章

Oracle PLSQL Demo - 05.WHILE循环[WHILE LOOP]

declare v_sal number := 6000; begin while (v_sal < 8000) loop v_sal := v_sal + 1; dbms_output.put_line(v_sal); end loop; end;

Oracle PLSQL Demo - 07.LOOP循环,以EXIT WHEN退出[EXIT in LOOP]

declare v_sal number := 6000; begin loop v_sal := v_sal + 1; dbms_output.put_line(v_sal); exit when v_sal = 8000; end loop; end;

Oracle PLSQL Demo - 06.LOOP循环,以IF判断退出[IF in LOOP]

declare v_sal number := 6000; begin loop v_sal := v_sal + 1; dbms_output.put_line(v_sal); if v_sal = 8000 then exit; end if; end loop; end;

Oracle PLSQL Demo - 10.For Loop遍历游标[FOR LOOP CURSOR]

declare cursor cur_emp is select t.* from scott.emp t; begin for r_emp in cur_emp loop dbms_output.put_line(r_emp.empno || ' ' || r_emp.sal); end loop; end;

Oracle PLSQL Demo - 18.01管道function[查询零散的字段组成list管道返回]

--PACKAGE CREATE OR REPLACE PACKAGE test_141213 is TYPE type_ref IS record( ENAME VARCHAR2(20), WORK_CITY VARCHAR2(20), SAL NUMBER(10)); TYPE t_type_ref IS TABLE OF type_ref; FUNCTION retrieve(v_name varchar2) RETURN t_type_ref PIPELINED; END test_14

Oracle PLSQL Demo - 16.弱类型REF游标[没有指定查询类型,已指定返回类型]

declare Type ref_cur_variable IS REF cursor; cur_variable ref_cur_variable; rec_emp scott.emp%RowType; v_sql varchar2(100) := 'select * from scott.emp t'; begin Open cur_variable For v_sql; Loop fetch cur_variable InTo rec_emp; Exit When cur_variable

Oracle PLSQL Demo - 20.弱类型REF游标[没有指定查询类型,也不指定返回类型]

declare Type ref_cur_variable IS REF cursor; cur_variable ref_cur_variable; v_ename varchar2(10); v_deptno number(2); v_sal number(7,2); v_sql varchar2(100) := 'select t.ename, t.deptno, t.sal from scott.emp t'; begin Open cur_variable For v_sql; Loo

Oracle PLSQL Demo - 19.管道function[查询整表组成list管道返回]

create or replace function function_demo RETURN emp PIPELINED as Type ref_cur_emp IS REF CURSOR RETURN emp%RowType; cur_emp ref_cur_emp; rec_emp cur_emp%RowType; begin Open cur_emp For select * from emp t; Loop fetch cur_emp InTo rec_emp; Exit When c

Oracle PLSQL Demo - 18.02.管道function[查询零散的字段组成list管道返回] [字段必须对上]

--PACKAGE CREATE OR REPLACE PACKAGE test_141215 is TYPE type_ref IS record( ENAME VARCHAR2(20), SAL NUMBER(10)); TYPE t_type_ref IS TABLE OF type_ref; FUNCTION retrieve(v_name varchar2) RETURN t_type_ref PIPELINED; END test_141215; -- PACKAGE BODY CR