DB/Oracle/PLSQL/ȿ

Top / DB / Oracle / PLSQL / ȿ

ܼ

ȿ֤LOOPWHILEFOR


LOOP ʸ

ñʤ롼ס

  • LOOP ʸ
    ...
    begin
        loop
            -- ֤򵭽
            ...
    
            -- exit ʸǥ롼פФ
            exit;
    
            -- λ
            exit when ... ;
        end loop;
    end;
    

WHILE ʸ

äȹʥ롼ס

LOOP ʸƱEXIT ˤ롣ĤޤȤ BREAK

  • WHILE ʸ
    ...
    begin
        -- P TRUE ΤȤϥ롼
        while hoge > 10 loop
            -- ֤򵭽
            ...
        end loop;
    end;
    

FOR ʸ

FOR ˤ롢ѿȤä롼ס

󥯥Ȥ̤ 1 Ǹꡣstep 2 ߤʤȤϤǤʤ

ѿɬפϤʤѤѿƱ̾Υ󥿤ѤϤǤ뤱ɤ⡢Ūˤ̤ѿȤư롣

LOOP ʸ WHILE ʸƱEXIT 롣

  • FOR ʸ
    ...
    begin
        -- c  1  10 ޤǥ󥯥Ȥν򷫤֤
        -- ѿ
        for c in 1..10 loop
            -- ֤򵭽
            ...
        end loop;
    
        -- ǥȤˤ reverse ꤹ
        for c in reverse 1..10 loop
            ...
        end loop;
    end;
    

FOR 롼

Ȥ߹碌ȡʣԤθ̤Ф FOR EACH ʸäݤưǤ롣

ܺ٤̥ڡ˵ҡ

롼פΥͥ

ɥͥȤǽ

END LOOP ˥٥ղäȡ¦Υ롼פνλ˳¦Υ롼פ⽪λǤ

  • 롼פΥͥ
    begin
        -- ñʥͥ
        loop
            loop
                ...
                exit when ...;
            end loop;
            exit when ...;
        end loop;
    
        -- ٥Ѥͥ
        <<hoge>> 
        loop
            loop
                ...
                exit when ...;
            -- ¦Υ٥ꤹ뤳Ȥб롼פ⽪λ
            end loop hoge;
        end loop;
    end;
    

å

CONTINUE롼פǽơΥ롼פ򳫻Ϥ롣

LOOP Ǥ⡢WHILE Ǥ⡢FOR ǤȤ롣

  • CONTINUE ʸ
    begin
        loop
            ....
            -- ʹߤν򤻤˼Υ롼פ򳫻Ϥ
            continue when ...;
            ....
        end loop;
    
    end;
    

Last-modified: 2011-11-08 () 15:39:52 (2361d)