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

  • Hi Fatih,

    can you explain your use-case for an automated deletion of objects marked as outstanding?

    There is no SQL procedure in 7.x to do that but maybe I do have a script solution depending on your use case.
  • Hi Markus,

    thanks for your quick response.

    The usecase is "convenience" and "automation".

    There is a custom configuration parameter and a scheduler, that triggers a custom processchain which is deleting in a bulk method the outstanding objects, instead of doing it manually.

    Therefore the customer cann easily maintain the handling of oustanding objects with the configuration parameter.

    PS: i meant in my topic v7.1.1 and not v7.7

    Thanks, Fatih
  • Hi Fatih,
    I think what Markus was asking is why are the objects being marked outstanding in the first place? It sounds from your description that you are doing something unnatural. Maybe you can explain your environment a bit?
    Thanks,
    George
  • Hello George,

    of course we can setup the behavior in the synch project to delete objects immediately instead of marking them as outstanding and the problem is solved. But in this way you have no insights into the outstanding objects anymore (which the customer might want to have) and no simple option to bulk control the handling of outstanding objects via an additional configuration parameter.

    Otherwise, the customer would need to change the behavior each time directly in the synch project for each type of object instead of controlling it centrally via an config param.

    Background: this is an migrated environment from v6 I am talking about.

    Thanks, Fatih
  • 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
    

     

  • Hello Markus,

    thanks for the solution and yes, I share your opinion about this :)

    Thanks, Fatih