This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

v7.7 Bulk Delete Outstanding Objects

Hello all,

in v6 there was the stored procedure available that simply deleted your outstanding objects:  exec vi_DeleteOutstandingInDB 'ADS'

Is there any similar stored procedure available in v7?

Unfortounatelly i didnt found anything in the database that sounds like that.

I know that you can easily delete the outstanding objects manually in the Manager via  "Manage objects markes as outstanding",
but I need it somehow in a automatic bulk way.

Any Ideas?

Thanks, Fatih

Parents
  • Hi Fatih,

    I can understand your requirement to present the outstanding objects to the customer. But, when you are talking about automated removal of those, I think the outcome of this will be, that no one will care about the outstanding objects. They will be deleted anyways.

    Nevertheless, the SQL procedures will not be available in version 7. This has to do with the different behavior of the membership handling and due to the application server integration.

    Please see the attached code-sample, that can be used to remove outstanding objects. The procedure takes a bunch of objects keys and deletes them using the same method as the Manager is using. 

    Public Sub CCC_Entity_DeleteOutStandingFromDB(ObjectKeys As IEnumerable(Of String))
     
        Dim f = Connection.SqlFormatter
     
        ' Set connection variable to hint about the management of OutStanding objects
        Session.Variables.Put("ManageOutstanding"True)
        Session.Variables.Put("NoCollisionTest"True)
        Session.Variables.Put("ManageOutstandingOperation""DELETE")
     
        ' Group the ObjectKeys by table
        Dim keysByTable = ObjectKeys _
            .Select(Function(k) New DbObjectKey(k)) _
            .GroupBy(Function(k) k.Tablename, StringComparer.OrdinalIgnoreCase)
     
        Try
     
            ' Create a unit of work here to optimize execution
            Using uow = Session.StartUnitOfWork()
     
                ' Iterate through the keys for each table
                For Each tableEntry In keysByTable
                    ' Partition the workload into junks defined by the limit of the IN clause.
                    For Each part In tableEntry.Partition(f.InClauseLimit)
     
                        ' Define the query for the current partition
                        Dim q = Query _
                                .From(tableEntry.Key) _
                                .Where(Function(t) t.Column("XObjectKey").In(part)) _
                                .SelectNonLobs()
     
                        ' Fetch a partition of the data using Bulk collection
                        Dim entities = Session.Source().GetCollection(q, EntityCollectionLoadType.Bulk)
     
                        ' For each entity of the collection
                        For Each e In entities
     
                            ' Call the customizer method to delete the outstanding object 
                            e.CallMethod("DeleteOutstanding")
     
                            ' put the entity to save in the unit of work
                            uow.Put(e)
                        Next
                    Next
                Next
     
                ' Write the changes to the database
                uow.Commit()
            End Using
        Finally
            ' Remove the connection variable that hints about the management of OutStanding objects
            Session.Variables.Remove("ManageOutstanding")
            Session.Variables.Remove("NoCollisionTest")
            Session.Variables.Remove("ManageOutstandingOperation")
        End Try
    End Sub
    

     

Reply
  • Hi Fatih,

    I can understand your requirement to present the outstanding objects to the customer. But, when you are talking about automated removal of those, I think the outcome of this will be, that no one will care about the outstanding objects. They will be deleted anyways.

    Nevertheless, the SQL procedures will not be available in version 7. This has to do with the different behavior of the membership handling and due to the application server integration.

    Please see the attached code-sample, that can be used to remove outstanding objects. The procedure takes a bunch of objects keys and deletes them using the same method as the Manager is using. 

    Public Sub CCC_Entity_DeleteOutStandingFromDB(ObjectKeys As IEnumerable(Of String))
     
        Dim f = Connection.SqlFormatter
     
        ' Set connection variable to hint about the management of OutStanding objects
        Session.Variables.Put("ManageOutstanding"True)
        Session.Variables.Put("NoCollisionTest"True)
        Session.Variables.Put("ManageOutstandingOperation""DELETE")
     
        ' Group the ObjectKeys by table
        Dim keysByTable = ObjectKeys _
            .Select(Function(k) New DbObjectKey(k)) _
            .GroupBy(Function(k) k.Tablename, StringComparer.OrdinalIgnoreCase)
     
        Try
     
            ' Create a unit of work here to optimize execution
            Using uow = Session.StartUnitOfWork()
     
                ' Iterate through the keys for each table
                For Each tableEntry In keysByTable
                    ' Partition the workload into junks defined by the limit of the IN clause.
                    For Each part In tableEntry.Partition(f.InClauseLimit)
     
                        ' Define the query for the current partition
                        Dim q = Query _
                                .From(tableEntry.Key) _
                                .Where(Function(t) t.Column("XObjectKey").In(part)) _
                                .SelectNonLobs()
     
                        ' Fetch a partition of the data using Bulk collection
                        Dim entities = Session.Source().GetCollection(q, EntityCollectionLoadType.Bulk)
     
                        ' For each entity of the collection
                        For Each e In entities
     
                            ' Call the customizer method to delete the outstanding object 
                            e.CallMethod("DeleteOutstanding")
     
                            ' put the entity to save in the unit of work
                            uow.Put(e)
                        Next
                    Next
                Next
     
                ' Write the changes to the database
                uow.Commit()
            End Using
        Finally
            ' Remove the connection variable that hints about the management of OutStanding objects
            Session.Variables.Remove("ManageOutstanding")
            Session.Variables.Remove("NoCollisionTest")
            Session.Variables.Remove("ManageOutstandingOperation")
        End Try
    End Sub
    

     

Children
No Data