VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "c_DBSession"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'Generated by IDL2VB v120. Copyright (c) 1999 Martin.Both
'Source File Name: ../demos/db_query/database.idl
'Target File Name: c_DBSession.cls

Option Explicit

Implements cOrbAbstractBase
Implements cOrbObject

'interface ::DB::Session
Const sTypeId As String = "IDL:DB/Session:1.0"
Private oObjRef As cOrbObjRef

'Helper to get different COM interface
Friend Function thisOrbAbstractBase() As cOrbAbstractBase
    Set thisOrbAbstractBase = Me
End Function

'Helper
Private Function cOrbAbstractBase_isObjRef() As Boolean
    cOrbAbstractBase_isObjRef = True
End Function

'Helper to get different COM interface
Friend Function thisOrbObject() As cOrbObject
    Set thisOrbObject = Me
End Function

'Helper
Private Function cOrbObject_setObjRef(ByVal ObjRef As cOrbObjRef, _
    ByVal Check As Boolean) As Boolean
    On Error GoTo ErrHandler
    If ObjRef Is Nothing Then
        cOrbObject_setObjRef = True
    Else
        cOrbObject_setObjRef = False
        Call ObjRef.narrow(sTypeId, Check, False)
    End If
    Set oObjRef = ObjRef
    Exit Function
ErrHandler:
    Call VBOrb.ErrReraise(Err, "setObjRef")
End Function

'Helper
Private Function cOrbObject_getObjRef() As cOrbObjRef
    Set cOrbObject_getObjRef = oObjRef
End Function

'Helper
Private Function cOrbObject_getId() As String
    cOrbObject_getId = sTypeId
End Function

'open() raises(c_DBErrMsgsEx)
Public Sub openSub(ByRef warns As c_DBMessageSeq)
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("open", False)
    Dim oIn As cOrbStream
    If oRequest.invokeReqst(True) Then
        Set oIn = oRequest.OutRes
        Dim sTypeId As String
        sTypeId = oIn.readString()
        Dim oUserEx As VBOrb.cOrbException
        Select Case sTypeId
        Case "IDL:DB/ErrMsgsEx:1.0"
            Set oUserEx = New c_DBErrMsgsEx
            Call oUserEx.initByRead(oIn)
        Case Else
            Call VBOrb.raiseUNKNOWN(1, VBOrb.CompletedMAYBE, _
                "Undefined CORBA User Exception: [" & sTypeId & "]")
        End Select
        Call VBOrb.raiseUserEx(oUserEx)
    Else
        Set oIn = oRequest.OutRes
        Set warns = New c_DBMessageSeq
        Call warns.initByRead(oIn, 0)
    End If
    Exit Sub
ErrHandler:
    Call VBOrb.ErrReraise(Err, "openSub")
End Sub

'executeStatement() raises(c_DBErrMsgsEx)
Public Function executeStatement(ByVal stmstr As String, _
    ByRef warns As c_DBMessageSeq) As Long
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("executeStatement", False)
    Dim oOut As cOrbStream
    Set oOut = oRequest.InArg
    Call oOut.writeString(stmstr)
    Dim oIn As cOrbStream
    If oRequest.invokeReqst(True) Then
        Set oIn = oRequest.OutRes
        Dim sTypeId As String
        sTypeId = oIn.readString()
        Dim oUserEx As VBOrb.cOrbException
        Select Case sTypeId
        Case "IDL:DB/ErrMsgsEx:1.0"
            Set oUserEx = New c_DBErrMsgsEx
            Call oUserEx.initByRead(oIn)
        Case Else
            Call VBOrb.raiseUNKNOWN(1, VBOrb.CompletedMAYBE, _
                "Undefined CORBA User Exception: [" & sTypeId & "]")
        End Select
        Call VBOrb.raiseUserEx(oUserEx)
    Else
        Set oIn = oRequest.OutRes
        executeStatement = oIn.readLong()
        Set warns = New c_DBMessageSeq
        Call warns.initByRead(oIn, 0)
    End If
    Exit Function
ErrHandler:
    Call VBOrb.ErrReraise(Err, "executeStatement")
End Function

'prepareStatement() raises(c_DBErrMsgsEx)
Public Function prepareStatement(ByVal stmstr As String, _
    ByRef warns As c_DBMessageSeq) As c_DBStatement
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("prepareStatement", False)
    Dim oOut As cOrbStream
    Set oOut = oRequest.InArg
    Call oOut.writeString(stmstr)
    Dim oIn As cOrbStream
    If oRequest.invokeReqst(True) Then
        Set oIn = oRequest.OutRes
        Dim sTypeId As String
        sTypeId = oIn.readString()
        Dim oUserEx As VBOrb.cOrbException
        Select Case sTypeId
        Case "IDL:DB/ErrMsgsEx:1.0"
            Set oUserEx = New c_DBErrMsgsEx
            Call oUserEx.initByRead(oIn)
        Case Else
            Call VBOrb.raiseUNKNOWN(1, VBOrb.CompletedMAYBE, _
                "Undefined CORBA User Exception: [" & sTypeId & "]")
        End Select
        Call VBOrb.raiseUserEx(oUserEx)
    Else
        Set oIn = oRequest.OutRes
        Set prepareStatement = m_DBStatement.narrow(oIn.readObject())
        Set warns = New c_DBMessageSeq
        Call warns.initByRead(oIn, 0)
    End If
    Exit Function
