#! perl use Sybase::Sybperl; use Sybase::DBlib; dbmsghandle ("message_handler"); dberrhandle ("error_handler"); my $user= ""; my $pass= ""; my $server= ""; my $db = ""; my $dbh = 0; my @data; my @rueck; my $status = ""; my $sql = " Select * from Test "; open(LOGG,">>x.test"); print LOGG "\n  LOGG".log_time()."opend"; $dbh = new Sybase::DBlib $user,$pass; print LOGG "\n  LOGG".log_time()."Connected"; $dbh->dbuse($db); print LOGG "\n  LOGG".log_time()."DB changed"; $status = $dbh->dbcmd($sql); print LOGG "\n  LOGG".log_time()."sql"; $status = $dbh->dbsqlexec; print LOGG "\n  LOGG".log_time()."executed"; $status=$dbh->dbresults; print LOGG "\n  LOGG".log_time()."results"; while(@data = $dbh->dbnextrow) {   if(@rueck==0)   { @rueck=[@data];   }   else   {   push(@rueck,[@data]);   } } $sql = "select * from tet"; $status = $dbh->dbcmd($sql); print LOGG "\n  LOGG".log_time()."sql"; $status = $dbh->dbsqlexec; print LOGG "\n  LOGG".log_time()."executed"; $status=$dbh->dbresults; print LOGG "\n  LOGG".log_time()."results"; $dbh->dbclose; print LOGG "\n  LOGG".log_time()."DB closed"; foreach  (@rueck) { print "\n ". $_; } close(LOGG); #============================================================= #============================================================= # Sybperl Error-Handling #============================================================= sub message_handler { my ($db, $message, $state, $severity, $text, $server, $procedure,$line) = @_; if ($severity > 10)  {   print LOGG "\n !FAIL".log_time()."Sybase message ". $message .", Severity ". $severity .", state ". $state;   print LOGG "\n !FAIL".log_time()."Server `". $server. "'" if defined ($server);   print LOGG "\n !FAIL".log_time()."Procedure `". $procedure. "'" if defined ($procedure);   print LOGG "\n !FAIL".log_time()."Line ". $line if defined ($line);   print LOGG "\n !FAIL".log_time().$text. "\n\n"; # &dbstrcpy returns the command buffer.   if(defined($db))   {    my ($lineno, $cmdbuff) = (1, undef);    my $row;    $cmdbuff = &Sybase::DBlib::dbstrcpy($db);          foreach $row (split (/\n/, $cmdbuff))    {     print LOGG "\n !FAIL".log_time(). sprintf ("%5d", $lineno ++). "> ". $row, "\n";    }   }  }  elsif ($message == 0)  {   print LOGG "\n !FAIL".log_time(). $text;  }      return 1; } sub error_handler { my ($db, $severity, $error, $os_error, $error_msg, $os_error_msg)= @_; # Check the error code to see if we should report this. if ($error != SYBESMSG) { print LOGG "\n !FAIL".log_time()."Sybase error: ", $error_msg;  print LOGG "\n !FAIL".log_time()."OS Error: ", $os_error_msg if defined ($os_error_msg);       }     return 0; }