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•Ò5 oo4o XV - CreateSqlARefresh

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

¡CreateSql ‚ł̍XV

  ECreateSql ‚Å‚àƒoƒCƒ“ƒh•Ï”‚ðŽg—p‚µ‚½XV‚ª‚Å‚«‚éB

¡OraSQLStmt ƒƒ\ƒbƒh

  OraSQLStmt.Refresh        (ƒŠƒNƒGƒŠ)
  Set OraSqlStmt = Nothing  (OraSQLStmt ”jŠü)

¡OraSQLStmt ƒvƒƒpƒeƒB

  OraSQLStmt.RecordCount    (ˆ—Œ”)

¡CreateSql ’萔

  Public Const ORASQL_DEFAULT     = &H0
  Public Const ORASQL_NO_AUTOBIND = &H1
  Public Const ORASQL_FAILEXEC    = &H2

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

Option Explicit

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

'=======================================================================
'  €”õ
'=======================================================================
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

'** SQL ì¬
  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 OraDatabase.LastServerErr = 1008 then OraDatabase.LastServerErrReset
  if err <> 0 or OraDatabase.LastServerErr <> 0 then
    MsgBox "SQL ì¬‚ÉŽ¸”s‚µ‚Ü‚µ‚½B" & chr(10) _
      & err & ": " & error & chr(10) _
      & "oo4o: " & OraDatabase.LastServerErrText
    end
  end if

'** ƒpƒ‰ƒƒ^’ljÁ
  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ƒ‰ƒƒ^’ljÁ‚ÉŽ¸”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"

'** ƒ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"
  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
  OraSqlStmt.Refresh
  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
  OraSqlStmt.Refresh
  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
  Eif OraDatabase.LastServerErr = 1008 then OraDatabase.LastServerErrReset
    ‚́ASQL ‚ðì‚邾‚¯‚ÉŽg—p‚µ‚½ CreateSQL ‚̃oƒCƒ“ƒhƒGƒ‰[‚ðƒŠƒZƒbƒgB
    æ‚Ƀpƒ‰ƒƒ^‚ð’ljÁ‚·‚é‚ƃGƒ‰[‚É‚È‚ç‚È‚¢‚ªASQL ‚ªŽÀs‚³‚ê‚Ä‚µ‚Ü‚¤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