SAK }‘ŠÙ

SAK Streets ƒƒCƒ“ƒXƒgƒŠ[ƒg }‘ŠÙEƒJƒtƒF ˆê—— SAK Streets ŒŸõ
| VB | SQL | Perl | PHP | ASP | JSP | C | PC | HP | FAQ | ƒtƒŠ[ƒ\ƒtƒg |

VB oo4o + SQL ‰ž—p•Ò6 oo4o XV - CreateSqlAƒoƒbƒ`XV

oo4o ‚́AOracle RDBMS ‚Å‚ÝŽg—p‰Â”\‚Å‚·B

¡CreateSql ‚ł̃oƒbƒ`XV

  ECreateSql ‚ŁAƒoƒCƒ“ƒh”z—ñ(OraParamArray)‚ðŽg—p‚µ‚ăoƒbƒ`XV‚ª
    ‚Å‚«‚éB‚±‚ê‚Í•Ö—˜‚ÉŽg—p‚Å‚«‚éB

¡Œ»ŽÀ“I‚ȃR[ƒh—á

Option Explicit

'** oo4o •Ï”éŒ¾
  dim OraSession
  dim OraDatabase
  dim OraSqlStmt
  dim OraPArray(3)
  dim BachRowMax as long

'=======================================================================
'  €”õ
'=======================================================================
Private Sub Form_Load()

  dim dbname as string
  dim cnuser as string

'** ƒGƒ‰[ƒgƒ‰ƒbƒvŠJŽn
  on local error resume next

'** ƒAƒCƒLƒƒƒbƒ`•\Ž¦
  'Load FormLogo
  'FormLogo.Show
  'DoEvents
  '// Ú‘±‚É 10 •b‚Ù‚Ç‚©‚©‚é‚̂ŁAuƒf[ƒ^ƒx[ƒXÚ‘±’†...v‚È‚Ç‚Ì
  '// ƒ‚[ƒhƒŒƒXƒ_ƒCƒAƒƒO‚ð•\Ž¦‚·‚é‚Æ—Ç‚¢B

'** ƒT[ƒrƒXAƒ†[ƒUÝ’è
  dbname = ""
  cnuser = "SAK/SAK"
  '// Oracle ƒT[ƒrƒX–¼(•Ê–¼)Aƒ†[ƒUEƒpƒXƒ[ƒhŽw’è

'** oo4o Ú‘±
  Set OraSession = CreateObject("OracleInProcServer.XOraSession")
  if err <> 0 then
    MsgBox "ƒf[ƒ^ƒx[ƒX‚ɐڑ±o—ˆ‚Ü‚¹‚ñB" & chr(10) _
      & "CreateObject - Oracle oo4o ƒGƒ‰["
    end
  end if
  Set OraDatabase = OraSession.OpenDatabase(dbname, cnuser, ORADB_DEFAULT)
  if err <> 0 then
    MsgBox "ƒf[ƒ^ƒx[ƒX‚ɐڑ±o—ˆ‚Ü‚¹‚ñB" & chr(10) _
      & err & ": " & error
    end
  end if

'** ƒpƒ‰ƒƒ^’ljÁ
  BachRowMax = 10
  OraDatabase.Parameters.AddTable "ƒL[", ORAPARM_INPUT, ORATYPE_CHAR, BachRowMax, 4
  OraDatabase.Parameters.AddTable "ƒf[ƒ^1", ORAPARM_INPUT, ORATYPE_NUMBER, BachRowMax
  OraDatabase.Parameters.AddTable "ƒf[ƒ^2", ORAPARM_INPUT, ORATYPE_NUMBER, BachRowMax
  OraDatabase.Parameters.AddTable "ƒf[ƒ^3", ORAPARM_INPUT, ORATYPE_NUMBER, BachRowMax
  if err <> 0 or OraDatabase.LastServerErr <> 0 then
    MsgBox "ƒpƒ‰ƒƒ^’ljÁ‚ÉŽ¸”s‚µ‚Ü‚µ‚½B" & chr(10) _
      & err & ": " & error & chr(10) _
      & "oo4o: " & OraDatabase.LastServerErrText
    end
  end if

'** ƒpƒ‰ƒƒ^”z—ñ€”õ
  set OraPArray(0) = OraDatabase.Parameters("ƒL[")
  set OraPArray(1) = OraDatabase.Parameters("ƒf[ƒ^1")
  set OraPArray(2) = OraDatabase.Parameters("ƒf[ƒ^2")
  set OraPArray(3) = OraDatabase.Parameters("ƒf[ƒ^3")

'** ƒAƒCƒLƒƒƒbƒ`I—¹
  'Unload FormLogo
  '// Ú‘±‚ªŠ®—¹‚·‚ê‚΁Auƒf[ƒ^ƒx[ƒXÚ‘±’†...v‚ðƒNƒ[ƒY‚·‚éB

'** ƒGƒ‰[ƒgƒ‰ƒbƒvI—¹
  on local error goto 0

End Sub

'=======================================================================
'  ŒãŽn––
'=======================================================================
Private Sub Form_Unload(Cancel As Integer)

'** ƒpƒ‰ƒƒ^‰ðÁ
  OraDatabase.Parameters.Remove "ƒL["
  OraDatabase.Parameters.Remove "ƒf[ƒ^1"
  OraDatabase.Parameters.Remove "ƒf[ƒ^2"
  OraDatabase.Parameters.Remove "ƒf[ƒ^3"

'** ƒpƒ‰ƒƒ^ƒNƒGƒŠ‰ðÁ
  Set OraSqlStmt = Nothing

'** oo4o Ú‘±‰ðœ
  Set OraDatabase = Nothing
  Set OraSession = Nothing

End Sub

'=======================================================================
'  ƒƒCƒ“
'=======================================================================
Private Sub Command1_Click()

'** RDB ˆ—
  if RdbShori(OraDatabase) then
    msgbox "RDB XV³íI—¹B (ˆ—Œ”= " & OraSqlStmt.RecordCount & ")"
  end if

End Sub

'=======================================================================
'  RDB ˆ—
'=======================================================================
private function RdbShori(OraDatabase) as boolean

  dim i as long

'** ƒGƒ‰[ƒZƒbƒg
  RdbShori = FALSE

'** ƒGƒ‰[ƒgƒ‰ƒbƒvŠJŽn
  on local error resume next

'** oo4o ƒGƒ‰[ƒŠƒZƒbƒg
  OraDatabase.LastServerErrReset

'** ƒeƒXƒgƒf[ƒ^ì¬
  for i = 0 to BachRowMax - 1
    OraPArray(0).Put_Value Format(Int(Rnd(1) * 1000), "0000"), i
    OraPArray(1).Put_Value Int(Rnd(1) * 1000), i
    OraPArray(2).Put_Value Int(Rnd(1) * 1000), i
    OraPArray(3).Put_Value Int(Rnd(1) * 1000), i
  next

'** ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“ŠJŽn
  OraSession.BeginTrans

'** RDB ˆ—1
  Set OraSqlStmt = OraDatabase.CreateSql("insert into sak.ƒeƒXƒgm " _
    & "(ƒL[, ƒf[ƒ^1, ƒf[ƒ^2, ƒf[ƒ^3) values " _
    & "(:ƒL[, :ƒf[ƒ^1, :ƒf[ƒ^2, :ƒf[ƒ^3)", ORASQL_DEFAULT)
  if err <> 0 or OraDatabase.LastServerErr <> 0 then
    OraSession.Rollback
    MsgBox "RDB XV1 ‚ÉŽ¸”s‚µ‚Ü‚µ‚½B" & chr(10) _
      & err & ": " & error & chr(10) _
      & "oo4o: " & OraDatabase.LastServerErrText
    exit function
  end if

'** ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“I—¹
  OraSession.CommitTrans

'** ƒGƒ‰[ƒgƒ‰ƒbƒvI—¹
  on local error goto 0

'** ³íƒZƒbƒg
  RdbShori = TRUE

end function

¡à–¾

  EParameters.Add ‚Ì‘ã‚í‚è‚É Parameters.AddTable ‚ðŽg—p‚µ‚ÄŽŸŒ³”‚ðŽw’è
    ‚·‚éB‚±‚±‚ł́ABachRowMax = 10 ‚ðŽg—p‚µ‚Ä‚¢‚éB
    OraPArray ‚ÆŠÖ˜A•t‚¯‚āAŽÀÛ‚̃f[ƒ^‚ðƒeƒXƒg‚È‚Ì‚Å—”‚ŃZƒbƒgB
    CreateSql ‚ðŽÀs‚·‚é‚ƁA10 Œ‚̍XV‚ªs‚í‚ê‚éB

  EOraPArray ‚©‚çA’l‚ðŽQÆ‚·‚é‚ɂ́AGet_Value ‚ðŽg—p‚·‚éB
    OraPArray.LastErrorText ‚à‚ ‚éB

¡VB oo4o + SQL ‰ž—p•ÒŽ‘—¿
¡VB ADO + SQL ‰ž—p•ÒŽ‘—¿
¡VB RDO + SQL ‰ž—p•ÒŽ‘—¿
¡SQL Šî‘b•ÒŽ‘—¿
¡SQL Šî‘bŽÀ’n•ÒŽ‘—¿
¡SQL ƒ`ƒ…[ƒjƒ“ƒO•ÒŽ‘—¿
¡Oracle PL/SQL •ÒŽ‘—¿
¡PostgreSQL •ÒAJAVA ServletAJSP •ÒŽ‘—¿
¡MySQL •ÒŽ‘—¿
¡VB “ü–å•ÒŽ‘—¿
¡VB Šî‘b•ÒŽ‘—¿
¡VB ƒrƒWƒ…ƒAƒ‹•ÒŽ‘—¿
¡VB ƒeƒNƒjƒbƒN•ÒŽ‘—¿
| VB | SQL | Perl | PHP | ASP | JSP | C | PC | HP | FAQ | ƒtƒŠ[ƒ\ƒtƒg |

SAK Streets ƒƒCƒ“ƒXƒgƒŠ[ƒg }‘ŠÙEƒJƒtƒF ˆê—— SAK Streets ŒŸõ



Copyright (C) 1999-2017 Y.SAK