postgres function construction problem
Posted on 2007-10-18
i've been creating a function in postgres, as i would like to request a "select is_super_account(id)" with and id
and have a boolean answer to know if the id is a super account or not.
in my table of account, if the account_id exist in super_account_id columns, the account is a "super account".
i have start creating a function with pgAdmin, how can i test in the following,
if the select return > 0. in order to return true or false.
can you help me to complete it ?
CREATE FUNCTION is_super_account(account_id integer) RETURNS boolean AS
'SELECT COUNT(*) FROM account WHERE super_account_id = account_id'
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION is_super_account(integer) OWNER TO community_user;
what is a good return type if i'd like to return complete rows.
how would be a function which receives a table name and two integers representing limits, like 3 and 7 , and that would return
from the 3rd to the 7th row of that table?
thanxs in advance ;o)