bank
This commit is contained in:
@@ -1,9 +1,22 @@
|
||||
show server_version;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- extensions
|
||||
-- ----------------------------------------------------------------------
|
||||
|
||||
select * from pg_available_extensions;
|
||||
|
||||
SHOW shared_preload_libraries;
|
||||
|
||||
drop schema if exists public cascade;
|
||||
create schema public;
|
||||
|
||||
create schema if not exists ext;
|
||||
create extension if not exists pgcrypto schema ext;
|
||||
|
||||
create extension if not exists pg_cron;
|
||||
|
||||
|
||||
create type holder_type as enum ('BANK', 'PERSON', 'COMPANY');
|
||||
|
||||
create table holder (
|
||||
@@ -60,7 +73,11 @@ create table currency (
|
||||
|
||||
insert into currency
|
||||
values ('EUR', 'Euro'), ('JPY', 'Yen'), ('USD', 'US Dollar'),
|
||||
('GBP', 'Livre Sterling'), ('KRW', 'Won');
|
||||
('GBP', 'Livre Sterling'), ('KRW', 'Won'), ('ZAR', 'Rand sud africain'),
|
||||
('CHF', 'Franc suisse'),
|
||||
('AUD', 'Dollar australien'), ('CAD', 'Dollar canadien'),
|
||||
('SEK', 'Couronne suédoise'),
|
||||
('NOK', 'Couronne norvégienne');
|
||||
|
||||
/************************************************************************
|
||||
* Exchange Rate
|
||||
@@ -90,7 +107,7 @@ create temporary table if not exists eurofxref (
|
||||
dumb text
|
||||
);
|
||||
|
||||
copy eurofxref FROM '/docker-entrypoint-initdb.d/banque/eurofxref-hist.csv' (FORMAT CSV, header, delimiter ',', ENCODING 'UTF8');
|
||||
\copy eurofxref FROM '/docker-entrypoint-initdb.d/eurofxref-hist.csv' (FORMAT CSV, header, delimiter ',', ENCODING 'UTF8');
|
||||
|
||||
insert into exchange_rate
|
||||
select 'USD', date, USD from eurofxref;
|
||||
@@ -104,6 +121,27 @@ select 'GBP', date, GBP from eurofxref;
|
||||
insert into exchange_rate
|
||||
select 'KRW', date, KRW from eurofxref;
|
||||
|
||||
insert into exchange_rate
|
||||
select 'ZAR', date, ZAR from eurofxref;
|
||||
|
||||
/*insert into exchange_rate
|
||||
select 'BRL', date, BRL from eurofxref where BRL <> 'N/A';*/
|
||||
|
||||
insert into exchange_rate
|
||||
select 'CHF', date, CHF from eurofxref;
|
||||
|
||||
insert into exchange_rate
|
||||
select 'AUD', date, AUD from eurofxref;
|
||||
|
||||
insert into exchange_rate
|
||||
select 'CAD', date, CAD from eurofxref;
|
||||
|
||||
/*insert into exchange_rate
|
||||
select 'MXN', date, MXN from eurofxref;*/
|
||||
|
||||
insert into exchange_rate
|
||||
select 'NOK', date, NOK from eurofxref;
|
||||
|
||||
create or replace function latest_exchange_rate (
|
||||
p_code text,
|
||||
p_date date
|
||||
@@ -119,7 +157,7 @@ select rate
|
||||
limit 1;
|
||||
$$;
|
||||
|
||||
-- Jeu de caractères utilisé
|
||||
-- Jeu de caractères utilisé
|
||||
CREATE OR REPLACE FUNCTION chars36()
|
||||
RETURNS text AS $$
|
||||
SELECT '12345ABCDE';
|
||||
@@ -147,13 +185,13 @@ DECLARE
|
||||
c text;
|
||||
i int;
|
||||
BEGIN
|
||||
|
||||
|
||||
FOR i IN 1..length(code5) LOOP
|
||||
c := substr(code5, i, 1);
|
||||
total := total + char_to_int(c) * weights[i];
|
||||
END LOOP;
|
||||
|
||||
total := total % length(chars);
|
||||
total := total % length(chars);
|
||||
RETURN substr(chars, total + 1, 1);
|
||||
END;
|
||||
$$ LANGUAGE plpgsql IMMUTABLE;
|
||||
|
||||
Reference in New Issue
Block a user