vues
This commit is contained in:
@@ -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;
|
||||
$$;
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user