Thread: problem with function return

problem with function return

From
"Florian Dickbauer"
Date:
Hi,
 
i have a problem with writing functions in SQL.....
 
I tried to write a function like this:
 
create function evaluate(text, text, text) returns setof text as '
Then some SQL Statements which should return a table with 4 columns, containing the information i want. But i don´t know which return type i have to define for muptiple columns and i couldn´t find it in the manual.
' language sql;
 
And i also have a second problem. The parameters i want to give to my function are strings and i need them in my statements, but that doesn´t seem to work the way that i want.
Example:
and ru.category like $1
or
and ra.gender like $2
 
The complete code that i have until now took my a long time and it doesn´t seem to work. Maybe someone can tell me what i´m doing wrong. The code is:
 
create or replace function ergebnis(text, text, text) returns setof text as '
select m.firstname, m.lastname, ru.rank, ra.total
from members m, runs ru, races ra
where ru.membernr=m.membernr
and ru.raceid=ra.id
and ra.name like $1 (I know this doesn´t work but i don´t know why)
and ru.category like $2
and ru.rank>0   
and m.gender like $3
order by ru.rank;
' language sql;
 
I hope someone can tell me what i´m doing wrong.
 
greetings, Florian Dickbauer