Index: /trunk/glueforge/templates/psdb/code.tt
===================================================================
--- /trunk/glueforge/templates/psdb/code.tt	(revision 4249)
+++ /trunk/glueforge/templates/psdb/code.tt	(revision 4250)
@@ -13,4 +13,5 @@
 [% INCLUDE insertobject.tt %]
 [% INCLUDE popobject.tt %]
+[% INCLUDE insertfits.tt %]
 [% INCLUDE popfits.tt %]
 [% INCLUDE selectrowsfits.tt -%]
Index: /trunk/glueforge/templates/psdb/insertfits.tt
===================================================================
--- /trunk/glueforge/templates/psdb/insertfits.tt	(revision 4250)
+++ /trunk/glueforge/templates/psdb/insertfits.tt	(revision 4250)
@@ -0,0 +1,32 @@
+bool [% namespace %]InsertFits(psDB *dbh, const psFits *fits)
+{
+    psArray         *rowSet;
+
+    // move to first HDU
+    if (!psFitsMoveExtNum(fits, 1, false)) {
+        // psError(); something bad happened
+        return false;
+    }
+
+    // check HDU type
+    if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE)  {
+        // psError(); something bad happened
+        return false;
+    }
+
+    // read fits table
+    rowSet = psFitsReadTable(fits);
+    if (!rowSet) {
+        // psError(); something bad happened
+        return false;
+    }
+
+    if (!psDBInsertRows(dbh, [% namespace FILTER upper %]_TABLE_NAME, rowSet)) {
+        // psError(); something bad happened
+        return false;
+    }
+
+    psFree(rowSet);
+
+    return true;
+}
