drop function if exists public.get_account_id;

create
or replace function public.get_account_id (
  p_bank_name varchar,
  p_bank_account_number varchar
) returns int LANGUAGE plpgsql as $$
declare
	_account_id int;

begin

raise notice 'FUNCTION: get_account_id';
-- E'\n' is new line
raise notice 'INPUT: % p_bank_name = %; % p_bank_account_number = %;', E'\n', p_bank_name, E'\n', p_bank_account_number;

select acct.acct_id
into _account_id
from public.accounts acct
where
	lower(acct.acct_bank_name) = lower(p_bank_name)
	and lower(acct.acct_number) = lower(p_bank_account_number);

raise notice 'RETURN VALUE: _account_id = %', _account_id;

return _account_id;

end;
$$;

grant
execute on function public.get_account_id (varchar, varchar) to acedanger;

grant
execute on function public.get_account_id (varchar, varchar) to budgetuser;