Thread Daten vergleich in eine If Else Schleife: If Else Schleife (6 answers)
Opened by Gast at 2006-12-28 11:31

Gast Gast
 2006-12-28 11:31
#72780 #72780
Hallo Leute ,
Frohes Fest!

ich habe folgende code geschrieben um daten"RC_CISCO.ID" & GATE_STATE .Data_RefID meine Beide Tabelle RC_CISCO und GATE_STATE zu Vergleichen .

Code: (dl )
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
#!/usr/bin/perl -w
#DatenbankAbfragen

use strict;
use warnings;
use DBI;

use Digest::MD5;
my $dbh;
my $raw_data;
my $sqldata;
my $rc;

#####################################RC-CISCO LETZTEN STATUS ABFRAGEN ########################

sub Query{
my $query;
my $sth;
my $execu;
my $newdata;
my $file;
my $ds;
my @ergebnisse;
my @row;
my $sqlrecord;
my $db_id;
my $neid;
my $CISCOID;
my $datarefid;
my $sth1;
my $query1;
my $found;
my $th_dbh;



$query="SELECT * FROM (SELECT RC_CISCO.ID, RC_CISCO.NEID, GATE_STATE.NEID, GATE_STATE.AState, GATE_STATE.TS_LastChange, ".
"GATE_STATE.Data_RefID FROM (RC_CISCO LEFT JOIN GATE_STATE ON RC_CISCO.ID = GATE_STATE.Data_RefID) WHERE ( (GATE_STATE.NEID='$neid')) ORDER BY RC_CISCO.TS DESC) AS SUB1 GROUP BY SUB1.ID";


$sth = $dbh->prepare($query) or die "$DBI::errstr\n";
$ds = $sth->execute or die "$DBI::errstr\n";

while($newdata = $sth->fetchrow_hashref)
{



if (($newdata ->{ID}) eq ($newdata->{Data_RefID}))
{
#RC_CISCO DATEN VERGLEICHEN

if (($newdata->{ID} eq "RC_CISCO$_->{CISCOID}") && ($newdata->{NEID} eq "$_->{neid}")
{
print "$stext:RC_CISCO$_->{CISCOID} unverändert -> Updaten\n";

$query="UPDATE GATE_STATE SET TS_LastChange=NOW() WHERE Data_RefID='$newdata->{ID}' ORDER BY TS_LastChange DESC LIMIT 1;
$sth1= $th_dbh->prepare($query) or die "$DBI::errstr\n";

$ds = $sth1->execute or die "$DBI::errstr\n";
$sth1->finish();


}
}
else

{

print "$stext:Unterschiedliche RC_CISCO Daten für RC_CISCO$_->{CISCOID}...\n";
# Updaten
if ($newdata->{ID} ne "RC_CISCO$_->{CISCOID}")
{
$query="UPDATE RC_CISCO SET ID='RC_CISCO$_->{CISCOID}' WHERE ID='$newdata->{ID}' LIMIT 1;";
$sth1 = $dbh->prepare($query) or die "$DBI::errstr\n";
$ds = $sth1->execute or die "$DBI::errstr\n";
$sth1->finish();
}
}

}
}
}


nun leidert bekomme ich folgende fehler!
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Scalar found where operator expected at ./test.pl line 74, near "$sth1= $th_dbh->prepare($query) or die "$DBI::errstr"
(Might be a runaway multi-line "" string starting on line 73)
(Missing operator before $DBI::errstr?)
Backslash found where operator expected at ./test.pl line 74, near "$DBI::errstr\"
(Missing operator before \?)
String found where operator expected at ./test.pl line 76, near "$ds = $sth1->execute or die ""
(Might be a runaway multi-line "" string starting on line 74)
(Missing semicolon on previous line?)
Scalar found where operator expected at ./test.pl line 76, near "$ds = $sth1->execute or die "$DBI::errstr"
(Missing operator before $DBI::errstr?)
Backslash found where operator expected at ./test.pl line 76, near "$DBI::errstr\"
(Missing operator before \?)
String found where operator expected at ./test.pl line 86, near "print ""
(Might be a runaway multi-line "" string starting on line 76)
(Missing semicolon on previous line?)
Scalar found where operator expected at ./test.pl line 86, near "print "$stext"
(Do you need to predeclare print?)
syntax error at ./test.pl line 70, near ")
{"
Global symbol "$stext" requires explicit package name at ./test.pl line 71.
syntax error at ./test.pl line 74, near "$sth1= $th_dbh->prepare($query) or die "$DBI::errstr"
Global symbol "$stext" requires explicit package name at ./test.pl line 86.
Unrecognized character \xFC at ./test.pl line 86.


kann mich jemand helfen!
danke

moderiert v. Relais: fehlerhafte Code-Tags korrigiert, fehlende hinzugefĆ¼gt.\n\n

<!--EDIT|Relais|1167301116-->

View full thread Daten vergleich in eine If Else Schleife: If Else Schleife