ErrHandler:
    Set prepareStatement = Nothing
    Call VBOrb.ErrReraise(Err, "prepareStatement")
End Function

'commit() raises(c_DBErrMsgsEx)
Public Sub commit(ByRef warns As c_DBMessageSeq)
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("commit", False)
    Dim oIn As cOrbStream
    If oRequest.invokeReqst(True) Then
        Set oIn = oRequest.OutRes
        Dim sTypeId As String
        sTypeId = oIn.readString()
        Dim oUserEx As VBOrb.cOrbException
        Select Case sTypeId
        Case "IDL:DB/ErrMsgsEx:1.0"
            Set oUserEx = New c_DBErrMsgsEx
            Call oUserEx.initByRead(oIn)
        Case Else
            Call VBOrb.raiseUNKNOWN(1, VBOrb.CompletedMAYBE, _
                "Undefined CORBA User Exception: [" & sTypeId & "]")
        End Select
        Call VBOrb.raiseUserEx(oUserEx)
    Else
        Set oIn = oRequest.OutRes
        Set warns = New c_DBMessageSeq
        Call warns.initByRead(oIn, 0)
    End If
    Exit Sub
ErrHandler:
    Call VBOrb.ErrReraise(Err, "commit")
End Sub

'rollback() raises(c_DBErrMsgsEx)
Public Sub rollback(ByRef warns As c_DBMessageSeq)
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("rollback", False)
    Dim oIn As cOrbStream
    If oRequest.invokeReqst(True) Then
        Set oIn = oRequest.OutRes
        Dim sTypeId As String
        sTypeId = oIn.readString()
        Dim oUserEx As VBOrb.cOrbException
        Select Case sTypeId
        Case "IDL:DB/ErrMsgsEx:1.0"
            Set oUserEx = New c_DBErrMsgsEx
            Call oUserEx.initByRead(oIn)
        Case Else
            Call VBOrb.raiseUNKNOWN(1, VBOrb.CompletedMAYBE, _
                "Undefined CORBA User Exception: [" & sTypeId & "]")
        End Select
        Call VBOrb.raiseUserEx(oUserEx)
    Else
        Set oIn = oRequest.OutRes
        Set warns = New c_DBMessageSeq
        Call warns.initByRead(oIn, 0)
    End If
    Exit Sub
ErrHandler:
    Call VBOrb.ErrReraise(Err, "rollback")
End Sub

'close() raises(c_DBErrMsgsEx)
Public Sub closeSub(ByRef warns As c_DBMessageSeq)
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("close", False)
    Dim oIn As cOrbStream
    If oRequest.invokeReqst(True) Then
        Set oIn = oRequest.OutRes
        Dim sTypeId As String
        sTypeId = oIn.readString()
        Dim oUserEx As VBOrb.cOrbException
        Select Case sTypeId
        Case "IDL:DB/ErrMsgsEx:1.0"
            Set oUserEx = New c_DBErrMsgsEx
            Call oUserEx.initByRead(oIn)
        Case Else
            Call VBOrb.raiseUNKNOWN(1, VBOrb.CompletedMAYBE, _
                "Undefined CORBA User Exception: [" & sTypeId & "]")
        End Select
        Call VBOrb.raiseUserEx(oUserEx)
    Else
        Set oIn = oRequest.OutRes
        Set warns = New c_DBMessageSeq
        Call warns.initByRead(oIn, 0)
    End If
    Exit Sub
ErrHandler:
    Call VBOrb.ErrReraise(Err, "closeSub")
End Sub

'destroy() raises(c_DBErrMsgsEx)
Public Sub destroy(ByRef warns As c_DBMessageSeq)
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("destroy", False)
    Dim oIn As cOrbStream
    If oRequest.invokeReqst(True) Then
        Set oIn = oRequest.OutRes
        Dim sTypeId As String
        sTypeId = oIn.readString()
        Dim oUserEx As VBOrb.cOrbException
        Select Case sTypeId
        Case "IDL:DB/ErrMsgsEx:1.0"
            Set oUserEx = New c_DBErrMsgsEx
            Call oUserEx.initByRead(oIn)
        Case Else
            Call VBOrb.raiseUNKNOWN(1, VBOrb.CompletedMAYBE, _
                "Undefined CORBA User Exception: [" & sTypeId & "]")
        End Select
        Call VBOrb.raiseUserEx(oUserEx)
    Else
        Set oIn = oRequest.OutRes
        Set warns = New c_DBMessageSeq
        Call warns.initByRead(oIn, 0)
    End If
    Exit Sub
ErrHandler:
    Call VBOrb.ErrReraise(Err, "destroy")
End Sub
