> You need conditional logic, which suggests pl/pgsql is the way to go.
Maybe he could use simple sql function like this:
create function check_loan(text,int,int) returns boolean as '
select ( select count(*) from kolcsonok where code_user=($2) and code_loan=($3) and typetable=($1)
) > 0;
' language 'sql';
The immediate benefit of it is that there's no need to install
a procedural languge for this simple task.
Regards,
Baldvin