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 |

ASP VB Script oo4o + SQL ‰ž—p•Ò5 oo4o XV - Parameters

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ƒ‰ƒƒ^‚ð’ljÁ‚·‚éB
    ServerType ‚Ń^ƒCƒv‚àŽw’è‚·‚éB(OraParameter)

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

  session("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

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

  EParameters.Remove ‚́Aƒpƒ‰ƒƒ^‚̒ljÁ‚ð‰ðÁ‚·‚éB

  session("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—á

<%@ Language=VBScript %>
<%
'=======================================================================
'  €”õ
'=======================================================================
  Public Const ORADB_DEFAULT   = &H0
  Public Const ORAPARM_INPUT    = 1
  Public Const ORAPARM_OUTPUT   = 2
  Public Const ORAPARM_BOTH     = 3
  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
  dim dbname
  dim cnuser

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

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

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

'** ƒpƒ‰ƒƒ^’ljÁ
  session("OraDatabase").LastServerErrReset
  if isempty(session("Pkey")) then
    session("OraDatabase").Parameters.Add "ƒL[", 0, ORAPARM_INPUT
    session("OraDatabase").Parameters("ƒL[").ServerType = ORATYPE_CHAR
    set session("Pkey") = session("OraDatabase").Parameters("ƒL[")
  end if
  if isempty(session("Pdata1")) then
    session("OraDatabase").Parameters.Add "ƒf[ƒ^1", 0, ORAPARM_INPUT
    session("OraDatabase").Parameters("ƒf[ƒ^1").ServerType = ORATYPE_NUMBER
    set session("Pdata1") = session("OraDatabase").Parameters("ƒf[ƒ^1")
  end if
  if isempty(session("Pdata2")) then
    session("OraDatabase").Parameters.Add "ƒf[ƒ^2", 0, ORAPARM_INPUT
    session("OraDatabase").Parameters("ƒf[ƒ^2").ServerType = ORATYPE_NUMBER
    set session("Pdata2") = session("OraDatabase").Parameters("ƒf[ƒ^2")
  end if
  if isempty(session("Pdata3")) then
    session("OraDatabase").Parameters.Add "ƒf[ƒ^3", 0, ORAPARM_INPUT
    session("OraDatabase").Parameters("ƒf[ƒ^3").ServerType = ORATYPE_NUMBER
    set session("Pdata3") = session("OraDatabase").Parameters("ƒf[ƒ^3")
  end if
  if err <> 0 or session("OraDatabase").LastServerErr <> 0 then
    response.write("<P>ƒpƒ‰ƒƒ^’ljÁ‚ÉŽ¸”s‚µ‚Ü‚µ‚½B<BR>" _
      & err & ": " & error & "<BR>" _
      & "oo4o: " & session("OraDatabase").LastServerErrText & "</P>")
  end if

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

'=======================================================================
'  ˆ—
'=======================================================================

'** RDB ˆ—
  if RdbShori() then
    response.write("<P>-- RDB XV³íI—¹ --</P>")
  end if

'=======================================================================
'  RDB ˆ—
'=======================================================================
function RdbShori()

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

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

'** oo4o ƒGƒ‰[ƒŠƒZƒbƒg
  session("OraDatabase").LastServerErrReset

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

'** RDB ˆ—1
  session("Pkey").Value = "a001"
  session("Pdata1").Value = 10
  session("Pdata2").Value = 20
  session("Pdata3").Value = 30

  session("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 session("OraDatabase").LastServerErr <> 0 then
    session("OraSession").Rollback
    response.write("<P>RDB XV1 ‚ÉŽ¸”s‚µ‚Ü‚µ‚½B<BR>" _
      & err & ": " & error & "<BR>" _
      & "oo4o: " & session("OraDatabase").LastServerErrText & "</P>")
    exit function
  end if

'** RDB ˆ—2
  session("Pkey").Value = "b002"
  session("Pdata1").Value = 100
  session("Pdata2").Value = 200
  session("Pdata3").Value = 300

  session("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 session("OraDatabase").LastServerErr <> 0 then
    session("OraSession").Rollback
    response.write("<P>RDB XV2 ‚ÉŽ¸”s‚µ‚Ü‚µ‚½B<BR>" _
      & err & ": " & error & "<BR>" _
      & "oo4o: " & session("OraDatabase").LastServerErrText & "</P>")
    exit function
  end if

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

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

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

end function
%>

¡à–¾

  E“¯‚¶XV SQL ‚ª‘å—Ê‚É”­¶‚·‚éƒpƒ^[ƒ“‚ÉŒø‰Ê‚ª‚ ‚é‚ƍl‚¦‚éB
    ƒR[ƒh‚͏­‚µ•¡ŽG‚É‚È‚éB

¡ASP VB Script oo4o + SQL ‰ž—p•ÒŽ‘—¿
¡ASP VB Script ADO + SQL ‰ž—p•ÒŽ‘—¿
¡ASP VB Script Šî‘bŽÀ’n•ÒŽ‘—¿
¡ASP VB Script Šî‘b•ÒŽ‘—¿
¡SQL Šî‘b•ÒŽ‘—¿
¡SQL Šî‘bŽÀ’n•ÒŽ‘—¿
¡SQL ƒ`ƒ…[ƒjƒ“ƒO•ÒŽ‘—¿
¡Oracle PL/SQL •ÒŽ‘—¿
¡PostgreSQL •ÒAJAVA ServletAJSP •ÒŽ‘—¿
¡MySQL •ÒŽ‘—¿
| 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