You are on page 1of 33

TAFJ-Po s t g r e S QL 1 3

I n s t all
R22
TAFJ-Po s t g r e S QL I n s t all

Amendment History:

Revisio
Date Amended Name Description
n

1 1st April 2017 H. Aubert Initial version

2 6th Jun 2017 M. Kumar procedure with screen shots

3 5th July 2019 H. Aubert PostgreSQL 10

4 29th Jan 2020 M. Kumar Screen shots for PostgreSQL 11.

Update PL/SQL procedure load instead of java


5 10th Mar 2020 M. Kumar
stored procs.

6 24th Mar 2020 M. Kumar R20 AMR review

Update for JSONB and update document for


7 12th Jan 2021 Riswana
PostgreSQL 13.

8 22nd March 2021 Riswana Update supported file types

9 12th April 2021 Vikas R21 AMR

10 9th July 2021 Riswana Change default file format as JSON

Add option to use JSONB record created and


11 29th Jan 2022 Riswana
accessed using org.json library.

12 25th March 2022 Puja R22 AMR Review

Page 2
TAFJ-Po s t g r e S QL I n s t all

Copyri g h t
Copyright © Temenos Headquarters SA 2009-2022

All rights reserved.

This document contains proprietary information that is protected by copyright. No part of this document may
be reproduced, transmitted, or made available directly or indirectly to a third party without the express
written agreement of TEMENOS UK Limited. Receipt of this material directly TEMENOS UK Limited
constitutes its express permission to copy. Permission to use or copy this document expressly excludes
modifying it for any purpose, or using it to create a derivative therefrom.

Errat a and Com m e n t s


If you have any comments regarding this manual or wish to report any errors in the
documentation, please document them and send them to the address below:
Technology Department

Temenos Headquarters SA
2 Rue de l’Ecole-de-Chimie,
CH - 1205 Geneva,
Switzerland

Tel SB: +41 (0) 22 708 1150


Fax: +41 (0) 22 708 1160

Please include your name, company, address, and telephone and fax numbers, and email
address if applicable. TAFJdev@temenos.com

Page 3
TAFJ-Po s t g r e S QL I n s t all

Table of Contents
Copyright................................................................................................................................................ 3
Errata and Comments............................................................................................................................ 3
Introduction............................................................................................................................................. 5
Download PostgreSQL........................................................................................................................... 5
Install PostgreSQL.................................................................................................................................. 5
Connect to the database...................................................................................................................... 16
Set and add PG_HOME variable.......................................................................................................... 18
Install necessary T24-Transact related settings into PostgreSQL DB..................................................18
Create the T24 database and user....................................................................................................... 18
Login with new t24 user:....................................................................................................................... 19
Install PostgreSQL with Docker............................................................................................................ 24
Install PostgreSQL for Ubuntu.............................................................................................................. 26
Supported File Types........................................................................................................................... 27
JSON File Type.................................................................................................................................... 27
Switch between JSON Implementations............................................................................28
CREATE-FILE Syntax.......................................................................................................28
DBImport........................................................................................................................... 29
Index On JSONB Values...................................................................................................29

Page 4
TAFJ-Po s t g r e S QL I n s t all

Intro d u c t i o n
This document will show all steps to configure a database, ready to be used by T24 with
TAFJ.

This procedure is for Windows® platform. For all other OS please refer to the official product
documentation.

Dow n l o a d Pos t g r e S Q L
From the following link: https://www.enterprisedb.com/downloads/postgres-postgresql-
downloads

Select the version 13.x and your operating system

Inst a l l Pos t g r e S Q L
Execute the downloaded file postgresql-13.1-1-windows-x64.exe.

Press Next…

Page 5
TAFJ-Po s t g r e S QL I n s t all

Choose the Installation Directory... (it will be $PG_HOME)

Press Next…

Press Next…

Page 6
TAFJ-Po s t g r e S QL I n s t all

Select the Data Directory...

Press Next…

Page 7
TAFJ-Po s t g r e S QL I n s t all

Set a Password. This is NOT (!) the password you will set in the properties file...

Press Next…

Page 8
TAFJ-Po s t g r e S QL I n s t all

Press Next…

Press Next…

Page 9
TAFJ-Po s t g r e S QL I n s t all

Press Next…

Press Next…

Page 10
TAFJ-Po s t g r e S QL I n s t all

Press Finish…

Press your PostgreSQL installation…

Press Next…

Select pgJDBC

Press Next…

Page 11
TAFJ-Po s t g r e S QL I n s t all

Choose Download Directory...

Press Next…

Page 12
TAFJ-Po s t g r e S QL I n s t all

Press Next…

Press Finish…

Execute from the download edb_pgjdbc.exe

Page 13
TAFJ-Po s t g r e S QL I n s t all

Press Next…

Set the path to %PG_HOME%\pgJDBC

