--todo 22640

INSERT
INTO purgetable
  (
    purgetable_id,
    tablename,
    description,
    datefieldname,
    plantfieldname,
    WHERECLAUSE,
    systemuser_id,
    TIMESTAMP
  )
SELECT seq_purgetable.nextval,
  'DeliveryScan',
  'Delivery scans',
  'ScanTimestamp',
  '',
  'PackingNote_ID is null and ((Select DateInactive from Customer where Customer_ID = DeliveryScan.Customer_Link_ID) < sysdate)',
  getminsystemuser(),
  sysdate
FROM dual;
COMMIT;