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•Ō4 oo4o XV - ƒoƒCƒ“ƒh•Ï”AParameters

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

ĄƒoƒCƒ“ƒh•Ï”

  EƒoƒCƒ“ƒh•Ï”‚ðŽg—p‚ĩ‚―XV‚ðs‚ĪŽ–‚Š‚Å‚Ŧ‚éB
    Oracle ƒT[ƒoã‚ĖƒLƒƒƒbƒVƒ… SQL ‚Š—˜—p‚Å‚Ŧ‚é‚Ė‚ō‚‘Ž‚É‚Č‚éB

Ąƒpƒ‰ƒƒ^ėŽ

  EParameters.Add ‚́Aƒpƒ‰ƒƒ^‚ð’Į‰Á‚·‚éB
    ServerType ‚Ń^ƒCƒv‚āŽw’č‚·‚éB(OraParameter)

  OraDatabase.Parameters.Add "ƒoƒCƒ“ƒh•Ï”–ž", 0, ORAPARM_INPUT
                                       ‰Šú’l _|  |
                             “ü—Í ORAPARM_INPUT  _|
                             o—Í ORAPARM_OUTPUT
                             I/O  ORAPARM_BOTH

  OraDatabase.Parameters("ƒoƒCƒ“ƒh•Ï”–ž").ServerType = ORATYPE_CHAR
                                      ORATYPE_VARCHAR2 _|
                                      ORATYPE_NUMBER
                                      ORATYPE_SINT
                                      ORATYPE_FLOAT
                                      ORATYPE_STRING
                                      ORATYPE_VARCHAR
                                      ORATYPE_DATE
                                      ORATYPE_UINT
                                      ORATYPE_CHAR
                                      ORATYPE_CHARZ
                                      ORATYPE_CURSOR

  EValue ‚Ńpƒ‰ƒƒ^‚É’l‚ðƒZƒbƒg‚·‚éB

  OraDatabase.Parameters("ƒoƒCƒ“ƒh•Ï”–ž").Value = "a001"

  EParameters.Remove ‚́Aƒpƒ‰ƒƒ^‚Ė’Į‰Á‚ð‰ðÁ‚·‚éB

  OraDatabase.Parameters.Remove "ƒoƒCƒ“ƒh•Ï”–ž"

Ąƒpƒ‰ƒƒ^’萔

'** ƒpƒ‰ƒƒ^“üo—Í
  Public Const ORAPARM_INPUT    = 1
  Public Const ORAPARM_OUTPUT   = 2
  Public Const ORAPARM_BOTH     = 3

'** ƒpƒ‰ƒƒ^ƒ^ƒCƒv
  Public Const ORATYPE_VARCHAR2 = 1
  Public Const ORATYPE_NUMBER   = 2
  Public Const ORATYPE_SINT     = 3
  Public Const ORATYPE_FLOAT    = 4
  Public Const ORATYPE_STRING   = 5
  Public Const ORATYPE_VARCHAR  = 9
  Public Const ORATYPE_DATE     = 12
  Public Const ORATYPE_UINT     = 68
  Public Const ORATYPE_CHAR     = 96
  Public Const ORATYPE_CHARZ    = 97
  Public Const ORATYPE_CURSOR   = 102

ĄŒŧŽĀ“I‚ČƒR[ƒh—á

Option Explicit

'** oo4o •Ï”éŒū
  dim OraSession
  dim OraDatabase

'=======================================================================
'  €”õ
'=======================================================================
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ƒ‰ƒƒ^’Į‰Á
  OraDatabase.Parameters.Add "ƒL[", 0, ORAPARM_INPUT
  OraDatabase.Parameters("ƒL[").ServerType = ORATYPE_CHAR
  OraDatabase.Parameters.Add "ƒf[ƒ^1", 0, ORAPARM_INPUT
  OraDatabase.Parameters("ƒf[ƒ^1").ServerType = ORATYPE_NUMBER
  OraDatabase.Parameters.Add "ƒf[ƒ^2", 0, ORAPARM_INPUT
  OraDatabase.Parameters("ƒf[ƒ^2").ServerType = ORATYPE_NUMBER
  OraDatabase.Parameters.Add "ƒf[ƒ^3", 0, ORAPARM_INPUT
  OraDatabase.Parameters("ƒf[ƒ^3").ServerType = ORATYPE_NUMBER
  if err <> 0 or OraDatabase.LastServerErr <> 0 then
    MsgBox "ƒpƒ‰ƒƒ^’Į‰Á‚ÉŽļ”s‚ĩ‚Ü‚ĩ‚―B" & chr(10) _
      & err & ": " & error & chr(10) _
      & "oo4o: " & OraDatabase.LastServerErrText
    end
  end if

'** ƒ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"

'** 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"
  end if

End Sub

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

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

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

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

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

'** RDB ˆ—1
  OraDatabase.Parameters("ƒL[").Value = "a001"
  OraDatabase.Parameters("ƒf[ƒ^1").Value = 10
  OraDatabase.Parameters("ƒf[ƒ^2").Value = 20
  OraDatabase.Parameters("ƒf[ƒ^3").Value = 30

  OraDatabase.ExecuteSQL "insert into sak.ƒeƒXƒgm " _
    & "(ƒL[, ƒf[ƒ^1, ƒf[ƒ^2, ƒf[ƒ^3) values " _
    & "(:ƒL[, :ƒf[ƒ^1, :ƒf[ƒ^2, :ƒf[ƒ^3)"
  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

'** RDB ˆ—2
  OraDatabase.Parameters("ƒL[").Value = "b002"
  OraDatabase.Parameters("ƒf[ƒ^1").Value = 100
  OraDatabase.Parameters("ƒf[ƒ^2").Value = 200
  OraDatabase.Parameters("ƒf[ƒ^3").Value = 300

  OraDatabase.ExecuteSQL "insert into sak.ƒeƒXƒgm " _
    & "(ƒL[, ƒf[ƒ^1, ƒf[ƒ^2, ƒf[ƒ^3) values " _
    & "(:ƒL[, :ƒf[ƒ^1, :ƒf[ƒ^2, :ƒf[ƒ^3)"
  if err <> 0 or OraDatabase.LastServerErr <> 0 then
    OraSession.Rollback
    MsgBox "RDB XV2 ‚ÉŽļ”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

Ąā–ū

  Eƒoƒ‰ƒƒ^‚ĖėŽ‚ƉðÁ‚́AForm_Load ‚Æ Form_Unload ‚ÅŽĀŽ{‚ĩ‚Ä‚Ē‚éB
    “Ŋ‚ķXV SQL ‚Š‘å—Ę‚É”­ķ‚·‚éƒpƒ^[ƒ“‚ÉŒø‰Ę‚Š‚ ‚é‚ƍl‚Ķ‚éB
    ƒR[ƒh‚͏­‚ĩ•ĄŽG‚É‚Č‚é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