Press Next…

Page 14
TAFJ-Po s t g r e S QL I n s t all

Press Next…

Press Finish…

Restart your computer if prompts

Try connecting to the master DB using pgAdmin4.

Execute %PG_HOME%\pgAdmin4\bin\pgAdmin4.exe

Page 15
TAFJ-Po s t g r e S QL I n s t all

 Press the passwords given during the installation process…

Con n e c t to the dat a b a s e


To connect to the database, open a web browser.

Page 16
TAFJ-Po s t g r e S QL I n s t all

Press the passwords given during the installation process…

You are connected to the database : PosgreSQL with the user postgres

Page 17
TAFJ-Po s t g r e S QL I n s t all

Se t and add PG_HOME varia b l e


Edit %PG_HOME%\pg_env.bat

Change and set PG_HOME


@ECHO OFF
REM The script sets environment variables helpful for PostgreSQL

@SET PG_HOME="E:\3rdParty\Db\PostgreSQL\13"
@SET PGDATA=E:\3rdParty\Db\PostgreSQL\13\data
@SET PGDATABASE=postgres
@SET PGUSER=postgres
@SET PGPORT=5432
@SET PGLOCALEDIR=E:\3rdParty\Db\PostgreSQL\13\share\locale

@SET PATH="%PG_HOME%\bin";%PATH%

Inst a l l ne c e s s a r y T24- Tran s a c t relat e d set t i n g s


int o Pos t g r e S Q L DB.

Change the following parameter with higher number and uncomment it to avoid error
shared memory : max_locks_per_transaction
#--------------------------------------------------------------------------------
--------------------------
max_locks_per_transaction = 10000 (instead of 64 by default)

Post this step; restart the PostgreSQL services to take effect of environment variable
change.

Creat e the T24 data b a s e and us e r


Connect through psql prompt using super user and execute the following script to
create a database and user for T24 use.

psql.exe

Page 18
TAFJ-Po s t g r e S QL I n s t all

Password:
CREATE TABLESPACE t24data OWNER postgres LOCATION
‘C:\PostgreSQL\postgressData\t24’;

CREATE DATABASE "T24" WITH OWNER = postgres TEMPLATE = template0


ENCODING = 'UTF8' TABLESPACE = t24data CONNECTION LIMIT = -1;

CREATE USER t24 WITH LOGIN SUPERUSER NOCREATEDB NOCREATEROLE


INHERIT NOREPLICATION CONNECTION LIMIT -1 PASSWORD 't24';

GRANT ALL ON DATABASE "T24" TO t24;

Restart the PostgreSQL service from windows services section.

Logi n with new t2 4 us e r:


psql.exe T24 t24
Password for user t24:

Page 19
TAFJ-Po s t g r e S QL I n s t all

Load the necessary PL/SQL functions into the database using the script under

$TAFJ_HOME/DBScripts/postgreSql (WARNING: Postgres does not like


backslashes!)

Server [localhost]:
Database [postgres]: T24
Port [5433]:
Username [postgres]: t24
Password for user t24:
psql (13.1)
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.

T24=# \i
'C:/Temenos/Development/TAFJ_SOURCES/TAFJ_DEV/TAFJHome/dbscripts/postg
resql/plsqlfunctions_postgresql.sql';

CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION

Page 20
TAFJ-Po s t g r e S QL I n s t all

CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION

Page 21
TAFJ-Po s t g r e S QL I n s t all

CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION

Page 22
TAFJ-Po s t g r e S QL I n s t all

CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
T24=#

T24=# CREATE CAST (varchar AS numeric) WITH INOUT AS IMPLICIT;

The line above creates an implicit cast from varchar to numeric. Without it, queries
such as :

SELECT RECID FROM “V_FBNK_CURRENCY” WHERE “RANK” > 2

Where “RANK” is implicitly converted to numeric will fail.

The \df command should be executed to verify the functions have been loaded inside DB.

Page 23
TAFJ-Po s t g r e S QL I n s t all

Also, from the pgAdmin4, the following could be executed

SELECT proname FROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_proc p

ON pronamespace = n.oid WHERE nspname = 'public';

Page 24
TAFJ-Po s t g r e S QL I n s t all

Once done, we are ready for the DB Import process to populate necessary tables and data
for T24 on this newly created database in PostgreSQL.

Page 25
TAFJ-Po s t g r e S QL I n s t all

Inst a l l Pos t g r e S Q L with Doc k e r


Postgres has a Debian linux docker image out on dockerhub. One can take this image and
build one with pljava using the script below. This docker script will install all dependencies
for pljava and pljava for PostgreSQL version 13.1

ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64

RUN apt-get update -y

RUN apt-get install -y apt-utils

RUN apt-get install -y default-jdk

RUN apt-get install -y gcc

