A former police detective, who was found to have stolen cocaine from an evidence store after dropping a bag of white powder outside his child's school, has been jailed for 19 years.