This commit is contained in:
2025-11-16 09:10:10 +01:00
parent 1bbbd16e03
commit 4f38a8793a
4 changed files with 104 additions and 16 deletions

View File

@@ -88,3 +88,49 @@ $$;
```sql
call add_company('Boulangerie de Valorgue', 'FR19803269968', '2014-08-19');
```
## d et r
```sql
create or replace procedure add_depot (
p_account_id bigint,
p_amount decimal
)
language plpgsql
as $$
declare
v_id bigint;
begin
insert into transaction (amount)
values (p_amount)
returning id into v_id;
insert into operation (transaction_id, account_id, amount, direction)
values (v_id, p_account_id, p_amount, 'CREDIT');
raise notice 'Dépôt de % sur le compte %', p_amount, p_account_id;
end;
$$;
```
```sql
create or replace procedure add_retrait (
p_account_id bigint,
p_amount decimal
)
language plpgsql
as $$
declare
v_id bigint;
begin
insert into transaction (amount)
values (p_amount)
returning id into v_id;
insert into operation (transaction_id, account_id, amount, direction)
values (v_id, p_account_id, p_amount, 'DEBIT');
raise notice 'Retrait de % sur le compte %', p_amount, p_account_id;
end;
$$;
```