Title says it all but this what I have determined...

I have DBD::Sybase built on a RedHat 7.2 w/ FreeTDS and it is working to 
a MSSQL server 7.0 and 2000...

Heres the issue...

If the database server has multiple databases with the same user account 
with access the database that connects is always the users default 
database...

Example...

USER:
my_user w/ access to all four my_databaseX but 'my_database1' is default

CONNECTING TO:
my_database1 w/ my_user connects to my_database1 (DEFAULT SCENARIO)
my_database2 w/ my_user connects to my_database1
my_database3 w/ my_user connects to my_database1
my_database4 w/ my_user connects to my_database1

All of these examples produce the following error message but the script 
connects and returns data but from the default database in all instances.

[bmcclint@BM0054 perl]$ ./mssql.pl
[Thu Mar 21 17:30:49 2002] mssql.pl: DBD::Sybase - can't change context 
to database my_database2

In the scenario with one user to a database there is not error and 
script functions normally.

SO WHAT I HAVE DETERMINED:
I am guessing that the username is not getting processed correct by the 
Sybase driver.  Reason I say this is the same script run on a Win32 
platform with DBD::ODBC correctly determines what database to pull data. 
  Basically whats going on is I have and application with other 
historical version of the database on line at the same time.  My 
temporary solution was to create my_userX accounts that default to the 
appropriate database.

Has anyone experienced this?
Thanks in advance...


SCRIPT USED BELOW:
#!/usr/bin/perl -w
$|=1;
#------------------------------------------------------------------------------
use strict;
use DBI;
#-------------------------------------------------------------------------------
my $host     = "my.server.domain";
my $database = "my_database";
my $username = "my_user";
my $password = "my_passwd";
#-------------------------------------------------------------------------------
my $dbh = DBI->connect("dbi:Sybase:server=$host;database=$database",
                        $username, $password) or die DBI->errstr;

my $statement = "select id from my_table";
my $sth = $dbh->prepare($statement) or die DBI->errstr();
    $sth->execute() or die DBI->errstr;

while(my $row = $sth->fetchrow_hashref()) {
   foreach my $key (sort keys %{$row}) {
     if(!defined(${$row}{$key})) { ${$row}{$key} = ''; }
     print "$key = ${$row}{$key}\n";
   }
}

$sth->finish() or die DBI->errstr();
$dbh->disconnect() or die DBI->errstr();

exit;



-- 
Bill McClintock - EDMS App/Web Development
    MCIWorldcom - Colorado Springs (GOG)
    VNet:622-0054   Local:(719)265-0054
      Pager:1-800-PAGEMCI PIN#1686599
      EMail:[EMAIL PROTECTED]
               AOLIM:bm0054


Reply via email to