> SELECT ; > ALLTRIM(cr.PayorID) AS PAYORID, ; > ALLTRIM(cr.CarName) AS CARRNAME, ; > 'XX' AS NPI_Q, ; > EligibilityRequestFormat(cr.PayorID, 'NPI', pt.PtSSN) AS NPI ; > FROM patient pt ; > JOIN ins_case ic ON ic.pat_no = pt.ptpn ; > JOIN covr cv ON cv.Pat_No = pt.ptpn ; > AND cv.cvps = 'P' ; > AND dDateOfService BETWEEN EVL( cv.Eff_Date, {1/1/1950} ) AND EVL( cv.Exp_Date, DATE() ) ; > JOIN inscarr cr ON cv.CvCarr = cr.inscarr ; > WHERE pt.PtPn = cPatientNumber INTO CURSOR PD READWRITE >Does your UDF change record pointers or workareas? If so its best not to run them inside a SELECT as others have stated. (I learned this recently)