Index: /trunk/glueforge/templates/psdb/Makefile.am
===================================================================
--- /trunk/glueforge/templates/psdb/Makefile.am	(revision 6152)
+++ /trunk/glueforge/templates/psdb/Makefile.am	(revision 6153)
@@ -18,4 +18,6 @@
     dbcleanup_c.tt \
     dbsetup_c.tt \
+    deleterowobjects.tt \
+    deleterowobjects_h.tt \
     doxyfile_in.tt \
     droptable.tt \
Index: /trunk/glueforge/templates/psdb/code.tt
===================================================================
--- /trunk/glueforge/templates/psdb/code.tt	(revision 6152)
+++ /trunk/glueforge/templates/psdb/code.tt	(revision 6153)
@@ -23,3 +23,4 @@
 [% INCLUDE objectfrommetadata.tt -%]
 [% INCLUDE selectrowobjects.tt -%]
+[% INCLUDE deleterowobjects.tt -%]
 [% END -%]
Index: /trunk/glueforge/templates/psdb/deleterowobjects.tt
===================================================================
--- /trunk/glueforge/templates/psdb/deleterowobjects.tt	(revision 6153)
+++ /trunk/glueforge/templates/psdb/deleterowobjects.tt	(revision 6153)
@@ -0,0 +1,19 @@
+long long [% table.namespace %]DeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)
+{
+    long long       deleted;
+
+    for (long long i; i < objects->n; i++) {
+        [% table.object_name %] *object = objects->data[i];
+        psMetadata *where = [% table.namespace %]MetadataFromObject(object);
+        long long count = psDBDeleteRows(dbh, [% table.namespace FILTER upper %]_TABLE_NAME, where, limit);
+        psFree(where)
+        if (count < 0) {
+            psError(PS_ERR_UNKNOWN, true, "failed to delete row from [% table.namespace %]");
+            return count;
+        }
+
+        deleted += count;
+    }
+
+    return deleted;
+}
Index: /trunk/glueforge/templates/psdb/deleterowobjects_h.tt
===================================================================
--- /trunk/glueforge/templates/psdb/deleterowobjects_h.tt	(revision 6153)
+++ /trunk/glueforge/templates/psdb/deleterowobjects_h.tt	(revision 6153)
@@ -0,0 +1,13 @@
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long [% table.namespace %]DeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
Index: /trunk/glueforge/templates/psdb/header.tt
===================================================================
--- /trunk/glueforge/templates/psdb/header.tt	(revision 6152)
+++ /trunk/glueforge/templates/psdb/header.tt	(revision 6153)
@@ -28,4 +28,5 @@
 [% INCLUDE objectfrommetadata_h.tt -%]
 [% INCLUDE selectrowobjects_h.tt -%]
+[% INCLUDE deleterowobjects_h.tt -%]
 [% END -%]
 
