A PostgreSQL Extension to add an Australian banking BSB number type.
To build and install this module:
make
make installor selecting a specific PostgreSQL installation:
make PG_CONFIG=/some/where/bin/pg_config
make PG_CONFIG=/some/where/bin/pg_config installAnd finally create the extension inside the database:
CREATE EXTENSION bankbsb;This module provides a data type bsb that you can use like a normal type. For example:
CREATE TABLE account (
id int PRIMARY KEY,
branch_code bsb
);
INSERT INTO account VALUES (1, '123-456');Valid BSB formats:
nnn-nnnexample123-456will be123-456nnnnnnwill convert tonnn-nnn, example123456will be123-456nnnnnwill convert to0nn-nnn, example12345will be012-345
Where n is an ASCII digit
Install the extension
make
make installRun the regression test
make installcheckIf the test fails, the result output will be in results/bankbsb_test.out. You can then diff this with expected/bankbsb_test.out.
Try the extension using Docker. Pick a local port you want Postgres to run on. Port 5432 may already be taken via another Postgres instance, so pick a different port it needed.
docker build -t postgres-bankbsb .
export PORT=5433
export POSTGRES_PASSWORD=mypassword
docker run -e POSTGRES_PASSWORD=${POSTGRES_PASSWORD} -p ${PORT}:5432 -d postgres-bankbsb
psql -h localhost -p ${PORT} -U postgresEnter password at the prompt. Then enable the extension.
CREATE EXTENSION bankbsb; Use the bsb type as you need.
CREATE TABLE account (
id serial PRIMARY KEY,
branch_code bsb
);
INSERT INTO account (branch_code) VALUES ('123456');
SELECT * FROM account; id | branch_code
----+-------------
1 | 123-456
(1 row)