PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: John Gilmore-Baldwin <john at dwx dot com>
Subject: error handlers
Date: Jun 1 1999 10:40PM

I'm having problems getting error handlers to work correctly.  If I don't
specify an error handler, the program works fine.  If I do, and the error
handler gets hit, my program dies immediately.

Sorry if it's boneheaded, but I don't see quite what I'm doing wrong.
Here's the pertinent code:

Sybase::DBlib::dberrhandle(\&SQLerrorHandler);

sub SQLerrorHandler
{
	my ($Database, $Severity, $Error, $OSerror, $ErrorMsg, $OSerrorMsg)
= @_;
	# Check the error code to see if we should report this.
	if ($error != SYBESMSG)
	{
		print STDERR ("Sybase error: ", $error_msg, "\n");
		print STDERR ("OS Error: ", $os_error_msg, "\n") if defined
($os_error_msg);
	}
	print LOGFILE ("Sybase error: ", $error_msg, "\n");
	$SQLerror = "Database: $Database\nError: $Error\nMessage:
$ErrorMsg\nSeverity: $Severity\n" .
				"OS Error: $OSerror\nOS Error Message:
$OSerrorMsg\n";
	print LOGFILE "$SQLerror\n";
	#print LOGFILE "$sqlstatement\n";
    ($todaysec, $todaymin, $todayhour, $todaymday, $todaymon, $todayyear,
			$todaywday, $todayyday, $todayisdst) = localtime(time);
	$todaydate = sprintf("%02d/%02d/%02d %02d:%02d:%02d",
						$todaymon + 1, $todaymday,
$todayyear,
						$todayhour, $todaymin,
$todaysec);
	print LOGFILE "$todaydate\n";
	print LOGFILE "----------------------------------------\n";
	&flush(LOGFILE);
	$errorRaised = 1;
	if ($doingNightly)
	{
		$doingNightly = 0;
		$doneNightly = 0;
	}

	INT_CANCEL;
}