!/usr/bin/perl -w #Hauptscript use strict; use warnings; use DBI; my $dbh; my $raw_data; my $sqldata; my $rc; open(DAT, '<','../gate_common/MySQLAccount.txt') or die"Could not open SQL-Data-file!"; $raw_data=; close(DAT); chomp $raw_data; my ($host,$user,$pass,$db) = split(/:/, $raw_data); print "host ".$host."\n"."user ".$user."\n"."pass ".$pass."\n"."db ".$db."\n"; $dbh = DBI->connect("DBI:mysql:".$db.":".$host,$user,$pass) or die "Connect Error: $DBI::errstr()\n"; Query($dbh); $dbh->disconnect; sub Query{ my $query; my $sth; my $execu; my $newdata; my $NEID = 2923; my $ds; my @ergebnisse; my @row; my $Datum1; my$Datum2; my$query1; my$query2; ################RC-CISCO LETZTEN STATUS ABFRAGEN ######################################################## $query = "SELECT * FROM RC_CISCO LEFT JOIN GATE_STATE ON RC_CISCO.NEID=GATE_STATE.NEID WHERE RC_CISCO.ID=? ORDER BY RC_CISCO.ID DESC LIMIT 1"; $sth = $dbh->prepare($query) or die "$DBI::errstr\n"; $sth->execute($NEID)or die "$DBI::errstr\n"; while($newdata = $sth->fetchrow_array()){ if(not defined $newdata){ $dbh->do("INSERT INTO RC_CISCO(ID) VALUES(?)",undef,$NEID) or die $dbh->errstr(); $dbh->do("INSERT INTO GATE_STATE(Data_RefID) VALUES(?)",undef,$NEID) or die $dbh->errstr(); } $query1="SELECT RC_CISCO.Datum FROM RC_CISCO"; $query2="SELECT GATE_STATE.Datum_ref FROM GATE_STATE"; my $Datum1=$query1; my $Datum2 = $query2; if($Datum1 =$Datum2){ print "gleich!\n!; } } while($newdata = $sth->fetchrow_hashref) { print " Name:$newdata->{NEID}}\n"; } $sth->finish(); } }