new sql function closeOrder