Option Explicit

Sub Main()
    EalyBind
    LateBind
End Sub

Sub EalyBind()

    Dim x As OraSession, db As OraDatabase, dyn As OraDynaset, f As OraField, v As Variant
    
    Set x = New OraSessionClass
    Set db = x.OpenDatabase("KOZTEST", "KOZ/KOZ", 0)
    Set dyn = db.CreateDynaset("SELECT * FROM DBA_TABLES WHERE ROWNUM < 100", 0)
    Set f = dyn(0)
    v = dyn(0)
    Set f = dyn.Fields(0)
    v = dyn.Fields(0)
    For Each f In dyn.Fields
        v = f.Name
    Next
    Do Until dyn.EOF
        dyn.MoveNext
    Loop
    db.BeginTrans
    db.ExecuteSQL "DELETE FROM TEST"
    db.CommitTrans
    
    db.BeginTrans
    db.ExecuteSQL "INSERT INTO TEST VALUES ('1')"
    db.Rollback
    
    db.BeginTrans
    db.ExecuteSQL "INSERT INTO TEST VALUES ('2')"
    db.CommitTrans
    
    Set dyn = db.CreateDynaset("SELECT * FROM TEST", 0)
    If dyn(0) = "2" Then
        MsgBox "EalyBind OK!"
    Else
        MsgBox "EalyBind NG!"
    End If
    
End Sub

Sub LateBind()

    Dim x, db, dyn, f, v
    
    Set x = CreateObject("OracleInProcServerForVBS.XOraSession")
    
    Set db = x.OpenDatabase("KOZTEST", "KOZ/KOZ", 0)
    Set dyn = db.CreateDynaset("SELECT * FROM DBA_TABLES WHERE ROWNUM < 100", 0)
    Set f = dyn(0)
    v = dyn(0)
    Set f = dyn.Fields(0)
    v = dyn.Fields(0)
    For Each f In dyn.Fields
        v = f.Name
    Next
    Do Until dyn.EOF
        dyn.MoveNext
    Loop
    db.BeginTrans
    db.ExecuteSQL "DELETE FROM TEST"
    db.CommitTrans
    
    db.BeginTrans
    db.ExecuteSQL "INSERT INTO TEST VALUES ('1')"
    db.Rollback
    
    db.BeginTrans
    db.ExecuteSQL "INSERT INTO TEST VALUES ('2')"
    db.CommitTrans
    
    Set dyn = db.CreateDynaset("SELECT * FROM TEST", 0)
    If dyn(0) = "2" Then
        MsgBox "LateBind OK!"
    Else
        MsgBox "LateBind NG!"
    End If


End Sub



ȥå   Խ ʬ Хåå ź ʣ ̾ѹ   ñ측 ǽ   ǽRSS
Last-modified: 2020-04-14 () 22:11:44 (42d)