in reply to Re: Re: SQL Stored Procedure return value
in thread SQL Stored Procedure return value

Hi Michael,
Thanks for writing but I get the following error when I run the above code DBD::Sybase::st execute failed: Server message number=156 severity=15 state=1 line=1 server=WIN-SVR2text=Incorrect syntax near the keyword 'select'. at ./syb.pl line 52.. Here is the code -
#$sth = $dbh->prepare("declare \@ret numeric exec TEST \@results=@ret +select @ret"); $sth = $dbh->prepare("declare \@ret numeric(9,4) exec TEST \@results= +@ret select @ret"); $sth->execute; do { while($d = $sth->fetch) { print "@$d\n"; } } while($sth->{syb_more_results});
It complains with the sql statement essentially. I have also tried escaping all the @ signs, it runs but always returns a value of 0.($sth = $dbh->prepare("declare \@ret numeric(9,4) exec TEST \@results=\@ret select \@ret");) Please advise.

Replies are listed 'Best First'.
Re: Re: SQL Stored Procedure return value
by mpeppler (Vicar) on Jul 17, 2003 at 20:25 UTC
    I'm uncertain how FreeTDS handles this, but the following should work:
    $sth = $dbh->prepare(" declare \@ret numeric exec TEST \@results=@ret select @ret "); $sth->execute; do { while($d = $sth->fetch) { print "@$d\n"; } } while($sth->{syb_more_results});
    (with appropriate error handling, of course).

    Michael

      Michael, Which Sybase libraries/drivers do I need to download to get DBD::Sybase to work with?
      Thank-you
        Hmmm - that should be valid SQL syntax. I don't have FreeTDS or MS-SQL, but I just tried this with Sybase and it works correctly.

        Maybe you need to ask on the FreeTDS mailing list?

        Michael