|< 1 2 >| | 11 Einträge, 2 Seiten |
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
use DBI();
use FileHandle();
use IO::File;
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#Dekleration benötigter Variablen
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
my ($TicketNumber, $Year, $Month, $FiscalYear, $TicketTitle, $Category, $Problemtype, $Component,
$SLA, $EscalationLevel, $Status, $Priority, $Queue, $Customer, $CustomerUserID, $TicketOwner,
$DirectSolve, $Hostname, $Created, $Solved);
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#DB Connection aufbauen
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
my $DB_NAME = "otrs_test";
my $DB_DSN = "DBI:mysql:database=$DB_NAME";
my $DB_USER = "******";
my $DB_PASSWD = "*****";
my $dbh = DBI->connect($DB_DSN, $DB_USER, $DB_PASSWD) or die "Fehler bei Datenbankverbindung";
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#Erstellen der Tabelle TicketData
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
my $SQL_CreateTable = "CREATE TABLE TicketData(
TicketNumber VARCHAR(50) ,
Year YEAR,
Month INT,
FiscalYear YEAR,
TicketTitle VARCHAR(255),
Category VARCHAR(50),
Problemtype VARCHAR(50),
Component VARCHAR(50),
SLA VARCHAR(20),
EscalationLevel TINYINT,
Status VARCHAR(20),
Priority VARCHAR(20),
Queue VARCHAR(50),
Customer VARCHAR(100),
CustomerUserID VARCHAR(100),
Ticketowner VARCHAR(50),
Directsolve TINYINT,
Hostname VARCHAR(20),
Created DATETIME,
Solved DATETIME,
PRIMARY KEY (TicketNumber)
)";
my $Abfrage = $dbh->prepare($SQL_CreateTable);
$Abfrage->execute();
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#Export zum Lesen öffnen
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
open(FH, '<c:\ExportOtrsStammdaten.csv') || die "Datei wurde nicht gefunden\n";
my @Content =<FH>;
close(FH);
my $Zeile;
foreach $Zeile (@Content) { #bei diesem Aufruf steht jeweils des aktuelle Wert von Content in der skalaren Variable
#print "$Zeile";
($TicketNumber, $Year, $Month, $FiscalYear, $TicketTitle, $Category, $Problemtype, $Component,
$SLA, $EscalationLevel, $Status, $Priority, $Queue, $Customer, $CustomerUserID, $TicketOwner,
$DirectSolve, $Hostname, $Created, $Solved) = split(/;/,$Zeile);
#my $sql = "INSERT INTO tbl_bsp SET bsp_artID=$sorte, bsp_text=$bezeichnung";
my $SQL_Insert = "INSERT INTO TicketData (
TicketNumber,
Year,
Month,
FiscalYear,
Category,
Problemtype,
Component,
SLA,
EscalationLevel,
Status,
Priority,
Queue,
Customer,
CustomerUserID,
TicketOwner,
DirectSolve,
Hostname,
Created,
Solved
)
VALUES (
$TicketNumber,
$Year,
$Month,
$FiscalYear,
$Category,
$Problemtype,
$Component,
$SLA,
$EscalationLevel,
$Status,
$Priority,
$Queue,
$Customer,
$CustomerUserID,
$TicketOwner,
$DirectSolve,
$Hostname,
$Created,
$Solved
)";
my $Abfrage1 = $dbh->prepare($SQL_Insert);
$Abfrage1->execute();
}
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#Schließen der Datenbankverbindung
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if ($dbh) {
$dbh->disconnect();
#print "DB Verbindung geschlossen";
}
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
my $SQL_Insert = "INSERT INTO TicketData ( TicketNumber, Year, Month, FiscalYear, Category, Problemtype, Component, SLA, EscalationLevel, Status, Priority, Queue, Customer, CustomerUserID, TicketOwner, DirectSolve, Hostname, Created, Solved ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; my $Abfrage1 = $dbh->prepare($SQL_Insert); $Abfrage1->execute( $TicketNumber, $Year, $Month, $FiscalYear, $Category, $Problemtype, $Component, $SLA, $EscalationLevel, $Status, $Priority, $Queue, $Customer, $CustomerUserID, $TicketOwner, $DirectSolve, $Hostname, $Created, $Solved );
schiba82+2008-04-02 16:31:02--Vielen Dank für die schnellen Rückmeldungen.
Ich poste einmal meinen Code, aber wie gesagt ich bin noch Anfänger.
schiba82+2008-04-02 17:00:49--Vielen Dank für den Tipp mit den Platzhalter, aber wie kann ich das Thema mit dem Import der CSV Dateien lösen.
|< 1 2 >| | 11 Einträge, 2 Seiten |