Created
August 27, 2021 13:19
-
-
Save EdgardoEhiyan/fde3e0175e7a37a70e287c73f4e23c8b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Este es el CSV que lee el Script | |
JOB_NUMBER;JOB_USE;JOB_NAM;JOB_STATUS;IO_DISK;CPU_PERCENT | |
212355;ABRKV;QPAD131526;DSPW;23383;9,26 | |
200623;JOBMANAGER;QSECURITY;DLYW;3400;20,01 | |
212123;MSELE2;QPAD125909;RUN;2234;3,17 | |
193306;QUSER;QRWTSRVR;TIMW;837;0,53 | |
204878;QUSER;QRWTSRVR;PSRW;678;0,34 | |
204480;EGARCIAE;QPAD073807;DSPW;328;0,38 | |
211392;MAHA11;QPAD120917;DSPW;287;0,53 | |
193265;QSECOFR;QP0ZSPWP;SELW;240;0,54 | |
212116;QUSER;QZRCSRVS;TIMW;231;0,43 | |
193160;QSYS;QJOBLOGSVR;DEQW;181;0,13 | |
193229;QTCP;QTVDEVICE;TIMW;167;0,19 | |
193230;QTCP;QTVDEVICE;TIMW;135;0,13 | |
193239;QSYS;QINTER2;DEQW;96;0,11 | |
193163;QSYS;QJOBLOGSVR;DEQW;93;0,06 | |
210698;EGARCIAE;QB5PHSRV;SELW;80;0,02 | |
210650;QUSER;QPWFSERVSO;PSRW;75;0,02 | |
212288;SADICAR;QPAD131051;DSPW;61;0,72 | |
193251;QUSER;QZSOSGND;SELW;48;0,08 | |
193150;QSYS;QUSRWRK;DEQW;38;0,18 | |
211639;QUSER;QZSOSIGN;TIMW;37;0,18 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Como leer un archivo Plano (.txt, CSV..etc) del IFS con SQL | |
-- y al mismo tiempo convertirlo de un formato de archivo Plano a Tabla | |
-- By Edgardo Ehiyan | |
Select REPLACE(SUBSTR(LINE,1,POSSTR(SUBSTR(LINE,1), ';')-1), '"','' )as JOB_NUMBER, | |
REPLACE(substr(LINE,locate_in_string(LINE, ';', 1, 1) + 1, | |
locate_in_string(LINE, ';', 1, 2) - | |
(locate_in_string(LINE, ';', 1, 1)+1)), '"','' ) as JOB_USE, | |
REPLACE(substr(LINE,locate_in_string(LINE, ';', 1, 2) + 1, | |
locate_in_string(LINE, ';', 1, 3) - | |
(locate_in_string(LINE, ';', 2, 2)+1)), '"','' ) as JOB_NAME, | |
REPLACE(substr(LINE,locate_in_string(LINE, ';', 1, 3) + 1, | |
locate_in_string(LINE, ';', 1, 4) - | |
(locate_in_string(LINE, ';', 3, 3)+1)), '"','') as JOB_STATUS, | |
REPLACE(substr(LINE,locate_in_string(LINE, ';', 1, 4) + 1, | |
locate_in_string(LINE, ';', 1, 5) - | |
(locate_in_string(LINE, ';', 4, 4)+1)), '"','') as IO_DISK, | |
replace(SUBSTR(line,(locate_in_string(line, ';', 1,5)+1)) , '"','') AS cpu_percent | |
from Table(IFS_Read_UTF8(Path_Name => '/home/msele2/test88.csv')) | |
-- OMITO LINEA DE TITULOS | |
WHERE REPLACE(SUBSTR(LINE,1,POSSTR(SUBSTR(LINE,1), ';')-1), '"','' ) <>'JOB_NUMBER'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ejemplo de como leer un CSV o TXT con SQL/db2 directamente desde el IFS y al mismo tiempo convertir ese archivo plano en formato de tabla.