History for InsertAbortedVersionAsNew
??changed:- <pre> SELECT rec.z_oid, %s, rec.z_serial, 'c', 0, '', '', nv.z_dataserial FROM %s rec, %s nv WHERE rec.z_version = %s AND rec.z_status = 'c' AND rec.z_data IS NULL AND rec.z_dataserial != '' AND rec.z_nv = nv.z_serial AND rec.z_oid = nv.z_oid </pre> Feed that sql the serial, the name of the data table, the name of the data table again, and the version name. <br> for each row: INSERT INTO %(data)s (z_oid, z_serial, z_pre, z_status, z_datalen, z_version, z_nv, z_dataserial) values (?, ?, ?, ?, ?, ?, ?, ?) <br> then select again a different set (interbase doesn't have an "if") <pre> SELECT rec.z_oid, %s, rec.z_serial,'c',0,'','', nv.z_serial FROM %s rec, %s nv WHERE rec.z_version = %s AND rec.z_status = 'c' AND rec.z_data IS NOT NULL AND rec.z_dataserial = '' AND rec.z_nv = nv.z_serial AND rec.z_oid = nv.z_oid </pre> <br> for each row returned: <pre> INSERT INTO %(data)s (z_oid, z_serial, z_pre, z_status, z_datalen, z_version, z_nv, z_dataserial) values (?, ?, ?, ?, ?, ?, ?, ?) </pre> <br> Then finally insert "ghost" records for version items that were created inside the version that need to be undone to: <pre> SELECT z_oid, %s, z_serial,'g',0,'','', '' FROM %s WHERE z_version = %s AND z_status = 'c' AND z_nv = '' " </pre> For each record: <pre> INSERT INTO %(data)s (z_oid, z_serial, z_pre, z_status, z_datalen, z_version, z_nv, z_dataserial) values (?, ?, ?, ?, ?, ?, ?, ?) </pre> <br> These should all be insert-selects and should be combined into one or two queries if possible. Python logic should not be used to do this. I just couldn't get it to work otherwise and bailed.