Exemple : déchargement des données avec la génération d'une commande de téléchargement pour une destination PostgreSQL

Rapport d'exécution :
[postgres@lat111 ~]$ db2hpu -i i1110 -f sysin 
INZM031I Optim High Performance Unload for Db2 06.05.00.001.04(210121) 
       64 bits 01/25/2021(Linux lat111 3.10.0-862.14.4.el7.x86_64 #1 SMP Fri Sep 21 09:07:21 UTC 2018 x86_64) 
INZI473I Memory limitations: 'unlimited' for virtual memory and 'unlimited' for data segment 
   ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+
000001 GLOBAL CONNECT TO SAMPLE;
000002 UNLOAD TABLESPACE
000003 SELECT * FROM I1110.EMPLOYEE;
000004 INTO TABLE (public.EMPLOYEE_PG)
000005 LOADDEST(POSTGRESQL WITH STANDARD AUTH)
000006 OUTFILE("outfile")
000007 LOADFILE("loadfile")
000008 DATE DATE_C
000009 FORMAT DELIMITED;
        
INZU462I HPU control step start: 01/25/2021 09:26:52.162. 
INZU463I HPU control step end : 01/25/2021 09:26:52.477. 
INZU464I HPU run step start : 01/25/2021 09:26:52.648. 
INZU410I HPU utility has unloaded 42 rows on lat111 host for I1110.EMPLOYEE in outfile.
INZU684I HPU utility has generated an upload command for the POSTGRESQL destination in the loadfile file. 
INZU465I HPU run step end : 01/25/2021 09:26:52.664. 
INZI441I HPU successfully ended: Real time -> 0m0.501895s 
User time -> 0m0.078101s : Parent -> 0m0.078101s, Children -> 0m0.000000s 
Syst time -> 0m0.073030s : Parent -> 0m0.073030s, Children -> 0m0.000000s
Section PostgreSQL associée dans le fichier db2hpu.dest :
[PostgreSQL]
url=lat109
dbname=DB_POSTGRE
user=postgres
Extrayez le fichier de sortie généré :
[postgres@lat111 ~]$ cat outfile
"000010","CHRISTINE","I","HAAS","A00","3978",1995-01-01,"PRES",18,"F",1963-08-24,+0152750.00,+0001000.00,+0004220.00
...
"200340","ROY","R","ALONZO","E21","5698",1997-07-05,"FIELDREP",16,"M",1956-05-17,+0031840.00,+0000500.00,+0001907.00
Commande de transfert générée :
[postgres@lat111 ~]$ cat loadfile
#!/bin/sh 
echo "Enter password for user 'postgres':" 
read -s password 
      
echo Start uploading ... 
echo "COPY PUBLIC.EMPLOYEE_PG(EMPNO,FIRSTNME,MIDINIT,LASTNAME,WORKDEPT,PHONENO,HIREDATE,JOB,EDLEVEL,
SEX,BIRTHDATE,SALARY,BONUS,COMM) FROM '/home/postgres/outfile' WITH ( FORMAT csv , 
DELIMITER ',', QUOTE '\"')"> "EMPLOYEE_PG.msg.tmp" 
"psql" -a -e -w -v "ON_ERROR_STOP=1" -f "EMPLOYEE_PG.msg.tmp" "dbname=DB_POSTGRE 
host=lat109 user=postgres password=$password " > "EMPLOYEE_PG.msg" 2>&1 
RC=$? 
rm -f "EMPLOYEE_PG.msg.tmp" 
if [ $RC -ne 0 ] 
then 
   echo "An error occurred while processing the 'outfile' file. The 'EMPLOYEE_PG.msg' 
file contains the associated execution report." 
else 
   echo "The 'outfile' file has been processed successfully. The 'EMPLOYEE_PG.msg' file 
contains the associated execution report." 
fi 
exit $RC