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 XV - Parameters

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

¡ƒoƒCƒ“ƒh•Ï”

  EƒoƒCƒ“ƒh•Ï”‚ðŽg—p‚µ‚½XV‚ð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ƒXAƒ†[ƒUÝ’è
  dbname = ""
  cnuser = "SAK/SAK"
  '// Oracle ƒT[ƒrƒX–¼(•Ê–¼)Aƒ†[ƒUEƒ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ƒvI—¹
  on error goto 0

'=======================================================================
'  ˆ—
'=======================================================================

'** RDB ˆ—
  if RdbShori() then
    response.write("<P>-- RDB XV³í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 XV1 ‚ÉŽ¸”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 XV2 ‚ÉŽ¸”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ƒvI—¹
  on error goto 0

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

end function
%>

¡à–¾

  E“¯‚¶XV 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 ServletAJSP •ÒŽ‘—¿
¡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-2024 Y.SAK