How to connect to Sybase using Win32 Perl and DBD::Sybase. 
Author Message
 How to connect to Sybase using Win32 Perl and DBD::Sybase.

Hi all,

I'm now using Win32 (ActiveState) Perl and DBI.
I can connect to ODBC sources using the DBD::ODBC, but when I use DBD::Sybase
to connect to Sybase, it keeps saying "Error: Runtime exception".

I have installed the OpenClient for Windows and can use command line isql to
connect to Sybase databases, so I don't know which part goes wrong.

Anyway has succeeded to connect to Sybase using though Win32 Perl & DBI?
What's the 'tricks'?

Thanks in advance.



Sun, 26 Aug 2001 03:00:00 GMT  
 How to connect to Sybase using Win32 Perl and DBD::Sybase.

Quote:


> > I'm now using Win32 (ActiveState) Perl and DBI.
> > I can connect to ODBC sources using the DBD::ODBC, but when I use DBD::Sybase
> > to connect to Sybase, it keeps saying "Error: Runtime exception".

> > I have installed the OpenClient for Windows and can use command line isql to
> > connect to Sybase databases, so I don't know which part goes wrong.

> > Anyway has succeeded to connect to Sybase using though Win32 Perl & DBI?

> I ran into the same error you're getting until I reverted to an older version
> of the Open Client DLLs (10.04, I think). DBD::Sybase works fine with these,
> but not at all with the OpenClient that comes with Adaptive Server 11.1.

I *suspect* that I've found the problem. It seems I'm not declaring the
server and client callbacks as CS_PUBLIC.

Here is a patch that you may want to try:

*** /tmp/T0NvaOFj       Tue Mar 23 08:23:45 1999
--- dbdimp.c    Tue Mar 23 08:23:43 1999
***************
*** 31,42 ****
  static CS_RETCODE display_header _((imp_dbh_t *, CS_INT, CS_DATAFMT*));
  static CS_RETCODE describe _((imp_sth_t *, int));
  static CS_RETCODE fetch_data _((imp_dbh_t *, CS_COMMAND*));
! static CS_RETCODE clientmsg_cb _((CS_CONTEXT*, CS_CONNECTION*, CS_CLIENTMSG*));
! static CS_RETCODE servermsg_cb _((CS_CONTEXT*, CS_CONNECTION*, CS_SERVERMSG*));
  static CS_COMMAND *syb_alloc_cmd _((CS_CONNECTION*));
  static void dealloc_dynamic _((imp_sth_t *));
  static int map_types _((int));
  static CS_CONNECTION *syb_db_connect _((struct imp_dbh_st *));

  static CS_CONTEXT *context;
--- 31,43 ----
  static CS_RETCODE display_header _((imp_dbh_t *, CS_INT, CS_DATAFMT*));
  static CS_RETCODE describe _((imp_sth_t *, int));
  static CS_RETCODE fetch_data _((imp_dbh_t *, CS_COMMAND*));
! static CS_RETCODE CS_PUBLIC clientmsg_cb _((CS_CONTEXT*, CS_CONNECTION*, CS_CLIENTMSG*));
! static CS_RETCODE CS_PUBLIC servermsg_cb _((CS_CONTEXT*, CS_CONNECTION*, CS_SERVERMSG*));
  static CS_COMMAND *syb_alloc_cmd _((CS_CONNECTION*));
  static void dealloc_dynamic _((imp_sth_t *));
  static int map_types _((int));
  static CS_CONNECTION *syb_db_connect _((struct imp_dbh_st *));
+ static int syb_db_use _((imp_dbh_t *, CS_CONNECTION *));

  static CS_CONTEXT *context;
***************
*** 44,50 ****

  static imp_dbh_t *DBH;

! static CS_RETCODE
  clientmsg_cb(context, connection, errmsg)
  CS_CONTEXT    *context;
  CS_CONNECTION *connection;    
--- 45,51 ----

  static imp_dbh_t *DBH;

! static CS_RETCODE CS_PUBLIC
  clientmsg_cb(context, connection, errmsg)
  CS_CONTEXT    *context;
  CS_CONNECTION *connection;    
***************
*** 80,89 ****
      if(CS_NUMBER(errmsg->msgnumber) == 6) { /* disconnect */
        imp_dbh->isDead = 1;
      }
      return CS_SUCCEED;
  }

! static CS_RETCODE
  servermsg_cb(context, connection, srvmsg)
  CS_CONTEXT    *context;
  CS_CONNECTION *connection;
--- 81,106 ----
      if(CS_NUMBER(errmsg->msgnumber) == 6) { /* disconnect */
        imp_dbh->isDead = 1;
      }
+
+     /* If this is a timeout message, return CS_FAIL to cancel the
+        operation and (if we're lucky) mark the connection as dead.
+        After a timeout the connection should be considered unusable.
+        Note that returning CS_SUCCEED on timeout simply tells the
+        library to wait for another timeout period after which this
+        callback will probably be called again. */
+
+     if (CS_SEVERITY(errmsg->msgnumber) == CS_SV_RETRY_FAIL &&
+       CS_NUMBER(errmsg->msgnumber) == 63 &&
+       CS_ORIGIN(errmsg->msgnumber) == 2 &&
+       CS_LAYER(errmsg->msgnumber) == 1) {
+       imp_dbh->isDead = 1; /* XXX */
+       return CS_FAIL;
+     }
+
      return CS_SUCCEED;
  }

! static CS_RETCODE CS_PUBLIC
  servermsg_cb(context, connection, srvmsg)
  CS_CONTEXT    *context;
  CS_CONNECTION *connection;

Michael
--
Michael Peppler         -||-  Data Migrations Inc.

Int. Sybase User Group  -||-  http://www.isug.com



Mon, 10 Sep 2001 03:00:00 GMT  
 How to connect to Sybase using Win32 Perl and DBD::Sybase.

Quote:



> > I *suspect* that I've found the problem. It seems I'm not declaring the
> > server and client callbacks as CS_PUBLIC.

> That seems to do the trick; running the test suite against the patched version
> gave the following result:

> t\base..............ok t\login.............ok t\main..............Use of
> uninitialized value at t\main.t line 97. FAILED test 8  Failed 1/12 tests,
> 91.67% okay t\place.............ok Failed Test  Status Wstat Total Fail
> Failed  List of failed
> -----------------------------------------------------------------------------
> -- t\main.t  12  1  8.33%  8 Failed 1/4 test scripts, 75.00% okay. 1/31
> subtests failed, 96.77% okay.

> How serious is this failure? He's looking for, and not finding, a DBI::err of
> 208 after executing a SELECT that should fail.

That's probably not very serious. I suggest that you try some scripts in your
environment, with appropriate error checking to satisfy yourself that this
works correctly.

Michael
--
Michael Peppler         -||-  Data Migrations Inc.

Int. Sybase User Group  -||-  http://www.isug.com



Tue, 11 Sep 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Cannot connect using DBD::Sybase

2. Cannot connect using DBD::Sybase

3. How Do I build and Install DBD:Sybase 0.91 on NT usinf Sybase Open Client 12.0

4. DBI::DBD::Sybase not trapping Sybase error codes and messages

5. DBD::Sybase 0.91, Sybase Openclient, and RH 7.3

6. DBD::SYBASE What ways to access error messages from Sybase DB

7. DBI/DBD::Sybase connect problem

8. Connecting to Sybase using Perl DBI

9. DBD::Oracle/Sybase on Win32

10. ActivePerl Win32 PPM and DBD-Sybase package

11. DBD::Sybase under win32

12. DBD::Sybase, Using Stored Procs with output vars

 

 
Powered by phpBB® Forum Software