Exemple: Déchargement de données avec la génération d'une commande de téléchargement pour une destination Db2 Warehouse , en fonction de l'utilisation de l'outil cURL

Rapport d'exécution :

[i1058@lat111 ~]$ db2hpu -i i1058 -f sysin
INZM031I Optim High Performance Unload for Db2 06.01.00.001(170224) 
         64 bits 02/27/2017 (Linux lat111 3.10.0-327.36.1.el7.x86_64 #1 SMP Wed Aug 17 03:02:37 EDT 2016 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 I1058.EMPLOYEE;
000004 INTO TABLE (MYUSER.EMPLOYEE)
000005 OUTFILE("outfile")
000006 LOADFILE("loadfile")
000007 LOADDEST(DB2 WAREHOUSE WITH STANDARD AUTH)
000008 FORMAT DEL;

INZU462I HPU control step start: 02/27/2017 16:52:11.477.
INZU463I HPU control step end  : 02/27/2017 16:52:11.819.
INZU464I HPU run step start    : 02/27/2017 16:52:11.887.
INZU410I HPU utility has unloaded 42 rows on lat111 host for MYUSER.EMPLOYEE in outfile.
INZU684I HPU utility has generated an upload command for the DB2 WAREHOUSE destination in the loadfile file.
INZU465I HPU run step end      : 02/27/2017 16:52:12.544.
INZI441I HPU successfully ended: Real time -> 0m1.066499s
User time -> 0m0.275287s : Parent -> 0m0.270976s, Children -> 0m0.004311s
Syst time -> 0m0.063821s : Parent -> 0m0.055198s, Children -> 0m0.008623s

Section Db2® Warehouse associée dans le fichier db2hpu.dest :

[Warehouse]
user=bluadmin
curl=yes
url=https://DB2WAREHOUSE_IP:8443/dashdb-api/load/local/del

Extrayez le fichier de sortie généré :

i1058@lat111 ~]$ cat outfile
"000010","CHRISTINE","I","HAAS","A00","3978",19950101,"PRES    ",18,"F",19630824,+0152750.00,+0001000.00,+0004220.00
...
"200340","ROY","R","ALONZO","E21","5698",19970705,"FIELDREP",16,"M",19560517,+0031840.00,+0000500.00,+0001907.00

Commande de transfert générée :

[i1058@lat111 ~]$ cat loadfile
#!/bin/sh
echo "Enter password for user 'bluadmin':"
read -s password

echo Start uploading ...
curl --write-out "%{http_code}" -X POST -H "Content-Type: multipart/form-data" --user "bluadmin:$password"
     "https://DB2WAREHOUSE_IP:8443/dashdb-api/load/local/del/MYUSER.EMPLOYEE?hasHeaderRow=false&delimiter=','&codePage=1208"
     -F loadFile1=@"outfile" -o "EMPLOYEE.msg" 2> "EMPLOYEE.msg.err"
RC=$?
if [ $RC -eq 0 ]
then
    RC=$(cat "EMPLOYEE.msg.http")
    if [ $RC -ge 300 -o $RC -lt 100 ]
    then
        RC=1
    else
        RC=0
        rm -f "EMPLOYEE.msg.err"
    fi
else
    RC=1
fi
rm -f "EMPLOYEE.msg.http" >/dev/null 2>&1
if [ $RC -ne 0 ]
then
    echo "An error occurred while processing the 'outfile' file. The 'EMPLOYEE.msg' and 'EMPLOYEE.msg.err' files 
          contain the associated execution reports."
else
    echo "The 'outfile' file has been processed successfully. The 'EMPLOYEE.msg' file contains the associated execution report."
fi
exit $RC