I don't think this next line isn't doing what you think...
SET LC_TIME TO l_lc_time; IF l_lc_time = 'hr_HR.UTF8' THEN SET LC_TIME TO 'hr_HR.UTF8'; END IF; IF l_lc_time = 'en_EN.UTF8' THEN SET LC_TIME TO 'en_EN.UTF8'; END IF;
This isn't a bug. The SQL Command "SET" is not something that can take a parameter. Doing "EXECUTE sql_string;" is probably the simplest solution - build the SET command as a string and execute it.