Update multiple records through custom script

Hi all,

I want to write code to update fullsyncdate attribute of UNSAccountB table for 1000 accounts at a time, something similar as below

Update UNSAccountB set FullSyncDate=DateTime.Now where cn in ('x','y'.....)

But am not getting any reference on how to do it. All I am getting is by updating one by one record. 

Below is my code block

Public Sub UpdateDaaSSyncInformationInUNSAccountBNew(ByVal userExistList As List(Of String),ByVal xproxyContext As String)
        logMessage("DaaS",xproxyContext+" >>CBA_DIF_UNSAccount_DaaS_Reconcile","UpdateDaaSSyncInformationInUNSAccountBNew","Entered method...")
        If(userExistList.Count>0) Then
        Dim whereClause As String=f.AndRelation(f.comparison("xproxyContext", xproxyContext,ValType.String), _
        f.inClause("cn",ValType.String,userExistList))
        'Load up a collection with all of the values we need
        Dim unsAccountBCollections As IColDbObject = Connection.CreateCol("UNSAccountB")
        unsAccountBCollections.Prototype.WhereClause = whereClause
        unsAccountBCollections.Prototype.Columns("UID_UNSAccountB").IsDisplayItem = True
        unsAccountBCollections.Load()


        Dim uidUNSAcccountB As String
        Dim dbUnsAccountB As ISingleDbObject

' Do not want to iterate one by one account and update the property.


       For Each unsAccountB As IColElem In unsAccountBCollections
            uidUNSAcccountB = unsAccountB.GetValue("uidUNSAcccountB").ToString()
            dbUnsAccountB = Connection.CreateSingle("UNSAccountB", uidUNSAcccountB)
            dbUnsAccountB("FullSyncDate").NewValue = DateTime.Now.ToString()
            dbUnsAccountB.Save()
      Next

End If
End Sub

Parents
  • Hi

    Which version are you using? Look at using Unit of Work, where you can update multiple objects in one transaction. Alterantively, if you don't need to invoke the object layer you can always look at updating the properties using SQL statements directly (which can also be done from within a script)

Reply
  • Hi

    Which version are you using? Look at using Unit of Work, where you can update multiple objects in one transaction. Alterantively, if you don't need to invoke the object layer you can always look at updating the properties using SQL statements directly (which can also be done from within a script)

Children