Let {phi(n)}(n=0)(infinity) be a sequence of functions satisfying a second-order differential equation of the form alphaphi(n)'' + betaphi(n)' + (sigma + lambda(n)tau)phi(n) = f(n), where alpha, beta, sigma, tau, and f(n) are smooth functions on the real line R, and lambda(n) is the eigenvalue parameter. Then we find a necessary and sufficient condition in order for {phi(n)}(n=0)(infinity) to be orthogonal relative to a distribution w and then-we give a method to find the distributional orthogonalizing weight w. For such an orthogonal function system, we also give a necessary and sufficient condition in order that the derived set {(pphi(n))'}(n=0)(infinity) is orthogonal, which is a generalization of Lewis and Hahn. We also give various examples. (C) 2002 Elsevier Science B.V. All rights reserved.