1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#******************************************************
#Insertion des informations contenues dans les
#variables vers le fichier indicateur_convention.txt
#******************************************************
my $fichier = "$Date|$Caisse|$NomFichier|$DateFichier|$HeureFichier\n";
my $titre = "Date|Caisse|Nom fichier|Datefichier|Heurefichier|\n";
my $chemin = "./indicateur_convention.txt";
open (FH, ">>$chemin") || die $!;
print FH $titre\n;
while ($fichier ne "")
{
print FH $fichier\n;
}
close (FH)
#******************************************************
#Insertion des informations contenues dans les
#variables vers la table Infocentre
#******************************************************
# récupération info fichier
open (FILE, ./indicateur_convention.txt) or die "impossible d'ouvrir le fichier";
my @lines = <FILE>;
close (FILE);
#Connexion BDD
my $db = 'DBI:oracle:BDD:adresseip';
my $user = '***';
my $pass = '***';
my $dbh = DBI->connect($db, $user, $pass)
or die "connexion impossible";
# traitement et inserstion ligne par ligne du fichier
foreach (@lines){
my ($Date, $Caisse, $NomFichier, $DateFichier, $HeureFichier) = split (/|/, $_);
my $req = $dbh->prepare("INSERT INTO INF_F_PUB_INTRANET VALUES('$Date', '$Caisse', '$NomFichier', '$DateFichier', '$HeureFichier')");
$req->execute()or die "requete impossible";
}
$dbh->disconnect(); |
Partager