sub Select_Qry{ ($class,$dbaseh,$query)=@_; my($sth, $execu); if(!defined($query)){ $sth->finish(); $dbaseh->disconnect(); } if($dbaseh->ping){ $sth=$dbaseh->prepare("$query") or warn $file->log( level => 'info', message => localtime() .": Can't prepare SQL statement:[$query] $DBI::errstr\n"); #Prepare the select query $execu =$sth->execute() or warn $file->log( level => 'info', message => localtime() .": Can't execute SQL statement:[$query] $DBI::errstr\n"); #Execute the select query if(!defined($execu)){ $file->log( level => 'info', message => localtime() .": Can't execute SQL statement:[$query] $DBI::errstr\n"); } else{ $file->log( level => 'info', message => localtime() .":SUCCESS:[$query]\n"); } while ( @arra = $sth->fetchrow_array ) { push (@Data_Array,@arra); } $file->log( level => 'info', message => localtime() .": Fetched Data [@Data_Array]\n"); } else{ $file->log( level => 'info', message => localtime() .": Reconnecting with Database by Ping function\n"); $dbaseh=&connection(); $file->log( level => 'info', message => localtime() .": DataBase Get Connected Successfully.\n" ); $sth=$dbaseh->prepare("$query") or warn $file->log( level => 'info', message => localtime() .": Can't prepare SQL statement: $DBI::errstr[$query]\n"); #prepare the select query $execu=$sth->execute() or warn $file->log( level => 'info', message => localtime() .": Can't execute SQL statement: $DBI::errstr[$query]\n"); #execute the select query if(!defined($execu)){ $file->log( level => 'info', message => localtime() .": Can't execute SQL statement:[$query] $DBI::errstr\n"); } else{ $file->log( level => 'info', message => localtime() .":SUCCESS:[$query]\n"); } while ( @arra = $sth->fetchrow_array ) { push (@Data_Array,@arra); } $file->log( level => 'info', message => localtime() .": Fetched Data [@Data_Array]\n"); } $sth->finish(); $dbaseh->disconnect(); #Disconnect the database. return @Data_Array; }