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 causes program failure (why?)
Date: Jan 6 1999 6:31PM

I have a Sybperl program that keeps dying.  When I check the log, I get this:

----------
Message: 540 Text: Schema for table 'story' has changed since compilation
of thi
s query.  Please re-execute query.

Sybase error:
Database: HASH(0xce3a0)
Error: 20018
Message: General SQL Server error: Check messages from the SQL Server.
Severity: 5
OS Error: -1
OS Error Message:


01/06/99
----------

I have error and message handlers in the program (the error handler is the
one getting called).  So, am I doing something wrong in the implementation
of this?  Here's the code:

sub SQLmessageHandler
{
	my ($Database, $Message, $State, $Severity, $Text, $Server,
		$Procedure, $Line) = @_;

	# Ignore informational messages (serverity = 1). To display
informational
	# messages, change the 1 to 0.
	#
	if ($Severity > 1)
	{
		print LOGFILE "Message: $Message Text: $Text\n";
		$SQLerror = "Database: $Database\nMessage: $Message\nState:
$State\nSeverity: $Severity\n" .
					"Text: $Text\nServer:
$Server\nProcedure: $Procedure\nLine: $Line\n";
		$errorRaised = 1;
		if ($doingNightly)
		{
			$doingNightly = 0;
			$doneNightly = 0;
		}
		print LOGFILE "$sqlstatement\n";

		INT_CONTINUE;
	}
}

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", $todaymon + 1, $todaymday,
$todayyear);
	print LOGFILE "$todaydate\n";
	&flush(LOGFILE);
	$errorRaised = 1;
	if ($doingNightly)
	{
		$doingNightly = 0;
		$doneNightly = 0;
	}

	INT_CONTINUE;
}

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