-1

I have to switch my webserver (internal use only) to a more recent version and so I have also new perl and new DBD:Sybase instead of DBD:ASAny I used before.

I use statements with bind variables regulary, they worked fine, but with DBD:Sybase I get the following error:

AH01215: DBD::Sybase::st execute failed: Server >message number=12006 severity=16 state=0 line=0 text=SQL Anywhere-Fehler >-110: Element 'DBD1' ist bereits vorhanden

The versions:

New: DBD::Sybase

/usr/local/lib/x86_64-linux-gnu/perl/5.22.1/DBD/Sybase.pm Installed: 1.15

Old: DBD::ASAny

DBD::ASAny version 1.14.

#!/usr/bin/perl 

use DBI;
print "Content-type: text/html\n\n";

$dbh = DBI->connect( "DBI:Sybase:server=tl", 'xxx', 'yyy', {PrintError => 1, AutoCommit => 0} ) or die "Connection failed\n    Connection string: $connstr\n    Error message    : $DBI::errstr\n";

$dbh2 = DBI->connect( "DBI:Sybase:server=tl", 'xxx', 'yyy', {PrintError => 1, AutoCommit => 0} ) or die "Connection failed\n    Connection string: $connstr\n    Error message    : $DBI::errstr\n";

$select="select artnr, bez1, bez2 from art where artnr like 'F%12%.00'";
$sth_t=$dbh->prepare($select);
$sth_t->execute();

$select="select lager_nr, bestand from bestand where art_nr = ? and coalesce(bestand,0) > 0 ";
$sth_lager=$dbh2->prepare($select)  or die "Prep sthlager nix:".$dbh2->errstr()."\n";

while ( ($artnr, $gtnr, $bez)=$sth_t->fetchrow())
{
    print $artnr."; ".$gtnr."; ".$bez;
    $sth_lager->execute($artnr)   or die "exec sthlager nix:".$dbh2->errstr()."\n";
    while ( ($lager,$bestand) = $sth_lager->fetchrow())
    {
        print $lager." : ".$bestand." || ";
    }
    $sth_lager->finish();
    print "\n<br>";
}

The offending line is "$sth_lager->execute($artnr)"

  • The error messages are in German? Are those from the driver? – simbabque May 22 '17 at 13:06
  • If you know which modules work for you, is there any reason you can't install exactly those versions of the modules directly? If they are not on CPAN, they are probably on BackPAN so you should be able to get them, and then install them using local::lib. – simbabque May 22 '17 at 13:07
  • 2
    "Element 'DBD1' ist bereits vorhanden" Are you sure that error comes from the code you've shown us? The error means "Element 'DBD1' already exists" and in generated when you try to insert a row which violates a unique index on the table. Which seems unlikely to be generated by a select statement. – Dave Cross May 22 '17 at 14:06
  • I am not saying this is a problem, but I do not like the method used to prepare>execute. Can you try `my $select = $dbh->prepare("select artnr, bez1, bez2 from art where artnr like 'F%12%.00'"); $select->execute || die "failed to execute";` also switch on `use strict;` `use warnings;` I also fully agree with @DaveCross. It seems that your error is telling you it is trying to create something which cannot be true if you are using select statements. – Gerhard May 22 '17 at 14:21
  • Sorry: the error message is in my apache2/error.log. @simbabque: as I understood DBD:ASAny is deprecated, and as it always was a drag to install, I was glad having something else. – Martin Schmidt May 23 '17 at 06:39
  • @Gerhard: yes there are they fine and right things, but this is just a test for provoking the error. – Martin Schmidt May 23 '17 at 06:39
  • @Dave: I only do a select, but the error comes every time when I do a execute with bind variables within an other loop of fetchrow. As I understood there is a stored procedure created when you do a prepare with bind variables, so maybe there is something with that. I do not know where 'DBD1' comes from. – Martin Schmidt May 23 '17 at 06:40
  • Well the question you need to ask yourself is, do you need this to work, or do you have time to play around? Even if it's a drag to install, I'd install it first to get it up and running, then bother about refactoring it with a different driver. – simbabque May 23 '17 at 06:43
  • @simbabque: I do have the time, the old installation (lenny) is running, I have a new server installed ( stretch ) and I'm just starting to move my programs. – Martin Schmidt May 23 '17 at 07:01
  • I see. Has the version of the database changed? Can you get a change log. (I've never used Sybase, so I'm poking around). – simbabque May 23 '17 at 07:06
  • No the sybase anywhere is running on different host, there has been no change in the last few years (ASA 12) – Martin Schmidt May 23 '17 at 07:48

1 Answers1

0

Thanks to You all, especially simbabque, he was on the right track. The answer is simple:
DBD::ASAny was written to handle SQL Anywhere, whereas DBD::Sybase is for Sybase Adaptive Server Enterprise, and these two systems are actually quite different.
I used the wrong tool. Mist.