Hunderds of Scottish public sector 'ghost workers' have been paid for up to 17 years despite their roles being abolished.