RUN apt-get install -y g++

RUN apt-get install -y python-psycopg2

RUN apt-get install -y postgresql postgresql-contrib

RUN apt-get install -y postgresql-server-dev-13

RUN apt-get install -y libkrb5-dev

RUN apt-get install -y libecpg-dev

RUN apt-get install -y libssl-dev

RUN apt-get install -y maven

RUN apt-get install -y git

RUN cd /usr/share/postgresql/ \

&& git clone https://github.com/tada/pljava.git \

&& cd pljava \

&& mvn clean install -Pwnosign

RUN cd /usr/share/postgresql/pljava/pljava-packaging/target && java -jar pljava-pg13.1-


amd64-Linux-gpp.jar

With the above image built, one can then run the below docker script to install
TAFJFunctions.jar

FROM ${POSTGRES_IMAGE_BUILT_ABOVE}

COPY --chown=postgres:root TAFJFunctions.jar /u01/app/

Page 26
TAFJ-Po s t g r e S QL I n s t all

COPY --chown=postgres:root javafunctions_postgresql.sql /u01/app/sql/

COPY --chown=postgres:root start-postgresql.sh /u01/app/

RUN chmod 755 /u01/app/start-postgresql.sh && chmod 755 /u01/app && chmod 755
/u01/app/data

USER postgres

ENTRYPOINT /u01/app/start-postgresql.sh

Where start-postresql.sh is shown below:

#!/bin/bash

# Debian

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

export PG_HOME=/usr/local/share/postgresql/

export POSTGRES_DB=$DB_NAME

export POSTGRES_USER=$DB_USER

export POSTGRES_PASSWORD=$DB_PASSWORD

echo "POSTGRES_DB:" $DB_NAME

echo "POSTGRES_USER: " $DB_USER

echo "POSTGRES_PASSWORD: " $DB_PASSWORD

cd /u01/app/sql

# Debian

/usr/lib/postgresql/13/bin/initdb

# Debian

/usr/lib/postgresql/13/bin/pg_ctl -D /var/lib/postgresql/data start

Page 27
TAFJ-Po s t g r e S QL I n s t all

# Create the database

psql --echo-all -v ON_ERROR_STOP=1 --username postgres <<-EOF

\x

ALTER SYSTEM set max_locks_per_transaction=500;

CREATE TABLESPACE t24data OWNER postgres LOCATION '/u01/app/data';

ALTER TABLESPACE t24data OWNER TO postgres;

CREATE DATABASE "$POSTGRES_DB" WITH OWNER = postgres TEMPLATE =


template0 ENCODING = 'UTF8' LC_COLLATE='C.UTF-8' TABLESPACE = t24data
CONNECTION LIMIT = -1;

CREATE USER $POSTGRES_USER WITH LOGIN SUPERUSER NOCREATEDB


NOCREATEROLE INHERIT NOREPLICATION CONNECTION LIMIT -1 PASSWORD
'$POSTGRES_PASSWORD';

GRANT ALL ON DATABASE "$POSTGRES_DB" TO $POSTGRES_USER;

EOF

#Debian

echo "pljava.classpath='/usr/share/postgresql/13/pljava/pljava-1.6.0-
SNAPSHOT.jar:/u01/app/TAFJFunctions.jar'" >> /var/lib/postgresql/data/postgresql.conf

echo "pljava.libjvm_location='/usr/lib/jvm/java-8-openjdk-
amd64/jre/lib/amd64/server/libjvm.so'" >> /var/lib/postgresql/data/postgresql.conf

echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf

# Debian

/usr/lib/postgresql/13/bin/pg_ctl -D /var/lib/postgresql/data stop

/usr/lib/postgresql/13/bin/pg_ctl -D /var/lib/postgresql/data start

echo

echo "Creating pljava extension...."

echo

psql --echo-all -v ON_ERROR_STOP=1 --username postgres <<-EOF

Page 28
TAFJ-Po s t g r e S QL I n s t all

\x

CREATE EXTENSION pljava;

GRANT USAGE ON LANGUAGE java TO postgres;

EOF

psql --echo-all -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB"


<<-eosql

\x

CREATE EXTENSION pljava;

GRANT USAGE ON LANGUAGE java TO $POSTGRES_USER;

CREATE CAST (varchar AS numeric) WITH INOUT AS IMPLICIT;

eosql

# Stored functions

psql --echo-all -U "$POSTGRES_USER" -d "$POSTGRES_DB" -f


./javafunctions_postgresql.sql

echo "Finished post install"

# Wait

while true; do sleep 10000; done

Inst a l l Pos t g r e S Q L for Ubu n t u

Following a similar procedure, it should work for Ubuntu (install of PostgreSQL on Ubuntu not
shown).

As a root os user:

apt-get update -y

Page 29
TAFJ-Po s t g r e S QL I n s t all

