Function : Database

NSFDbDeleteNotes - Deletes all notes in an ID table from a database.
----------------------------------------------------------------------------------------------------------

#include <nsfdb.h>

STATUS LNPUBLIC NSFDbDeleteNotes(
DBHANDLE hDB,
DHANDLE hTable,
UNID far *retUNIDArray);

Description :

This function takes a database handle, a handle associated with a Note ID Table, and deletes all the notes specified in the ID table. For local databases only, it also optionally returns an array of UNIDs of the deleted notes (mostly used by the Replication process).

This function is useful when deleting a large number of notes in a remote database, because it minimizes the network traffic by sending only one request to the Lotus Domino Server.
Parameters :

Sample Usage :


           /* Batch any Deletions */

          if (error_status = IDCreateTable( alignment,
                                             &deltable_handle))
               goto Exit;
           else
               cleanup_state += FREE_DELTABLE;
           del_max = IDEntries(thetable_handle);
           del_count = 0L;
           while( del_count < del_max )
           {
               while (IDScan(thetable_handle,
                            (BOOL)(del_count++==0L), &note_id))
               {

                   /* Build a table to batch operation */

                   error_status = IDInsert(deltable_handle,
                                           note_id, &ok_flag);
                   if (!ok_flag || error_status)
                   {
                       printf("IDInsert in deltable failed.\n");
                       goto Exit;
                   }
                   if ((del_count % MAXOPTIMALDELETIONS) == 0)
                       break;
               }
               if (IDEntries(deltable_handle))

               {   /* Using NULL in 3rd arg avoids ERR_REMOTE_UNID */

                   if (error_status = NSFDbDeleteNotes (
                                           db_handle_src,
                                           deltable_handle,
                                           NULL))
                       goto Exit;

                   /* adjust del_count exit of while(IDScan) */

                   printf("\n%s: %lu Notes in %s\n",
                          (del_count <= del_max)? "Deleting"
                                                : "Deleted",
                          (del_count <= del_max)? 50
                                                : del_count-1,
                          src_name);
                   if (error_status = IDDeleteAll(deltable_handle))
                       goto Exit;
               }
           }

           cleanup_state -= FREE_DELTABLE;
           if ( error_status = IDDestroyTable(deltable_handle))
                goto Exit;


See Also :

IDDeleteAll
----------------------------------------------------------------------------------------------------------