Wasn’t this a Barney Miller episode 30 years ago?
Yup. Looks like it's on Hulu: http://www.tvrage.com/shows/id-2716/episodes/17819">