apt-get install -y apt-utils

apt-get install java-8-openjdk-amd64

apt-get install -y gcc

apt-get install -y g++

apt-get install -y python-psycopg2

apt-get install -y postgresql postgresql-contrib

apt-get install -y postgresql-server-dev-13

apt-get install -y libkrb5-dev

apt-get install -y libecpg-dev

apt-get install -y libssl-dev

apt-get install -y maven

apt-get install -y git

As a postgres os user:

cd /usr/share/postgresql/

To get pljava:

git clone https://github.com/tada/pljava.git

cd pljava

mvn clean install -Pwnosign

cd /usr/share/postgresql/pljava/pljava-packaging/target

java –jar <pljava.jar>, example: java -jar pljava-pg13.1-amd64-Linux-gpp.jar

Configuration Parameters in postgresql psql:

SHOW pljava.classpath;

--------------------------------------------------------------------------------------------------------------------------

Page 30
TAFJ-Po s t g r e S QL I n s t all

/usr/share/postgresql/13/pljava/pljava/target/pljava-1.6.0-
SNAPSHOT.jar;/u01/Temenos/TAFJ/dbscripts/h2/TAFJFunctions.jar

SHOW pljava.libjvm_location;

----------------------------------------------------------------------

/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/amd64/server/libjvm.so

Sup p o r t e d File Type s

 TEXT (DEPRECATED)

 JSON (DEFAULT)

XML type is not supported in Postgresql. While creating a file from Transact, widely
“TYPE=XML” is used, by default it will create a JSONB type table in Postgresql. We can
switch this behaviour using the below property. If it is set to VARCHAR, the table is created
with datatype VARCHAR and the data is stored in TEXT format

temn.tafj.jdbc.default.table.type=VARCHAR

Similarly we can define the table datype of dict file using the below property. By default dict
table is of type JSON. If set to VARCHAR, it is created with datatype VARCHAR and the dict
is stored in TEXT format.

temn.tafj.jdbc.default.dict.type=VARCHAR

JSON File Type


Json File type is now supported in PostgreSQL. It stores the data in Jsonb format with
fieldname/index as key and the data as value. Default behaviour is to use index as key.
Using the below property we can switch to use the fieldname as the key

temn.tafj.use.transact.fieldname.json=true *Default value is false

For E.g: XMLRECORD column of F.XML.TRANS.CONTEXT will be as below

If the property is set to false, the record is created with index-data JSON layout as below,

Page 31
TAFJ-Po s t g r e S QL I n s t all

"1": [ "Specify transformation for third-"],

"2": "party application to pick up",

"3": "50123"

If the property is set to true, the record is created with field-data JSON layout as below

"Descript": [

"descript": [

"Specify transformation for third-"

],

"reserved10": "party application to pick up"

Swit c h bet w e e n JSON Impl e m e n t a t i o n s


There are two implementations to create and access this JSONB record. To use the
Temenos Implementation set below property,

temn.tafj.db.use.json.tafj.implementation=true, by default this property is false


and it uses the org.json library to create and access the JSON record. The database should
be converted using DBImport to make it compatible with this option. Refer to DBImport
section for the same.

CREATE- FILE Synt a x


Syntax to create file of type JSON,

CREATE-FILE FILENAME TYPE=JSON

It will create two columns,

COLUMN NAME COLUMN TYPE

Page 32
TAFJ-Po s t g r e S QL I n s t all

RECID VARCHAR(255)

XMLRECORD JSONB

DBI m p o r t
Select JSON Layout during DBImport

Once the DBImport is completed, we cannot change the JSON layout


from index-data layout to field-data layout and vice-versa. Set
temn.tafj.use.transact.fieldname.json property correctly and then redo
DBImport to change the JSON layout.
!!
WARNING !!

If a PostgreSQL database was created with earlier versions of TAFJ, then we need to
DBImport the database to make it compatible with latest TAFJ. Set the below property to 1 or
2 in tafj.properties, based upon the requirement.

temn.tafj.db.postgresql.covert.json.model.from.old.to.new.format

Set 1, if the records in database has <NULL> tag.

Set 2, to convert database from Temenos Implementation of JSON record to org.json library
created JSON record.

Note: Remove this property after DBImport.

Ind e x On JSON B Valu e s


Btree Index on a field can be created on the table as below,

Single-value Field:

CREATE INDEX <Indexname> ON "<Table_name>" USING BTREE (((XMLRECORD-


>>'4')));

Note: ->> operator convert the values as text and indexed

Multi-Value Field:

Index support for JSONPath is very limited at this point. JSONPath support for indexes will
be improved in subsequent PostgreSQL releases.

Reference: https://scalegrid.io/blog/using-jsonb-in-postgresql-how-to-effectively-store-index-
json-data-in-postgresql/

Page 33

You might also like