Dear Albe,Thanks for your support !!!In my function the problem is that global variables defined inside the function. These variables are visible to functions defined inside a function.
Holy Crap...PostgreSQL functions support closures and global variables? Who knew? Well, aside from that fact that relations are global, anyway...
The problem you seem to have is trying to do something in PostgreSQL exactly like you'd do it in Oracle. While I'm sure many things can be ported over you seem to have stumbled upon one of those things that likely will need to be written using PostgreSQL idioms.
David J.