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•Ò8 oo4o ƒXƒgƒAƒhƒtƒ@ƒ“ƒNƒVƒ‡ƒ“ - PL/SQL ƒuƒƒbƒN

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

¡ƒXƒgƒAƒhƒtƒ@ƒ“ƒNƒVƒ‡ƒ“ / ƒXƒgƒAƒhƒvƒƒVƒWƒƒ

  EExecuteSql ‚Å‚ÌŽÀs

  Dim pret

'** ƒpƒ‰ƒƒ^’ljÁ
  OraDatabase.Parameters.Add "ret", 0, ORAPARM_OUTPUT
  set pret = OraDatabase.Parameters("ret")
  pret.ServerType = ORATYPE_VARCHAR2

'** ƒXƒgƒAƒhƒtƒ@ƒ“ƒNƒVƒ‡ƒ“ŽÀs
  OraDatabase.ExecuteSql "begin :ret := sak.GetTmp(); end;"

'** –ß‚è’lŽæ“¾
  msgbox pret.value

'** ƒpƒ‰ƒƒ^‰ðÁ
  OraDatabase.Parameters.Remove "ret"

  ECreateSql ‚Å‚ÌŽÀs

  Dim OraSqlStmt
  Dim pret

'** SQL ì¬
  Set OraSqlStmt = OraDatabase.CreateSql("begin :ret := sak.GetTmp(); end;" _
    , ORASQL_DEFAULT)

'** ƒpƒ‰ƒƒ^’ljÁ
  OraDatabase.Parameters.Add "ret", 0, ORAPARM_OUTPUT
  set pret = OraDatabase.Parameters("ret")
  pret.ServerType = ORATYPE_VARCHAR2

'** ƒXƒgƒAƒhƒtƒ@ƒ“ƒNƒVƒ‡ƒ“ŽÀs
  OraSqlStmt.Refresh

'** –ß‚è’lŽæ“¾
  msgbox pret.value

'** ƒpƒ‰ƒƒ^‰ðÁ
  OraDatabase.Parameters.Remove "ret"

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

¡•â‘«

  E–ß‚è’lˆÈŠO‚Ì“ü—́Ao—́A“üo—̓pƒ‰ƒƒ^‚à’ʏí‚̃oƒCƒ“ƒh•Ï”‚ŃAƒNƒZƒX
    ‚·‚ê‚Ηǂ¢B"begin :ret := sak.GetTmp(:para1, :para2); end;"

  E–ß‚è’l‚ª‚È‚¢ê‡‚́A"begin sak.GetTmp(:para1, :para2); end;" ‚Æ‚È‚éB

  EƒXƒgƒAƒh‚ÌŽÀs‚ÉŒÀ‚炸Abegin ... end; ‚Ì PL/SQL ƒuƒƒbƒN‚ðˆ—‚·‚é
    ‚±‚Æ‚ª‚Å‚«‚éBbegin ... end; ‚Å‚Ü‚Æ‚ß‚ç‚ê‚é‚à‚̂́Aˆê“x‚É”­s‚µ‚½•û
    ‚ªƒŒƒXƒ|ƒ“ƒX‚Í—Ç‚¢B

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

Option Explicit

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

'=======================================================================
'  €”õ
'=======================================================================
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("begin :ret := sak.GetTmp(); end;" _
    , 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 "ret", 0, ORAPARM_OUTPUT
  set pret = OraDatabase.Parameters("ret")
  pret.ServerType = ORATYPE_VARCHAR2
  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 "ret"

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

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

End Sub

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

'---- ExecuteSql ‚Å‚ÌŽÀs ----
  print "-- ExecuteSql ‚Å‚ÌŽÀs --"

'** ƒXƒgƒAƒhƒtƒ@ƒ“ƒNƒVƒ‡ƒ“ŽÀs
  OraDatabase.ExecuteSql "begin :ret := sak.GetTmp(); end;"

'** –ß‚è’lŽæ“¾
  print pret.value

'---- CreateSql ‚Å‚ÌŽÀs ----
  print "-- CreateSql ‚Å‚ÌŽÀs --"

'** ƒXƒgƒAƒhƒtƒ@ƒ“ƒNƒVƒ‡ƒ“ŽÀs
  OraSqlStmt.Refresh

'** –ß‚è’lŽæ“¾
  print pret.value

  print "-- I—¹ --"

End Sub

¡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