mirror of
https://github.com/acedanger/budget-database.git
synced 2025-12-05 22:50:13 -08:00
corrected name of file to be in line with the proc name
This commit is contained in:
34
postgres/procedures/update_budget_from_import.sql
Normal file
34
postgres/procedures/update_budget_from_import.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
CREATE OR REPLACE PROCEDURE public.update_budget_from_import()
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
declare
|
||||
_acct int;
|
||||
|
||||
begin
|
||||
|
||||
select acct.acct_id
|
||||
into _acct
|
||||
from public.accounts acct
|
||||
where
|
||||
lower(acct.bank_name) = 'bank of america'
|
||||
and acct.account_number = '4581';
|
||||
|
||||
if _acct is null
|
||||
then
|
||||
raise notice 'could not get the account id';
|
||||
end if;
|
||||
|
||||
truncate public.budgetdetails;
|
||||
insert into public.budgetdetails (trx_description, trx_date, trx_amount, acct_id)
|
||||
select
|
||||
description
|
||||
, cast(dt as date) as dt_converted
|
||||
, amount
|
||||
, _acct
|
||||
from public.budgetimport;
|
||||
|
||||
end
|
||||
$$;
|
||||
|
||||
GRANT EXECUTE ON PROCEDURE public.update_budget_from_import() TO acedanger;
|
||||
GRANT EXECUTE ON PROCEDURE public.update_budget_from_import() TO budgetuser;
|
||||
Reference in New Issue
Block a user