Pol,
it appears that the plpgsql function chokes on your parameter declaration. Just a hunch, could it be that you have used a TAB character in between the name parameter and the word for?
Plpgsql doesn't like that at all. If so add at least one space before the word for.
/Bart