UPDATE mtl_transaction_accounts
SET gl_batch_id = -2
WHERE gl_batch_id = -1
AND organization_id = &org_id
AND transaction_date < (
SELECT max(schedule_close_date)+.99999
FROM org_acct_periods
WHERE organization_id = &org_id
AND open_flag = ‘N’);