Mario Splivalo <mario.splivalo@mobart.hr> writes:
> Am I doing something wrong here, or there is no way of using temporary
> tables within 'sql' written functions?
I believe the problem is that for a SQL function we parse the whole
function body before executing any of it. So you'd need to split this
into two separate functions.
regards, tom lane