dbTalk Databases Forums  

Sybase::DBlib error handling

comp.databases.sybase comp.databases.sybase


Discuss Sybase::DBlib error handling in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Green Dolphin
 
Posts: n/a

Default Sybase::DBlib error handling - 02-04-2004 , 06:47 AM






Hi all,

I am using the following codes to initiate a Sybase connection.

$dbh = new Sybase:Blib ($userid,$password,$server)
if (!$dbh)
{
print 'Connection failed';
exit(0);
}

What can I do if I want to identify what error has occured? Is that
caused by wrong server / wrong userid / wrong password?

Please help.
Thanks a lot for your advice.

Reply With Quote
  #2  
Old   
Sybaseneal
 
Posts: n/a

Default Re: Sybase::DBlib error handling - 02-04-2004 , 12:47 PM






Hello,

You would need to install error and message handlers:
$old_handler = dberrhandle($err_handle)
$old_handler = dbmsghandle($msg_handle)
Register an error (or message) handler for DB-Library to use. Handler examples can be found in sybutil.pl in the Sybperl
distribution. Returns a reference to the previously defined handler (or undef if none were defined). Passing undef as the argument
clears the handler.

The DB-Library Reference Manual has details:
http://sybooks.sybase.com/onlinebook...eric__BookView

Green Dolphin wrote:
Quote:
Hi all,

I am using the following codes to initiate a Sybase connection.

$dbh = new Sybase:Blib ($userid,$password,$server)
if (!$dbh)
{
print 'Connection failed';
exit(0);
}

What can I do if I want to identify what error has occured? Is that
caused by wrong server / wrong userid / wrong password?

Please help.
Thanks a lot for your advice.


Reply With Quote
  #3  
Old   
Ed Avis
 
Posts: n/a

Default Re: Sybase::DBlib error handling - 02-06-2004 , 03:22 PM



ssss (AT) hutchcity (DOT) com (Green Dolphin) writes:

Quote:
I am using the following codes to initiate a Sybase connection.

$dbh = new Sybase:Blib ($userid,$password,$server)
if (!$dbh)
{
print 'Connection failed';
exit(0);
}

What can I do if I want to identify what error has occured?
Unless you have a particular need to use dblib, you'd be better off
using DBI and the DBD::Sybase driver. With DBI you can set the
RaiseError flag so that every database error will be translated into
an exception.

--
Ed Avis <ed (AT) membled (DOT) com>


Reply With Quote
  #4  
Old   
Rene van Leeuwen
 
Posts: n/a

Default Re: Sybase::DBlib error handling - 02-09-2004 , 05:57 PM



In article <l1d68rkimq.fsf (AT) budvar (DOT) future-i.net>, Ed Avis wrote:
Quote:
ssss (AT) hutchcity (DOT) com (Green Dolphin) writes:

I am using the following codes to initiate a Sybase connection.

$dbh = new Sybase:Blib ($userid,$password,$server)
if (!$dbh)
{
print 'Connection failed';
exit(0);
}

What can I do if I want to identify what error has occured?

You should include an error-handler in your code,

See for an example of sub error_handler {} in sybutil.pl in your sybperl
source

--
___ _
Quote:
_ \___ _ _ ___//
/ -_) ' \/ -_)
_|_\___|_||_\___|

Reply With Quote
  #5  
Old   
Green Dolphin
 
Posts: n/a

Default Re: Sybase::DBlib error handling - 02-10-2004 , 06:45 AM



Thanks for your help.

May I ask why error handler have to go with message handler?


Sybaseneal <user (AT) invalid (DOT) domain> wrote

Quote:
Hello,

You would need to install error and message handlers:
$old_handler = dberrhandle($err_handle)
$old_handler = dbmsghandle($msg_handle)
Register an error (or message) handler for DB-Library to use. Handler examples can be found in sybutil.pl in the Sybperl
distribution. Returns a reference to the previously defined handler (or undef if none were defined). Passing undef as the argument
clears the handler.

The DB-Library Reference Manual has details:
http://sybooks.sybase.com/onlinebook...eric__BookView

Green Dolphin wrote:
Hi all,

I am using the following codes to initiate a Sybase connection.

$dbh = new Sybase:Blib ($userid,$password,$server)
if (!$dbh)
{
print 'Connection failed';
exit(0);
}

What can I do if I want to identify what error has occured? Is that
caused by wrong server / wrong userid / wrong password?

Please help.
Thanks a lot for your advice.

Reply With Quote
  #6  
Old   
Michael Peppler
 
Posts: n/a

Default Re: Sybase::DBlib error handling - 02-10-2004 , 09:14 AM



On Tue, 10 Feb 2004 04:45:20 -0800, Green Dolphin wrote:

Quote:
Thanks for your help.

May I ask why error handler have to go with message handler?
In DBlibrary, the "error" handler handles any errors that occur in the
client library itself (i.e. DBlibrary interenal errors), and the "message"
handler handles any errors/messages that are returned from the server.

Michael

Quote:

Sybaseneal <user (AT) invalid (DOT) domain> wrote

Hello,

You would need to install error and message handlers:
$old_handler = dberrhandle($err_handle)
$old_handler = dbmsghandle($msg_handle)
Register an error (or message) handler for DB-Library to use. Handler examples can be found in sybutil.pl in the Sybperl
distribution. Returns a reference to the previously defined handler (or undef if none were defined). Passing undef as the argument
clears the handler.

The DB-Library Reference Manual has details:
http://sybooks.sybase.com/onlinebook...eric__BookView

Green Dolphin wrote:
Hi all,

I am using the following codes to initiate a Sybase connection.

$dbh = new Sybase:Blib ($userid,$password,$server)
if (!$dbh)
{
print 'Connection failed';
exit(0);
}

What can I do if I want to identify what error has occured? Is that
caused by wrong server / wrong userid / wrong password?

Please help.
Thanks a lot for your advice.
--
Michael Peppler Data Migrations, Inc.
mpeppler (AT) peppler (DOT) org http://www.mbay.net/~mpeppler
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.mbay.net/~mpeppler/resume.html



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.