mirror of
https://github.com/acedanger/budget-database.git
synced 2025-12-06 07:00:14 -08:00
37 lines
1.2 KiB
PL/PgSQL
37 lines
1.2 KiB
PL/PgSQL
drop function if exists public.get_transactions_for_period;
|
|
|
|
create
|
|
or replace function public.get_transactions_for_period (p_account_name text, p_start date, p_end date) returns table (
|
|
bank_name text,
|
|
account_type text,
|
|
account_number text,
|
|
account_friendly_name text,
|
|
transaction_date date,
|
|
transaction_description text,
|
|
transaction_amount numeric(8, 2),
|
|
transaction_day_of_week text,
|
|
running_bal numeric
|
|
) LANGUAGE plpgsql as $$
|
|
begin
|
|
|
|
raise notice 'FUNCTION: get_transactions';
|
|
-- E'\n' is new line
|
|
raise notice 'INPUT: % p_start = %; % p_end = %;', E'\n', p_start, E'\n', p_end;
|
|
|
|
return query
|
|
select
|
|
bl.account_bank_name, bl.account_type, bl.account_number, bl.account_friendly_name
|
|
, bl.transaction_date, bl.transaction_description, bl.transaction_amount
|
|
, bl.transaction_day_of_week, bl.running_bal
|
|
from public.runbal bl
|
|
where
|
|
lower(bl.account_friendly_name) = trim(lower(p_account_name))
|
|
and bl.transaction_date between p_start and p_end;
|
|
end;
|
|
$$;
|
|
|
|
grant
|
|
execute on function public.get_transactions_for_period (text, date, date) to acedanger;
|
|
|
|
grant
|
|
execute on function public.get_transactions_for_period (text, date, date) to budgetuser; |