DB/Oracle/PLSQL/

ܼ


μ

äƤΤϡΰФݥ󥿡ŪˤϡSQL ʸ¹ԤȤη̥åȤФ롢ߤνоݤǤԤؤΥݥ󥿤ΤȡȰۥ뤬롣ɽ򤴤ˤ礴ˤ礹ȤˡɤιԤ򸫤Ƥ뤫ȤŪ˻äƤ褦ʴ

ۥ뤬롣

  • μ
    ۥDML SELECT ʸμ¹ԻˡPL/SQL 󤬾˺륫
    ץ񤯤ȤȤˤƤȻȤΥ롣 SELECT ʸη̤ʣԤˤʤȤ˻Ȥ

ۥ

DML SELECT ʸȯԻPL/SQL ˤäƾ˺ƻȤ˴륫롣ɬפ˱ƾΤǡưϰռɬפϤʤ

ľ SQL ʸμ¹Է̤˴ؤ SQL °ȤƤĤΤǡϳѤǤ롣򻲾Ȥ뤳Ȥǡľ SQL ʸɤΤ褦˽줿狼롣

°

  • SQL °μ
    °
    SQL%FOUND֡뷿ľ SQL ʸ 1 ԰ʾ֤äƤ TRUE
    SQL%NOTFOUND֡뷿ľ SQL ʸ 1 Ԥ֤äƤʤä TRUE
    SQL%ROWCOUNTľ SQL ʸDZƶԿ
  • SQL °

ץޤŪ롢̥åȤФݥ󥿡

̾SQL ǤϹñ̤ǤǤʤΤǡʣԤ᤹䤤碌ʤɤˤŪ˽оݤȤԤꤷʤȤʤ

äȤȤϰʲ

    • CORSOR hoge IS SELECT ...;
  1. Υץ
    • OPEN hoge;
      • ˴Ϣդ줿 SQL ʸ¹
      • ̥åȤΰܤإå
  2. եå
    • FETCH hoge INTO fuga;
      • ΤԤΥǡѿسǼ
      • 򼡤ιԤذư
  3. Υ
    • CLOSE hoge;
      • ȷ̥åȤβ

Ūʽ

ǡǤդ SELECT ʸ򥫡ȴϢդǤ롣ѿǼѤ INTO ϴޤʤɬפ˱ ORDER BY ǥȤʷ̥åȤΥȤϤǤʤ༡ưǤʤˡ

ѥ᡼ղ

˥ѥ᡼ղäơץ󤹤ȤͤϤ롣ץϤѥ᡼Ѥ뤳Ȥǡ¹Ԥ SQL ʸͤưŪѹǤ롣

WHERE Ϳͤʤɤ򥪡ץ󤹤뤿ӤưŪѹǤΤǡƱѤǤƸΨɤ

  • ѥ᡼ղ

°

ۥˤ⤢ä°ˡISOPEN ɲäƤ롣

%NOTFOUND %ROWCOUNT 褯Ȥ%ISOPEN ϥκƥץξ֥åʤɤ˻Ѥ롣Ȥ⤢뤫⤷ʤ

  • °μ
    °
    %ISOPEN֡뷿뤬ץ󤷤Ƥ TRUE
    %FOUND֡뷿ǿΥեå 1 ԰ʾ֤äƤ TRUE
    %NOTFOUND֡뷿ǿΥեå 1 Ԥ֤äƤʤä TRUE
    %ROWCOUNTޤǤ˥եåäƤԤι׿
  • °

FOR 롼

̤Ф FOR EACH ߤʤΡ

ץ󡢥եåλϰŪ˽Τǵס

  • FOR 롼

䤤碌ѤСάǤ롣ɤβΤȡ°Ȥʤʤա

  • 䤤碌Ѥ FOR 롼

Last-modified: 2011-11-08 () 16:59:58