| 1 | package oEdtk::trackEdtk; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use oEdtk::Main; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Config::IniFiles; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Sys::Hostname; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Digest::MD5 qw(md5_base64); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use DBI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Cwd qw(abs_path); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Exporter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use vars qw($VERSION @ISA @EXPORT_OK); # @EXPORT %EXPORT_TAGS); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 4 | $VERSION = 2.1129; # eventually this library should be taken over by oEdtk::Tracking | |||||||||||||||||||||||||||
| 17 | 4 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # @EXPORT = qw( | ||||||||||||||||||||||||||||
| 20 | # ); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 4 | @EXPORT_OK = qw( | |||||||||||||||||||||||||||
| 23 | ini_Edtk_Conf conf_To_Env | ||||||||||||||||||||||||||||
| 24 | env_Var_Completion | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | init_Tracking track_Obj | ||||||||||||||||||||||||||||
| 27 | define_Mod_Ed define_Job_Evt | ||||||||||||||||||||||||||||
| 28 | define_Track_Key | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | edit_Track_Table | ||||||||||||||||||||||||||||
| 31 | create_Track_Table prepare_Tracking_Env | ||||||||||||||||||||||||||||
| 32 | drop_Track_Table | ||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # 3 possible ways to feed it (config edtk.ini -> EDTK_TRACK_MODE): | ||||||||||||||||||||||||||||
| 38 | # -1- DB : tracking directly in a DBMS (DB) -> slows down the production run (insert the tracking info at the end of the run to limit the impact => END of the module?) | ||||||||||||||||||||||||||||
| 39 | # -2- FDB : tracking through SQLite -> no handling of several real-time accesses => create 1 db file per process (procDB) -> organize a data consolidation | ||||||||||||||||||||||||||||
| 40 | # -3- LOG : flat tracking files -> organize a data consolidation | ||||||||||||||||||||||||||||
| 41 | # | ||||||||||||||||||||||||||||
| 42 | # ? TODO: bug in the dynamic creation of the SQLite file, TSTAMP/PROCESS_ID is not used ??? | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 4 | my $DBI_DNS = ""; | |||||||||||||||||||||||||||
| 45 | 4 | my $DBI_USER = ""; | |||||||||||||||||||||||||||
| 46 | 4 | my $DBI_PASS = ""; | |||||||||||||||||||||||||||
| 47 | 4 | my $TABLENAME = "tracking_oEdtk"; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 4 | my $ED_HOST = ""; | |||||||||||||||||||||||||||
| 50 | 4 | my $ED_TSTAMP = ""; | |||||||||||||||||||||||||||
| 51 | 4 | my $ED_PROC = ""; | |||||||||||||||||||||||||||
| 52 | 4 | my $ED_SNGL_ID = ""; | |||||||||||||||||||||||||||
| 53 | 4 | my $ED_USER = ""; | |||||||||||||||||||||||||||
| 54 | 4 | my $ED_SEQ = ""; | |||||||||||||||||||||||||||
| 55 | 4 | my $ED_APP = ""; | |||||||||||||||||||||||||||
| 56 | 4 | my $ED_MOD_ED = ""; | |||||||||||||||||||||||||||
| 57 | 4 | my $ED_JOB_EVT = ""; | |||||||||||||||||||||||||||
| 58 | 4 | my $ED_OBJS = ""; | |||||||||||||||||||||||||||
| 59 | 4 | my @ED_K_NAME; | |||||||||||||||||||||||||||
| 60 | my @ED_K_VAL; | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 4 | my @TRACKED_OBJ; | |||||||||||||||||||||||||||
| 63 | 4 | my @DB_USER_COL; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 4 | my $NOK = -1; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub ini_Edtk_Conf { | ||||||||||||||||||||||||||
|
Subroutine
ini_Edtk_Conf: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | # look for the configuration file | ||||||||||||||||||||||||||||
| 70 | # return the path to the valid configuration file | ||||||||||||||||||||||||||||
| 71 | 0 | my $iniEdtk = $INC{'oEdtk/trackEdtk.pm'}; | |||||||||||||||||||||||||||
| 72 | 0 | $iniEdtk =~ s/(trackEdtk\.pm)//; | |||||||||||||||||||||||||||
| 73 | 0 | $iniEdtk .= "iniEdtk/edtk.ini"; | |||||||||||||||||||||||||||
| 74 | 0 | my $hostname = uc( hostname() ); | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | # OPEN THE CONFIGURATION FILE | ||||||||||||||||||||||||||||
| 77 | 0 | my $tmpIniEdtk = $iniEdtk; | |||||||||||||||||||||||||||
| 78 | 0 | my $confIni; | |||||||||||||||||||||||||||
| 79 | 0 | ▶ | while ( $tmpIniEdtk ne 'local' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ( !( -e $tmpIniEdtk ) ) { die "ERR. config file not found : $tmpIniEdtk\n"; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | $confIni = Config::IniFiles->new( -file => $tmpIniEdtk, -default => 'DEFAULT' ); | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | $iniEdtk = $tmpIniEdtk; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | # look for the iniEdtk variable in the '$hostname' section, or by default | ||||||||||||||||||||||||||||
| 86 | # in the 'DEFAULT' section (see the new method) | ||||||||||||||||||||||||||||
| 87 | 0 | $tmpIniEdtk = $confIni->val( $hostname, 'iniEdtk' ); | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | # if iniEdtk == current file then set the value to local (avoid infinite loops) | ||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if ( $tmpIniEdtk eq $iniEdtk ) { last; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | $ENV{EDTK_INIEDTK} = $iniEdtk; | |||||||||||||||||||||||||||
| 94 | 0 | return $iniEdtk; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | sub conf_To_Env { | ||||||||||||||||||||||||||
|
Subroutine
conf_To_Env: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | # load the requested sections of the config file into the environment configuration | ||||||||||||||||||||||||||||
| 100 | # as parameters, pass the path to the ini file + the section to load | ||||||||||||||||||||||||||||
| 101 | # if the HOSTNAME section exists it overrides the values from the section | ||||||||||||||||||||||||||||
| 102 | 0 | my $confIni = shift; | |||||||||||||||||||||||||||
| 103 | 0 | my $section = shift; | |||||||||||||||||||||||||||
| 104 | 0 | ▶ | $section ||= 'DEFAULT'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$section ||= "DEFAULT"
MC/DC0%0/1
$section ||= "DEFAULT"
$section
Truth table0%0/2
A
A= $section
| |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | our ( %hSpecific, %hConfig ); # package-scoped configuration hashes | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if ( -e $confIni ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | else { | ||||||||||||||||||||||||||||
| 111 | 0 | die "ERR. config file not found : $confIni\n"; | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 0 | my $hostname = uc( hostname() ); | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | # OPEN THE CONFIGURATION FILE | ||||||||||||||||||||||||||||
| 117 | 0 | my %hConfIni; | |||||||||||||||||||||||||||
| 118 | 0 | tie %hConfIni, 'Config::IniFiles', ( -file => $confIni ); | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | # LOAD THE VALUES FROM THE SECTION | ||||||||||||||||||||||||||||
| 121 | 0 | my %hSection; | |||||||||||||||||||||||||||
| 122 | 0 | ▶ | if ( exists $hConfIni{$section} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 0 | %hSection = %{ $hConfIni{$section} }; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | # LOAD THE HOSTNAME-SPECIFIC VALUES AS OVERRIDES | ||||||||||||||||||||||||||||
| 127 | 0 | my %hHostname; | |||||||||||||||||||||||||||
| 128 | 0 | ▶ | if ( exists $hConfIni{$hostname} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 0 | undef %hSpecific; | |||||||||||||||||||||||||||
| 130 | 0 | %hHostname = %{ $hConfIni{$hostname} }; | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | else { | ||||||||||||||||||||||||||||
| 133 | 0 | warn "INFO machine '$hostname' unknown in the configuration"; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | 0 | %hConfig = ( %hSection, %hHostname ); | |||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 0 | my $self = abs_path($0); | |||||||||||||||||||||||||||
| 138 | 0 | $self =~ /([\w\.\-]+)[\/\\]\w+\.\w+$/; | |||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | # DEFINITION FOR THE DEV ENVIRONMENT OF THE CURRENT APPLICATION/PROGRAM | ||||||||||||||||||||||||||||
| 141 | 0 | $hConfig{'EDTK_PRGNAME'} = $1; | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | #$hConfig{'EDTK_OPTJOB'} =$EDTK_OPTJOB; | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | # set up the environment variables | ||||||||||||||||||||||||||||
| 146 | 0 | ▶ | while ( ( my $cle, my $valeur ) = each(%hConfig) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 0 | ▶ | $valeur ||= ""; | ||||||||||||||||||||||||||
|
Condition0%0/2
$valeur ||= ""
MC/DC0%0/1
$valeur ||= ""
$valeur
Truth table0%0/2
A
A= $valeur
| |||||||||||||||||||||||||||||
| 148 | 0 | $ENV{$cle} = $valeur; | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | 0 | 1; | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub env_Var_Completion (\$) { ## no critic (ProhibitSubroutinePrototypes) | ||||||||||||||||||||||||||
|
Subroutine
env_Var_Completion: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | # expand the paths, replacing the environment variables with their real values | ||||||||||||||||||||||||||||
| 156 | # every nesting level defined in the environment variables is expanded | ||||||||||||||||||||||||||||
| 157 | # requires the environment variables to be defined beforehand | ||||||||||||||||||||||||||||
| 158 | 0 | my $rScript = shift; | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | # there may be variables within the environment variables themselves | ||||||||||||||||||||||||||||
| 161 | 0 | ▶ | while ( ${$rScript} =~ /\$/g ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | ${$rScript} =~ s/\$(\w+)/${ENV{$1}}/g; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | 0 | ${$rScript} =~ s/(\/)/\\/g; | |||||||||||||||||||||||||||
| 165 | 0 | 1; | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | ################################################################################ | ||||||||||||||||||||||||||||
| 169 | # PRODUCTION TRACKING DEFINITION SECTION | ||||||||||||||||||||||||||||
| 170 | # | ||||||||||||||||||||||||||||
| 171 | # | ||||||||||||||||||||||||||||
| 172 | 4 | my $DBH; | |||||||||||||||||||||||||||
| 173 | my %h_subInsert; | ||||||||||||||||||||||||||||
| 174 | 4 | my %h_subCreate; # referenced by the mode check below; left empty on purpose | |||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | # define the insertion method | ||||||||||||||||||||||||||||
| 177 | 4 | $h_subInsert{'LOG'} = \&subInsert_Log; | |||||||||||||||||||||||||||
| 178 | 4 | $h_subInsert{'DB'} = \&subInsert_DB; | |||||||||||||||||||||||||||
| 179 | 4 | $h_subInsert{'FDB'} = \&subInsert_DB; | |||||||||||||||||||||||||||
| 180 | 4 | $h_subInsert{'none'} = \&noSub; | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 4 | my %h_subClose; | |||||||||||||||||||||||||||
| 183 | 4 | $h_subClose{'DB'} = \&subClose_DB; | |||||||||||||||||||||||||||
| 184 | 4 | $h_subClose{'FDB'} = \&subClose_DB; | |||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub prepare_Tracking_Env() { | ||||||||||||||||||||||||||
|
Subroutine
prepare_Tracking_Env: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 187 | 0 | my $iniEdtk = ini_Edtk_Conf(); | |||||||||||||||||||||||||||
| 188 | 0 | conf_To_Env( $iniEdtk, 'ENVDESC' ); | |||||||||||||||||||||||||||
| 189 | 0 | conf_To_Env( $iniEdtk, 'EDTK_DB' ); | |||||||||||||||||||||||||||
| 190 | 0 | oe_uc_sans_accents( $ENV{EDTK_TRACK_MODE} ); | |||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 0 | 1; | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 0 | ▶ | sub open_Tracking_Env() { | ||||||||||||||||||||||||||
|
Subroutine
open_Tracking_Env: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 196 | 0 | ▶ | if ( $ENV{EDTK_TRACK_MODE} =~ /FDB/i ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | # DB FILE oe_now_time/PROCESS | ||||||||||||||||||||||||||||
| 199 | 0 | $ENV{EDTK_DBI_DNS} =~ s/(.+)\.(\w+)$/$1\.$ED_TSTAMP\.$ED_PROC\.$2/; | |||||||||||||||||||||||||||
| 200 | 0 | warn "INFO tracking to $ENV{EDTK_DBI_DSN}\n"; | |||||||||||||||||||||||||||
| 201 | 0 | create_Track_Table( $ENV{EDTK_DBI_DSN} ); | |||||||||||||||||||||||||||
| 202 | 0 | open_DBI(); | |||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | elsif ( $ENV{EDTK_TRACK_MODE} =~ /LOG/i ) { | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | # log | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | elsif ( $ENV{EDTK_TRACK_MODE} =~ /DB/i ) { | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | # DB connection tracking | ||||||||||||||||||||||||||||
| 213 | 0 | open_DBI(); | |||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | else { | ||||||||||||||||||||||||||||
| 217 | 0 | $ENV{EDTK_TRACK_MODE} = "none"; | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if ( !( $h_subInsert{ $ENV{EDTK_TRACK_MODE} } ) && !( $h_subCreate{ $ENV{EDTK_TRACK_MODE} } ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$h_subInsert{$ENV{"EDTK_TRACK_MODE"}} or $h_subCreate{$ENV{"EDTK_TRACK_MODE"}}
MC/DC0%0/2
$h_subInsert{$ENV{"EDTK_TRACK_MODE"}} or $h_subCreate{$ENV{"EDTK_TRACK_MODE"}}
$h_subInsert{$ENV{"EDTK_TRACK_MODE"}}
$h_subCreate{$ENV{"EDTK_TRACK_MODE"}}
Truth table0%0/3
A or B
A= $h_subInsert{$ENV{"EDTK_TRACK_MODE"}}B= $h_subCreate{$ENV{"EDTK_TRACK_MODE"}}
| |||||||||||||||||||||||||||||
| 222 | { | ||||||||||||||||||||||||||||
| 223 | 0 | warn "INFO $ENV{EDTK_TRACK_MODE} undefined - tracking halted\n"; | |||||||||||||||||||||||||||
| 224 | 0 | $ENV{EDTK_TRACK_MODE} = "none"; | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 0 | 1; | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 0 | ▶ | sub open_DBI() { | ||||||||||||||||||||||||||
|
Subroutine
open_DBI: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 231 | my $dbargs = { | ||||||||||||||||||||||||||||
| 232 | AutoCommit => $ENV{EDTK_DBI_AutoCommit}, | ||||||||||||||||||||||||||||
| 233 | RaiseError => $ENV{EDTK_DBI_RaiseError}, | ||||||||||||||||||||||||||||
| 234 | PrintError => $ENV{EDTK_DBI_PrintError} | ||||||||||||||||||||||||||||
| 235 | 0 | }; | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | $DBH = DBI->connect( | ||||||||||||||||||||||||||||
| 238 | $ENV{EDTK_DBI_DSN}, | ||||||||||||||||||||||||||||
| 239 | $ENV{EDTK_DBI_DSN_USER}, | ||||||||||||||||||||||||||||
| 240 | $ENV{EDTK_DBI_DSN_PASS} | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | # ,$dbargs | ||||||||||||||||||||||||||||
| 243 | 0 | ▶ | ) or die "ERR no connection to $ENV{EDTK_DBI_DSN} " . DBI->errstr; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 0 | 1; | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | ▶ | sub init_Tracking { | ||||||||||||||||||||||||||
|
Subroutine
init_Tracking: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 249 | 0 | my $Mod_Ed = shift; | |||||||||||||||||||||||||||
| 250 | 0 | my $Typ_Job = shift; | |||||||||||||||||||||||||||
| 251 | 0 | my $Job_User = shift; | |||||||||||||||||||||||||||
| 252 | 0 | my @Track_Key = @_; | |||||||||||||||||||||||||||
| 253 | 0 | define_Mod_Ed($Mod_Ed); # U(ndef) by default | |||||||||||||||||||||||||||
| 254 | 0 | define_Job_Evt($Typ_Job); # S(pool) by default | |||||||||||||||||||||||||||
| 255 | 0 | define_Job_User($Job_User); # user job request, by default 'None' | |||||||||||||||||||||||||||
| 256 | 0 | $ED_HOST = hostname(); | |||||||||||||||||||||||||||
| 257 | 0 | $ED_TSTAMP = oe_now_time(); | |||||||||||||||||||||||||||
| 258 | 0 | $ED_PROC = $$; | |||||||||||||||||||||||||||
| 259 | 0 | $ED_SEQ = 0; # (dynamic, private) | |||||||||||||||||||||||||||
| 260 | 0 | $ED_SNGL_ID = md5_base64( $ED_HOST . $ED_TSTAMP . $ED_PROC ); | |||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | &prepare_Tracking_Env(); | |||||||||||||||||||||||||||
| 263 | 0 | &open_Tracking_Env(); | |||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 0 | my $indice = 0; | |||||||||||||||||||||||||||
| 266 | 0 | foreach my $element (@Track_Key) { | |||||||||||||||||||||||||||
| 267 | 0 | define_Track_Key( $element, $indice++ ); # default key for indiced col_name | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 0 | $0 =~ /([\w-]+)[\.plmex]*$/; | |||||||||||||||||||||||||||
| 271 | 0 | ▶ | $1 ? $ED_APP = "application" : $ED_APP = $1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 0 | $ED_OBJS = 1; ## default insert unit count (dynamic) | |||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 0 | warn | |||||||||||||||||||||||||||
| 276 | "INFO tracking init ( track mode : $ENV{EDTK_TRACK_MODE}, edition mode : $ED_MOD_ED, job type : $ED_JOB_EVT, user : $ED_USER, optional Keys : @ED_K_NAME )\n"; | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 0 | return $ED_SNGL_ID; | |||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | 0 | ▶ | sub track_Obj { | ||||||||||||||||||||||||||
|
Subroutine
track_Obj: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | # track_Obj ([$ED_OBJS, $ED_JOB_EVT, @ED_K_VAL]) | ||||||||||||||||||||||||||||
| 284 | # $ED_OBJS (optional) : number of units of the object (1 by default) | ||||||||||||||||||||||||||||
| 285 | # $ED_JOB_EVT (optional) : event in question (see define_Job_Evt) | ||||||||||||||||||||||||||||
| 286 | # @ED_K_VAL (optional) : values of the optional keys defined with init_Tracking (same order) | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | 0 | $ED_SEQ++; | |||||||||||||||||||||||||||
| 289 | 0 | $ED_OBJS = shift; | |||||||||||||||||||||||||||
| 290 | 0 | ▶ | $ED_OBJS ||= 1; | ||||||||||||||||||||||||||
|
Condition0%0/2
$ED_OBJS ||= 1
MC/DC0%0/1
$ED_OBJS ||= 1
$ED_OBJS
Truth table0%0/2
A
A= $ED_OBJS
| |||||||||||||||||||||||||||||
| 291 | 0 | define_Job_Evt(shift); | |||||||||||||||||||||||||||
| 292 | 0 | @ED_K_VAL = @_; | |||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 0 | undef @TRACKED_OBJ; | |||||||||||||||||||||||||||
| 295 | 0 | push( @TRACKED_OBJ, oe_now_time() ); | |||||||||||||||||||||||||||
| 296 | 0 | push( @TRACKED_OBJ, $ED_USER ); | |||||||||||||||||||||||||||
| 297 | 0 | push( @TRACKED_OBJ, $ED_SEQ ); | |||||||||||||||||||||||||||
| 298 | 0 | push( @TRACKED_OBJ, $ED_SNGL_ID ); | |||||||||||||||||||||||||||
| 299 | 0 | push( @TRACKED_OBJ, $ED_APP ); | |||||||||||||||||||||||||||
| 300 | 0 | push( @TRACKED_OBJ, $ED_MOD_ED ); | |||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 0 | push( @TRACKED_OBJ, $ED_JOB_EVT ); | |||||||||||||||||||||||||||
| 303 | 0 | push( @TRACKED_OBJ, $ED_OBJS ); | |||||||||||||||||||||||||||
| 304 | 0 | undef @DB_USER_COL; | |||||||||||||||||||||||||||
| 305 | 0 | ▶ | for ( my $i = 0 ; $i <= $#ED_K_VAL ; $i++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 306 | 0 | ▶ | push( @TRACKED_OBJ, $ED_K_NAME[$i] || "" ); | ||||||||||||||||||||||||||
|
Condition0%0/2
$ED_K_NAME[$i] || ''
MC/DC0%0/1
$ED_K_NAME[$i] || ''
$ED_K_NAME[$i]
Truth table0%0/2
A
A= $ED_K_NAME[$i]
| |||||||||||||||||||||||||||||
| 307 | 0 | ▶ | push( @TRACKED_OBJ, $ED_K_VAL[$i] || "" ); | ||||||||||||||||||||||||||
|
Condition0%0/2
$ED_K_VAL[$i] || ''
MC/DC0%0/1
$ED_K_VAL[$i] || ''
$ED_K_VAL[$i]
Truth table0%0/2
A
A= $ED_K_VAL[$i]
| |||||||||||||||||||||||||||||
| 308 | 0 | push( @DB_USER_COL, "ED_K${i}_NAME" ); | |||||||||||||||||||||||||||
| 309 | 0 | push( @DB_USER_COL, "ED_K${i}_VAL" ); | |||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 0 | ▶ | &{ $h_subInsert{ $ENV{EDTK_TRACK_MODE} } } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 313 | or die "ERR. undefined EDTK_TRACK_MODE -> $ENV{EDTK_TRACK_MODE}\n"; | ||||||||||||||||||||||||||||
| 314 | 0 | 1; | |||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 0 | ▶ | sub define_Mod_Ed { | ||||||||||||||||||||||||||
|
Subroutine
define_Mod_Ed: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | # Printing Mode : looking for one of the following : | ||||||||||||||||||||||||||||
| 320 | # Undef (default), Batch, Tp, Web, Mail | ||||||||||||||||||||||||||||
| 321 | 0 | my $value = shift; | |||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 0 | ▶ | if ($value) { $ED_MOD_ED = $value } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 324 | 0 | $ED_MOD_ED =~ /([NBTWM])/; | |||||||||||||||||||||||||||
| 325 | 0 | $ED_MOD_ED = $1; | |||||||||||||||||||||||||||
| 326 | 0 | ▶ | $ED_MOD_ED ||= "U"; # Undef by default | ||||||||||||||||||||||||||
|
Condition0%0/2
$ED_MOD_ED ||= "U"
MC/DC0%0/1
$ED_MOD_ED ||= "U"
$ED_MOD_ED
Truth table0%0/2
A
A= $ED_MOD_ED
| |||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 0 | return $ED_MOD_ED; | |||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 0 | ▶ | sub define_Job_Evt { | ||||||||||||||||||||||||||
|
Subroutine
define_Job_Evt: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | # Job Event : looking for one of the following : | ||||||||||||||||||||||||||||
| 334 | # Job (default), Spool, Document, Line, Warning, Error, Halt (critic), Reject | ||||||||||||||||||||||||||||
| 335 | 0 | my $value = shift; | |||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if ($value) { $ED_JOB_EVT = $value } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 338 | 0 | $ED_JOB_EVT =~ /([JSDLWEHR])/; | |||||||||||||||||||||||||||
| 339 | 0 | $ED_JOB_EVT = $1; | |||||||||||||||||||||||||||
| 340 | 0 | ▶ | $ED_JOB_EVT ||= "J"; # Job by default | ||||||||||||||||||||||||||
|
Condition0%0/2
$ED_JOB_EVT ||= "J"
MC/DC0%0/1
$ED_JOB_EVT ||= "J"
$ED_JOB_EVT
Truth table0%0/2
A
A= $ED_JOB_EVT
| |||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 0 | return $ED_JOB_EVT; | |||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 0 | ▶ | sub define_Job_User { | ||||||||||||||||||||||||||
|
Subroutine
define_Job_User: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | # USER JOB REQUEST : LOOKING FOR ONE OF THE FOLLOWING : | ||||||||||||||||||||||||||||
| 348 | # None (default), user Id (max 10 alphanumerics) | ||||||||||||||||||||||||||||
| 349 | 0 | my $value = shift; | |||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if ( $value =~ /(\w{1,10})/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 352 | 0 | $ED_USER = $1; | |||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||
| 354 | else { | ||||||||||||||||||||||||||||
| 355 | 0 | $ED_USER = "None"; | |||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 0 | return $ED_USER; | |||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | 0 | ▶ | sub define_Track_Key { | ||||||||||||||||||||||||||
|
Subroutine
define_Track_Key: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | # TO DEFINE THE COL_NAME OF THE N INDICED TRACKING KEY | ||||||||||||||||||||||||||||
| 364 | 0 | my $value = shift; | |||||||||||||||||||||||||||
| 365 | 0 | my $indice = shift; | |||||||||||||||||||||||||||
| 366 | 0 | ▶ | $indice ||= 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$indice ||= 0
MC/DC0%0/1
$indice ||= 0
$indice
Truth table0%0/2
A
A= $indice
| |||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 0 | ▶ | if ( !defined $ENV{EDTK_MAX_USER_KEY} ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 369 | 0 | warn "INFO: tracking key undefined\n"; | |||||||||||||||||||||||||||
| 370 | 0 | return 0; | |||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | elsif ( $indice gt( $ENV{EDTK_MAX_USER_KEY} - 1 ) ) { | ||||||||||||||||||||||||||||
| 374 | 0 | warn "INFO: tracking key not allowed (limit is $ENV{EDTK_MAX_USER_KEY})\n"; | |||||||||||||||||||||||||||
| 375 | 0 | return 0; | |||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||
| 378 | elsif ( length($value) > 5 ) { | ||||||||||||||||||||||||||||
| 379 | 0 | $value =~ s/^(\w{5})(.*)/$1/; | |||||||||||||||||||||||||||
| 380 | 0 | warn "INFO: redefined col as '$value'"; | |||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||
| 382 | 0 | ▶ | if ($value) { $ED_K_NAME[$indice] = $value; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | 0 | $ED_K_NAME[$indice] =~ s/\s/\_/g; | |||||||||||||||||||||||||||
| 385 | 0 | oe_uc_sans_accents( $ED_K_NAME[$indice] ); | |||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | 0 | return $ED_K_NAME[$indice]; | |||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | 0 | ▶ | sub subInsert_Log() { | ||||||||||||||||||||||||||
|
Subroutine
subInsert_Log: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | # WHEN TRACKING IS DONE THROUGH LOG FILES | ||||||||||||||||||||||||||||
| 393 | # TODO complete with the use of the Logger replacement | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | 0 | my $request = join( ", ", @TRACKED_OBJ ); | |||||||||||||||||||||||||||
| 396 | 0 | warn "$request\n"; | |||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | 0 | 1; | |||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | 0 | ▶ | sub subInsert_DB() { | ||||||||||||||||||||||||||
|
Subroutine
subInsert_DB: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | # build the SQL command to insert into a DBI database (file/DB) | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | 0 | my $request = "insert into $ENV{EDTK_DBI_TRACKING}"; | |||||||||||||||||||||||||||
| 406 | 0 | $request .= " ("; | |||||||||||||||||||||||||||
| 407 | 0 | $request .= | |||||||||||||||||||||||||||
| 408 | "ED_TSTAMP, ED_USER, ED_SEQ, ED_SNGL_ID, ED_APP, ED_MOD_ED, ED_JOB_EVT, ED_OBJ_COUNT"; | ||||||||||||||||||||||||||||
| 409 | 0 | ▶ | if (@DB_USER_COL) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 410 | 0 | $request .= ", "; | |||||||||||||||||||||||||||
| 411 | 0 | $request .= join( ", ", @DB_USER_COL ); | |||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||
| 413 | 0 | $request .= " ) values ('"; | |||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | # DATE FORMATTING FOR THE DBMS | ||||||||||||||||||||||||||||
| 416 | # $request .=sprintf ("to_date('%014.f', 'YYYYMMDDHH24MISS'), '", shift @TRACKED_OBJ); | ||||||||||||||||||||||||||||
| 417 | 0 | $request .= join( "', '", @TRACKED_OBJ ); | |||||||||||||||||||||||||||
| 418 | 0 | $request .= "')"; | |||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | 0 | $DBH->do($request); | |||||||||||||||||||||||||||
| 421 | 0 | ▶ | if ( $DBH->err() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 422 | 0 | warn "INFO " . $DBI::errstr . "\n"; | |||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | # $DBH->commit(); # needed when AutoCommit is 0 | ||||||||||||||||||||||||||||
| 426 | # $DBH->disconnect(); | ||||||||||||||||||||||||||||
| 427 | # if ($DBH->err()) { warn "$DBI::errstr\n"; } | ||||||||||||||||||||||||||||
| 428 | 0 | 1; | |||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | 0 | ▶ | sub noSub() { | ||||||||||||||||||||||||||
|
Subroutine
noSub: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | # EMPTY FUNCTION FOR THE %H_SUBINSERT FUNCTION POINTERS | ||||||||||||||||||||||||||||
| 434 | # to avoid using tests in repetitive functions | ||||||||||||||||||||||||||||
| 435 | # (fake switch/case) | ||||||||||||||||||||||||||||
| 436 | 0 | return 1; | |||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | 0 | ▶ | sub test_exist_table() { | ||||||||||||||||||||||||||
|
Subroutine
test_exist_table: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 440 | my $dbargs = { | ||||||||||||||||||||||||||||
| 441 | AutoCommit => $ENV{EDTK_DBI_AutoCommit}, | ||||||||||||||||||||||||||||
| 442 | RaiseError => $ENV{EDTK_DBI_RaiseError}, | ||||||||||||||||||||||||||||
| 443 | PrintError => $ENV{EDTK_DBI_PrintError} | ||||||||||||||||||||||||||||
| 444 | 0 | }; | |||||||||||||||||||||||||||
| 445 | $DBH = | ||||||||||||||||||||||||||||
| 446 | DBI->connect( $ENV{EDTK_DBI_DSN}, $ENV{EDTK_DBI_DSN_USER}, | ||||||||||||||||||||||||||||
| 447 | 0 | ▶ | $ENV{EDTK_DBI_DSN_PASS}, $dbargs ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 448 | or die "ERR no connection to $ENV{EDTK_DBI_DSN} " . DBI->errstr; | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | 0 | my $request = "select * from $ENV{EDTK_DBI_TABLENAME}"; | |||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | 0 | $DBH->do($request); | |||||||||||||||||||||||||||
| 453 | 0 | ▶ | if ($DBI::errstr) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 454 | 0 | ▶ | if ( $DBI::errstr =~ /no such table/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 455 | 0 | $DBH->disconnect(); | |||||||||||||||||||||||||||
| 456 | 0 | return 0; | |||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||
| 458 | 0 | warn "INFO " . $DBI::errstr . "\n"; | |||||||||||||||||||||||||||
| 459 | 0 | $DBH->disconnect(); | |||||||||||||||||||||||||||
| 460 | 0 | return $NOK; | |||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||
| 462 | 0 | $DBH->disconnect(); | |||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | 0 | 1; | |||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | 0 | ▶ | sub edit_Track_Table { | ||||||||||||||||||||||||||
|
Subroutine
edit_Track_Table: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 468 | 0 | my $request = shift; | |||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | 0 | &open_DBI(); | |||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | 0 | my $ref_Tab = &fetchall_DBI($request); | |||||||||||||||||||||||||||
| 473 | 0 | &edit_All_rTab($ref_Tab); | |||||||||||||||||||||||||||
| 474 | 0 | 1; | |||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | 0 | ▶ | sub create_Track_Table() { | ||||||||||||||||||||||||||
|
Subroutine
create_Track_Table: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | #my $dbi_dns=shift; | ||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | # CREATE TABLE tablename [IF NOT EXISTS][TEMPORARY] (column1data_type, column2data_type, column3data_type); | ||||||||||||||||||||||||||||
| 482 | #&prepare_Tracking_Env(); | ||||||||||||||||||||||||||||
| 483 | #$dbi_dns ||=$ENV{EDTK_DBI_DNS}; | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | 0 | my $dbargs = { | |||||||||||||||||||||||||||
| 486 | AutoCommit => 0, | ||||||||||||||||||||||||||||
| 487 | RaiseError => 0, | ||||||||||||||||||||||||||||
| 488 | PrintError => 0 | ||||||||||||||||||||||||||||
| 489 | }; | ||||||||||||||||||||||||||||
| 490 | $DBH = | ||||||||||||||||||||||||||||
| 491 | DBI->connect( $ENV{EDTK_DBI_DSN}, $ENV{EDTK_DBI_DSN_USER}, $ENV{EDTK_DBI_DSN_PASS}, | ||||||||||||||||||||||||||||
| 492 | 0 | ▶ | $dbargs ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 493 | or die "ERR no connection to $ENV{EDTK_DBI_DSN} " . DBI->errstr; | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | 0 | my $struct = "CREATE TABLE $ENV{EDTK_DBI_TABLENAME} "; | |||||||||||||||||||||||||||
| 496 | 0 | $struct .= | |||||||||||||||||||||||||||
| 497 | "( ED_TSTAMP NUMBER(14) NOT NULL"; # interesting for formated date and interval search | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | # $struct .="( ED_TSTAMP VARCHAR2(14) NOT NULL"; # most used | ||||||||||||||||||||||||||||
| 500 | # $struct .="( ED_TSTAMP DATE NOT NULL"; # Not compatible | ||||||||||||||||||||||||||||
| 501 | # $struct .=", ED_HOST VARCHAR2(15) NOT NULL"; # hostname | ||||||||||||||||||||||||||||
| 502 | # $struct .=", ED_PROC VARCHAR2(6) NOT NULL"; # process | ||||||||||||||||||||||||||||
| 503 | 0 | $struct .= ", ED_USER VARCHAR2(10) NOT NULL"; # job request user | |||||||||||||||||||||||||||
| 504 | 0 | $struct .= ", ED_SEQ NUMBER(9) NOT NULL"; # sequence | |||||||||||||||||||||||||||
| 505 | 0 | $struct .= ", ED_SNGL_ID VARCHAR2(22) NOT NULL"; # Single ID | |||||||||||||||||||||||||||
| 506 | 0 | $struct .= ", ED_APP VARCHAR2(15) NOT NULL"; # application name | |||||||||||||||||||||||||||
| 507 | 0 | $struct .= ", ED_MOD_ED CHAR"; # edition mode (Batch, Tp, Web, Mail) | |||||||||||||||||||||||||||
| 508 | 0 | $struct .= | |||||||||||||||||||||||||||
| 509 | ", ED_JOB_EVT CHAR"; # event level within the job (Spool, Document, Line, Warning, Error) | ||||||||||||||||||||||||||||
| 510 | 0 | $struct .= ", ED_OBJ_COUNT NUMBER(15)"; # number of elements/objects attached to the event | |||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | 0 | ▶ | for ( my $i = 0 ; $i lt $ENV{EDTK_MAX_USER_KEY} ; $i++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 513 | 0 | $struct .= ", ED_K${i}_NAME VARCHAR2(5)"; # key name $i | |||||||||||||||||||||||||||
| 514 | 0 | $struct .= ", ED_K${i}_VAL VARCHAR2(30)"; # key value $i | |||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||
| 516 | 0 | $struct .= | |||||||||||||||||||||||||||
| 517 | ")"; #, CONSTRAINT pk_$ENV{EDTK_DBI_TABLENAME} PRIMARY KEY (ED_TSTAMP, ED_PROC, ED_SEQ)"; | ||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | 0 | $DBH->do($struct); | |||||||||||||||||||||||||||
| 520 | 0 | ▶ | if ($DBI::errstr) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 521 | 0 | warn "INFO " . $DBI::errstr . "\n"; | |||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | # my $seq ="CREATE SEQUENCE sq_$TABLENAME | ||||||||||||||||||||||||||||
| 525 | # MINVALUE 1 | ||||||||||||||||||||||||||||
| 526 | # MAXVALUE 999999999 | ||||||||||||||||||||||||||||
| 527 | # START WITH 1 | ||||||||||||||||||||||||||||
| 528 | # INCREMENT BY 1;"; | ||||||||||||||||||||||||||||
| 529 | #$dbh->do("$seq"); | ||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | 0 | $DBH->commit(); # needed when AutoCommit is 0 | |||||||||||||||||||||||||||
| 532 | 0 | $DBH->disconnect(); | |||||||||||||||||||||||||||
| 533 | 0 | 1; | |||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||
| 536 | 0 | ▶ | sub drop_Track_Table() { | ||||||||||||||||||||||||||
|
Subroutine
drop_Track_Table: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 537 | 0 | &prepare_Tracking_Env(); | |||||||||||||||||||||||||||
| 538 | 0 | &open_DBI(); | |||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | 0 | warn "=> Drop table $ENV{EDTK_DBI_TABLENAME} from $ENV{EDTK_DBI_DSN}, if exist\n\n"; | |||||||||||||||||||||||||||
| 541 | 0 | $DBH->do("DROP TABLE $ENV{EDTK_DBI_TABLENAME}"); | |||||||||||||||||||||||||||
| 542 | 0 | $DBH->disconnect; | |||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | 0 | 1; | |||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||
| 547 | 0 | ▶ | sub fetchall_DBI { | ||||||||||||||||||||||||||
|
Subroutine
fetchall_DBI: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | # CONNECT TO A DBI TABLE TO SELECT INTO AN ARRAY REFERENCE | ||||||||||||||||||||||||||||
| 550 | # select all the data matching a criterion | ||||||||||||||||||||||||||||
| 551 | # option: query to pass, example "SELECT * FROM TRACKING_OEDTK WHERE ED_MOD_ED = 'T'" | ||||||||||||||||||||||||||||
| 552 | # by default it is 'SELECT * from $ENV{EDTK_DBI_TABLENAME}' | ||||||||||||||||||||||||||||
| 553 | 0 | my $request = shift; | |||||||||||||||||||||||||||
| 554 | 0 | ▶ | $request ||= "SELECT * from $ENV{EDTK_DBI_TABLENAME}"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$request ||= qq[SELECT * from $ENV{"EDTK_DBI_TABLENAME"}]
MC/DC0%0/1
$request ||= qq[SELECT * from $ENV{"EDTK_DBI_TABLENAME"}]
$request
Truth table0%0/2
A
A= $request
| |||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | 0 | my $sql = qq($request); | |||||||||||||||||||||||||||
| 557 | 0 | my $sth = $DBH->prepare($sql); | |||||||||||||||||||||||||||
| 558 | 0 | ▶ | $sth->execute() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 559 | || warn "ERR. DBI exec " . $DBH->errstr; | ||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||
| 561 | 0 | my $rTab = $sth->fetchall_arrayref; | |||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||
| 563 | 0 | $sth->{Active} = 1 | |||||||||||||||||||||||||||
| 564 | ; # fix for the SQLite bug "closing dbh with active statement" http://rt.cpan.org/Public/Bug/Display.html?id=9643 | ||||||||||||||||||||||||||||
| 565 | 0 | $sth->finish(); | |||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||
| 567 | #$DBH->commit(); # needed when AutoCommit is 0 ??? | ||||||||||||||||||||||||||||
| 568 | 0 | ▶ | if ($DBI::errstr) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 569 | 0 | warn $DBI::errstr . "\n"; | |||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||
| 572 | 0 | return $rTab; | |||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | 0 | ▶ | sub edit_All_rTab { | ||||||||||||||||||||||||||
|
Subroutine
edit_All_rTab: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | # PRINT ALL THE DATA OF AN ARRAY PASSED BY REFERENCE | ||||||||||||||||||||||||||||
| 578 | # display the array in columns | ||||||||||||||||||||||||||||
| 579 | 0 | my $rTab = shift; | |||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | 0 | ▶ | for ( my $i = 0 ; $i <= $#{$rTab} ; $i++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 582 | 0 | my $cols = $#{ $$rTab[$i] }; | |||||||||||||||||||||||||||
| 583 | 0 | print "\n$i:\t"; | |||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||
| 585 | 0 | ▶ | for ( my $j = 0 ; $j <= $cols ; $j++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 586 | 0 | ▶ | print "$$rTab[$i][$j]" if ( defined $$rTab[$i][$j] ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||
| 589 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||
| 591 | 0 | 1; | |||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | 0 | ▶ | sub subClose_DB() { | ||||||||||||||||||||||||||
|
Subroutine
subClose_DB: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 595 | 0 | ▶ | $DBH->commit() if ( $ENV{EDTK_DBI_AutoCommit} eq 0 ); # needed when AutoCommit is 0 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||
| 597 | # $DBH->disconnect(); | ||||||||||||||||||||||||||||
| 598 | 0 | 1; | |||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||
| 601 | 2 | ▶ | END { | ||||||||||||||||||||||||||
|
Subroutine
END: called CC=2 SCAR=10.5
| |||||||||||||||||||||||||||||
| 602 | 2 | ▶ | if ( exists $h_subClose{EDTK_TRACK_MODE} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 603 | 0 | &{ $h_subClose{ $ENV{EDTK_TRACK_MODE} } }; | |||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||
| 606 | 4 | 1; | |||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||
| 608 | =head1 NAME | ||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||
| 610 | oEdtk::trackEdtk - production tracking: configuration, environment and insert | ||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||
| 612 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||
| 614 | use oEdtk::trackEdtk qw(init_Tracking track_Obj); | ||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||
| 616 | init_Tracking($mod_ed, $job_evt, $job_user, @keys); | ||||||||||||||||||||||||||||
| 617 | # ... run the job ... | ||||||||||||||||||||||||||||
| 618 | track_Obj($count, $job_evt, @key_values); | ||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||
| 620 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | Legacy production-tracking helper. It locates and loads the site configuration | ||||||||||||||||||||||||||||
| 623 | into C<%ENV>, then records tracking events either in a database (C<DB>), in a | ||||||||||||||||||||||||||||
| 624 | per-process SQLite file (C<FDB>) or in flat log files (C<LOG>), following | ||||||||||||||||||||||||||||
| 625 | C<EDTK_TRACK_MODE>. L<oEdtk::Tracking> is its object-oriented successor; this | ||||||||||||||||||||||||||||
| 626 | library is meant to be taken over by it. | ||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||
| 628 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||
| 630 | =head2 ini_Edtk_Conf | ||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | my $ini = ini_Edtk_Conf(); | ||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||
| 634 | Locate and return the valid configuration file, following the C<iniEdtk> chain | ||||||||||||||||||||||||||||
| 635 | declared in the hostname section, and set C<$ENV{EDTK_INIEDTK}>. | ||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||
| 637 | =head2 conf_To_Env | ||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||
| 639 | conf_To_Env($confIni, $section); | ||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||
| 641 | Load a section of the configuration file into C<%ENV>, with the hostname section | ||||||||||||||||||||||||||||
| 642 | overriding the section values when it exists. | ||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||
| 644 | =head2 env_Var_Completion | ||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||
| 646 | env_Var_Completion(\$script); | ||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||
| 648 | Expand the environment variables nested inside C<$script>, level by level, until | ||||||||||||||||||||||||||||
| 649 | none remains. | ||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||
| 651 | =head2 init_Tracking | ||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||
| 653 | my $single_id = init_Tracking($mod_ed, $job_evt, $job_user, @keys); | ||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||
| 655 | Initialise the tracking environment: define the edition mode, the job event and | ||||||||||||||||||||||||||||
| 656 | the user, then the optional keys, and return the single identifier of the run. | ||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||
| 658 | =head2 track_Obj | ||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||
| 660 | track_Obj($count, $job_evt, @key_values); | ||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||
| 662 | Record one tracked object with the current settings. C<$count> defaults to one, | ||||||||||||||||||||||||||||
| 663 | and the optional key values follow the order given to L</init_Tracking>. | ||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||
| 665 | =head2 define_Mod_Ed | ||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||
| 667 | my $code = define_Mod_Ed($value); | ||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||
| 669 | Set the edition mode (Undef, Batch, Tp, Web or Mail) and return its one-letter | ||||||||||||||||||||||||||||
| 670 | code (C<U> by default). | ||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||
| 672 | =head2 define_Job_Evt | ||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||
| 674 | my $code = define_Job_Evt($value); | ||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||
| 676 | Set the job event (Job, Spool, Document, Line, Warning, Error, Halt or Reject) | ||||||||||||||||||||||||||||
| 677 | and return its one-letter code (C<J> by default). | ||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | =head2 define_Track_Key | ||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||
| 681 | my $name = define_Track_Key($value, $index); | ||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||
| 683 | Define the column name of the C<$index>-th optional tracking key. The name is | ||||||||||||||||||||||||||||
| 684 | truncated to five characters and upper-cased without accents, and refused when | ||||||||||||||||||||||||||||
| 685 | the index exceeds C<EDTK_MAX_USER_KEY>. | ||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||
| 687 | =head2 edit_Track_Table | ||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||
| 689 | edit_Track_Table($request); | ||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||
| 691 | Run a C<SELECT> against the tracking table and display the resulting rows. | ||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||
| 693 | =head2 create_Track_Table | ||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||
| 695 | create_Track_Table(); | ||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||
| 697 | Create the tracking table for the current DSN, with one name/value column pair | ||||||||||||||||||||||||||||
| 698 | per configured user key. | ||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||
| 700 | =head2 prepare_Tracking_Env | ||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||
| 702 | prepare_Tracking_Env(); | ||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||
| 704 | Load the tracking configuration and normalise the tracking mode. | ||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||
| 706 | =head2 drop_Track_Table | ||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||
| 708 | drop_Track_Table(); | ||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||
| 710 | Drop the tracking table for the current DSN, if it exists. | ||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||
| 712 | The following subs are internal helpers and are not part of the public API: | ||||||||||||||||||||||||||||
| 713 | C<open_Tracking_Env>, C<open_DBI>, C<define_Job_User>, C<subInsert_Log>, | ||||||||||||||||||||||||||||
| 714 | C<subInsert_DB>, C<noSub>, C<test_exist_table>, C<fetchall_DBI>, | ||||||||||||||||||||||||||||
| 715 | C<edit_All_rTab> and C<subClose_DB>. | ||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||
| 717 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||
| 719 | The oEdtk team. | ||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||
| 721 | =cut | ||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||
| 723 | # NOTES | ||||||||||||||||||||||||||||
| 724 | # | ||||||||||||||||||||||||||||
| 725 | # LIST OF TABLES | ||||||||||||||||||||||||||||
| 726 | # select table_name from tabs; | ||||||||||||||||||||||||||||
| 727 | # | ||||||||||||||||||||||||||||
| 728 | # List the tables of the current user's schema: | ||||||||||||||||||||||||||||
| 729 | # SELECT table_name FROM user_tables; | ||||||||||||||||||||||||||||
| 730 | # | ||||||||||||||||||||||||||||
| 731 | # List the tables accessible by the user: | ||||||||||||||||||||||||||||
| 732 | # SELECT table_name FROM all_tables; | ||||||||||||||||||||||||||||
| 733 | # | ||||||||||||||||||||||||||||
| 734 | # List all the tables (ADMIN is required): | ||||||||||||||||||||||||||||
| 735 | # SELECT table_name FROM dba_tables; | ||||||||||||||||||||||||||||
| 736 | # | ||||||||||||||||||||||||||||
| 737 | # TABLE DESCRIPTION: | ||||||||||||||||||||||||||||
| 738 | # desc my_table; # returns the fields and their types | ||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||
| 740 | # EXAMPLE QUERIES - http://fadace.developpez.com/sgbdcmp/fonctions/ | ||||||||||||||||||||||||||||
| 741 | # | ||||||||||||||||||||||||||||
| 742 | # SELECT * FROM TRACKING_OEDTK WHERE ED_JOB_EVT='S'; | ||||||||||||||||||||||||||||
| 743 | # SELECT * FROM TRACKING_OEDTK WHERE ED_MOD_ED='T'; | ||||||||||||||||||||||||||||
| 744 | # SELECT SUM(ED_OBJ_COUNT) AS "OBJECTS" FROM TRACKING_OEDTK WHERE ED_JOB_EVT='D'; | ||||||||||||||||||||||||||||
| 745 | # SELECT COUNT(ED_OBJ_COUNT) AS "OBJECTS" FROM TRACKING_OEDTK WHERE ED_JOB_EVT='D'; | ||||||||||||||||||||||||||||
| 746 | # SELECT DISTINCT ED_SNGL_ID FROM TRACKING_OEDTK; | ||||||||||||||||||||||||||||
| 747 | # SELECT COUNT (DISTINCT ED_SNGL_ID) FROM TRACKING_OEDTK ; | ||||||||||||||||||||||||||||
| 748 | # SELECT COUNT (DISTINCT ED_SNGL_ID) FROM TRACKING_OEDTK WHERE ED_JOB_EVT='D'; | ||||||||||||||||||||||||||||
| 749 | # SELECT COUNT (DISTINCT ED_SNGL_ID) AS "TOTAL" FROM TRACKING_OEDTK WHERE ED_JOB_EVT='D' AND ED_MOD_ED='T'; | ||||||||||||||||||||||||||||
| 750 | # SELECT ED_TSTAMP, ED_APP, ED_SNGL_ID FROM TRACKING_OEDTK WHERE ED_MOD_ED='T' AND ED_JOB_EVT='S'; | ||||||||||||||||||||||||||||
| 751 | # SELECT to_char(ED_TSTAMP, 'DD/MM/YYYY HH24:MM:SS'), ED_APP, ED_SNGL_ID FROM TRACKING_OEDTK WHERE ED_MOD_ED='T' AND ED_JOB_EVT='S'; | ||||||||||||||||||||||||||||
| 752 | # SELECT to_char(ED_TSTAMP, 'DD/MM/YYYY HH24:MM:SS') AS TIME , ED_APP, ED_SNGL_ID FROM TRACKING_OEDTK WHERE ED_MOD_ED='B' AND ED_JOB_EVT='S'; | ||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||
| 754 | # update EDTK_FILIERES SET ed_postcomp =2020 where ed_postcomp<>'FilR100'; | ||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||
| 756 | # | ||||||||||||||||||||||||||||
| 757 | # END | ||||||||||||||||||||||||||||