select i.invoice_nr, i.organization_id, i.parent_invoice_id, i.total_amount, i.recipient_id, i.contact_id, i.organization_id, i.status from iv_invoices i, cr_items ii where ii.latest_revision = i.invoice_id and ii.item_id = :invoice_id update iv_invoices set invoice_nr = :invoice_nr, due_date = now() where invoice_id = (select latest_revision from cr_items where item_id = :invoice_id) update cr_items set publish_status = 'live', parent_id = :invoice_folder_id where item_id = :file_id update acs_objects set context_id = :invoice_folder_id where object_id = :file_id