VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "c_DBStatementImplTie"
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_DBStatementImplTie.cls

Option Explicit

'You can use this class as a tie to your servant or as a servant example.
'Using as a tie:
' Your servant has to implement c_DBStatement
' To activate a servant via tie write following:
'  Dim oDBStatementImplTie As c_DBStatementImplTie
'  Set oDBStatementImplTie = New c_DBStatementImplTie
'  Call oDBStatementImplTie.setDelegate(oServant)
'  Call oOrb.Connect(oDBStatementImplTie)
'Using as a servant example:
' Rename class to c_DBStatementImpl and save the file as c_DBStatementImpl.cls.
' Remove delegate stuff and write your own servant operations.
' To activate a servant write following:
'  Dim oDBStatementImpl As c_DBStatementImpl
'  Set oDBStatementImpl = New c_DBStatementImpl
'  Call oOrb.Connect(oDBStatementImpl)

Implements cOrbSkeleton
Implements c_DBStatement

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

'Each tie contains a delegate object, to which all operations are forwarded.
'You can remove this if you use this class as an example for your servant.
Public Sub setDelegate(ByVal Delegate As c_DBStatement)
    Set oDelegate = Delegate
End Sub

Public Function getDelegate() As c_DBStatement
    Set getDelegate = oDelegate
End Function

Friend Property Get ObjRef() As cOrbObjRef
    Set ObjRef = oObjRef
End Property

Friend Property Get This() As c_DBStatement
    Dim oObj As cOrbObject
    Set oObj = New c_DBStatement
    If oObj.setObjRef(oObjRef, False) Then
        Set This = Nothing
    Else
        Set This = oObj
    End If
End Property

Private Property Get cOrbSkeleton_TypeId(ByVal Item As Integer) As String
    Select Case Item
    Case 0: cOrbSkeleton_TypeId = sTypeId
    Case 1: cOrbSkeleton_TypeId = "IDL:omg.org/CORBA/Object:1.0"
    End Select
End Property

Private Property Get cOrbSkeleton_ObjRef() As cOrbObjRef
    Set cOrbSkeleton_ObjRef = oObjRef
End Property

Private Property Set cOrbSkeleton_ObjRef(ByVal newObjRef As cOrbObjRef)
    Set oObjRef = newObjRef
End Property

'Helper
Private Function cOrbSkeleton_execute(ByVal sOperation As String, _
    ByVal oIn As cOrbStream, ByVal oOut As cOrbStream) As Long
    On Error GoTo ErrHandler
    Dim oImpl_ As c_DBStatement
    Set oImpl_ = IIf(oDelegate Is Nothing, Me, oDelegate)
    Select Case sOperation
    Case "describe"
        Dim a1_cols As c_DBColumnDescriptorSeq
        Dim a1_warns As c_DBMessageSeq
        Dim describe As Long
        describe = oImpl_.describe(a1_cols, a1_warns)
        Call oOut.writeLong(describe)
        Call a1_cols.writeMe(oOut, 0)
        Call a1_warns.writeMe(oOut, 0)
    Case "execute"
        Dim a2_using As c_DBColumnDataSeq
        Set a2_using = New c_DBColumnDataSeq
        Call a2_using.initByRead(oIn, 0)
        Dim a2_row As c_DBColumnDataSeq
        Dim a2_warns As c_DBMessageSeq
        Dim execute As Long
        execute = oImpl_.execute(a2_using, a2_row, a2_warns)
        Call oOut.writeLong(execute)
        Call a2_row.writeMe(oOut, 0)
        Call a2_warns.writeMe(oOut, 0)
    Case "declareCursor"
        Dim a3_hold As Boolean
        a3_hold = oIn.readBoolean()
        Dim a3_warns As c_DBMessageSeq
        Dim declareCursor As c_DBCursor
        Set declareCursor = oImpl_.declareCursor(a3_hold, a3_warns)
        Call oOut.writeObject(declareCursor)
        Call a3_warns.writeMe(oOut, 0)
    Case "free"
        Dim a4_warns As c_DBMessageSeq
        Call oImpl_.free(a4_warns)
        Call a4_warns.writeMe(oOut, 0)
    Case Else
        Call VBOrb.raiseBADOPERATION(1, VBOrb.CompletedNO, sOperation)
    End Select
    cOrbSkeleton_execute = 0 'NO_EXCEPTION
    Exit Function
UserExWriter:
    Call VBOrb.getException().writeMe(oOut)
    cOrbSkeleton_execute = 1 'USER_EXCEPTION
    Exit Function
ErrHandler:
    If VBOrb.ErrIsUserEx() Then Resume UserExWriter
    Call VBOrb.ErrReraise(Err, "Statement.execute(" & sOperation & ")")
End Function

'Implements c_DBStatement

'describe() raises(c_DBErrMsgsEx)
Private Function c_DBStatement_describe(ByRef cols As c_DBColumnDescriptorSeq, _
    ByRef warns As c_DBMessageSeq) As Long
    On Error GoTo ErrHandler
    'Please write your own code here if using as servant example
    If oDelegate Is Nothing Then
        Call VBOrb.raiseNOIMPLEMENT(0, VBOrb.CompletedNO)
    Else
        c_DBStatement_describe = oDelegate.describe(cols, warns)
    End If
    Exit Function
ErrHandler:
    Call VBOrb.ErrReraise(Err, "describe")
End Function

'execute() raises(c_DBErrMsgsEx)
Private Function c_DBStatement_execute(ByVal using As c_DBColumnDataSeq, _
    ByRef row As c_DBColumnDataSeq, ByRef warns As c_DBMessageSeq) As Long
    On Error GoTo ErrHandler
    'Please write your own code here if using as servant example
    If oDelegate Is Nothing Then
        Call VBOrb.raiseNOIMPLEMENT(0, VBOrb.CompletedNO)
    Else
        c_DBStatement_execute = oDelegate.execute(using, row, warns)
    End If
    Exit Function
ErrHandler:
    Call VBOrb.ErrReraise(Err, "execute")
End Function

'declareCursor() raises(c_DBErrMsgsEx)
Private Function c_DBStatement_declareCursor(ByVal hold As Boolean, _
    ByRef warns As c_DBMessageSeq) As c_DBCursor
    On Error GoTo ErrHandler
    'Please write your own code here if using as servant example
    If oDelegate Is Nothing Then
        Call VBOrb.raiseNOIMPLEMENT(0, VBOrb.CompletedNO)
    Else
        Set c_DBStatement_declareCursor = oDelegate.declareCursor(hold, warns)
    End If
    Exit Function
ErrHandler:
    Set c_DBStatement_declareCursor = Nothing
    Call VBOrb.ErrReraise(Err, "declareCursor")
End Function

'free() raises(c_DBErrMsgsEx)
Private Sub c_DBStatement_free(ByRef warns As c_DBMessageSeq)
    On Error GoTo ErrHandler
    'Please write your own code here if using as servant example
    If oDelegate Is Nothing Then
        Call VBOrb.raiseNOIMPLEMENT(0, VBOrb.CompletedNO)
    Else
        Call oDelegate.free(warns)
    End If
    Exit Sub
ErrHandler:
    Call VBOrb.ErrReraise(Err, "free")
End Sub
