Routine to update database with objects or lists of objects

A simple procedure that accepts a list of bold objects and lists to commit to the database.

Frequently it is necessary to commit a single object or several objects to the database. This procedure accepts a list of objects and object lists, adds them all to a single list and commits them in a single operation.

procedure UpdateDatabaseWithObjects( Objs : array of const );


   i : integer;

   bie : TBoldIndirectElement;

   lstObjs : TBoldObjectList;

   currObj : TBoldElement;


   lstObjs := nil;

   bie := nil;


     lstObjs := TBoldObjectList.Create;

     bie := TBoldIndirectElement.Create;

     for i := 0 to Length( Objs )-1 do begin

        currObj := Objs[i].vObject as TBoldElement;

        if not Assigned( currObj ) then


        if not (( currObj is TBoldObject) or ( currObj is TBoldObjectList )) then

           raise Exception.Create( 'UpdateDatabaseWithObjects: can only update TBoldObject or TBoldObjectList' )

        else begin

          currObj.GetAsList( bie );

          lstObjs.AddList( bie.Value as TBoldList );



     if lstObjs.count > 0 then

        lstObjs[0].BoldSystem.UpdateDatabaseWithList( lstObjs );



      bie .Free;




Share this article!

Follow us!

Find more helpful articles: