PostgreSQL-IBAN/README.md

61 lines
1.2 KiB
Markdown
Raw Permalink Normal View History

2020-10-24 21:42:58 +00:00
![C/C++ CI](https://github.com/yorickdewid/PostgreSQL-IBAN/workflows/C/C++%20CI/badge.svg)
# PostgreSQL IBAN
2016-03-05 22:32:06 +00:00
PostgreSQL IBAN extension that can verify International Bank Account Numbers.
This ensures that only valid bank account numbers are stored.
### Example
```sql
CREATE TABLE test_iban (
2020-10-24 21:42:58 +00:00
name text,
account iban
2016-03-05 22:32:06 +00:00
)
2020-10-24 21:47:01 +00:00
--
2016-03-05 22:32:06 +00:00
-- Insert data
2020-10-24 21:47:01 +00:00
--
2016-03-05 22:32:06 +00:00
2020-10-24 21:42:58 +00:00
-- Dutch IBAN format
INSERT INTO test_iban (name, account) VALUES ('John', 'NL91ABNA0417164300');
-- German IBAN format
INSERT INTO test_iban (name, account) VALUES ('Doe', 'DE89370400440532013000');
-- Invalid data
2016-03-05 22:32:06 +00:00
INSERT INTO test_iban (name, account) VALUES ('Dean', 'AZ22NABZ00000000137010001944');
2020-10-24 21:47:01 +00:00
--
2020-10-24 21:42:58 +00:00
-- Show output
2020-10-24 21:47:01 +00:00
--
2020-10-24 21:42:58 +00:00
SELECT * FROM test_iban;
2016-03-05 22:32:06 +00:00
```
Manually test input
```sql
SELECT iban_validate('KW81CBKU0000000000001234560101');
-- Or cast
SELECT 'KZ86125KZT5004100100'::iban;
```
the `::iban` datatype can be cast to an text to perform string operations
```sql
SELECT 'KZ86125KZT5004100100'::iban::text;
```
2020-10-24 21:45:54 +00:00
## Build
Make sure PostgreSQL development tools are installed (check `pg_config`)
2020-10-24 21:47:01 +00:00
```bash
2020-10-24 21:45:54 +00:00
git clone https://github.com/yorickdewid/PostgreSQL-IBAN
cd PostgreSQL-IBAN
make install
```
Login to the database and load the extension
2020-10-24 21:47:01 +00:00
```sql
2020-10-24 21:45:54 +00:00
CREATE EXTENSION iban;
```