DB/Oracle/PLSQL/㳰

ܼ

㳰פ󡣤̤ݡ


Ū㳰

ȤѤʤ SELECT ... INTO ʸǡ֤꤬ʣԤä䡢0 ä㳰ʻѤߤ㳰ǡ줾 too_many_rowsno_data_foundˤȯ롣Τ褦ʤȤˡPL/SQL EXCEPTION ˽ܤ

ջ

  • 顼ȯȤ㳰ǽǤС PL/SQL ֥åΤェλˤʤ롣դ곰Υ顼ȯϡƤӽФʤȤ SQL*Plusˤ˥顼᤹ƤӽФ˥顼᤹ΤϥץȤƤϤХǤʤΤǡ OTHERS 㳰ϥɥȤäۤ褤֤
  • 㳰ǥ顼Ȥ˼¹᤹ȤϤǤʤ̵ʤ顢顼ȯսͥȤƵҤФǤ
  • ³Υǡ١ˤäȯ륨顼 PL/SQL 㳰νоݳȤ¸ߤʤɽФ SELECT ʸȯԻϡPL/SQL ǤϤʤ Oracle Database 饨顼롣Τ褦㳰 OTHERS ϥɥǤ⥭åǤʤ

㳰μ

Ѥߤ㳰Τ̤ۤ㳰桼㳰Ѳǽ

Ѥ㳰ȤϡPL/SQL ˤäƴѰդƤ㳰Τȡ

Ѥ㳰ˤϰʲΤ褦ʤΤ롣ܺ٤ Oracle Oracle Database PL/SQL ե٤򻲾ȡ

  • 㳰̣̾
    NO_DATA_FOUND1 ԤǤ٤䤤碌η̤ 0 äȤ
    TOO_MANY_ROWS1 ԤǤ٤䤤碌η̤ʣԤäȤ
    INVALID_CURSOR̵ʥԤäȤ
    ZERO_DIVIDEԤäȤ
    DUP_VAL_ON_INDEXͤʣƤȤ

Ȥ

Ū㳰 ޤˤ졣ä򸫤褦

Oracle Υ顼ֹϤ뤱ɡѤߤΤ褦˻Ȥ䤹̾դƤʤ㳰㳰ǽˤϡ顼ֹб̾ʬǤĤɬפ롣

Ȥ

ϰʲ̤ꡣ

  1. 㳰̾
  2. 㳰̾ȥ顼ֹδϢդ
  3. 㳰Ǥ
  • Ȥ

桼㳰

桼㳰롼ˤĤȤФͤ 100 ʾǤϤʤ ƤȤȤ

ñꤲƼƽδñʥ桼㳰뤷Oracle ǻȤƤʤ顼ֹղä Oracle ȯ顼Ǥ뤫Τ褦ˤդޤ碌뤳ȤǤ롣

Ȥ

ñϤ

  • ñʥ桼㳰

Oracle Υ顼äݤդޤ碌뤳Ȥǽ顼ֹդơǡ١Υ顼ǽȤäꤲ롣ۤ Oracle 㳰Ʊˡǥ桼㳰ⰷΤǡ߷׾㳰ΤΤڤˤʤ롣

Ȥ륨顼ֹϡ-20000 -20999 Τ줫

  • ȥɥץѤ桼㳰

㳰дؿ

㳰ǻȤʴؿ

SQLCODE

㳰Υ顼ֹ֤ؿ

  • SQLCODE ֤ͤ
    0㳰ȯƤʤ
    1桼㳰
    +100NO_DATA_FOUND 㳰
    -NOracle ֤顼ֹ

SQLERRM

㳰Υ顼å֤ؿΤޤޡ

Ȥ

㳰Ѥ롣SQL ʸľܤδؿ뤳ȤϵĤʤΤǡȤмΥ顼ơ֥ʤɤϡ̤ѿ˳ǼƤȤɬפ롣

  • Ȥ

Ǥϡ顼åĹȤơѿΥХȿȾʬǤ 50 顼åڤФƤ롣VARCHAR2 ǻꤹΤϥХȿǡSUBSTR ǻꤹΤʸʤΤǡܸǤ 100 ХȤѿˤ 50 ʸʤ1 ʸ = 2 ХȡʸɤˤäƤ 3 ХȤʤΤ 33 ʸˡ

ܸĶȤäƤ٤ƤΥ顼åܸǤȤ櫓ǤʤϱѸΤޤޡΤ褦ڤФ򤹤ȡѸΥå 50 ʸ50 ХȡˤڤƤޤ

VARCHAR2 ϲĹʸʤΤ礭ͤꤷƤ򿩤櫓ǤϤʤѤƽʬ礭ͤȤäƤȤб뤫뤤ϥåΥѸˤʤɤƤбǤʤȤʤ

ޤǤ⥨顼Ѹ줬ȾʬǤڤ줿ȤƤ⡢٤Ĥˤ󤸤ʤʤȤϻפɡ


Last-modified: 2011-11-09 () 11:50:31