Skip to Content.
Sympa Menu

freetds - RE: [freetds] Need help with SQL server stored procedure output?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: 'FreeTDS Development Group' <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] Need help with SQL server stored procedure output?
  • Date: Fri, 18 Jul 2003 15:46:34 -0400

> From: Gaurav Nangia [mailto:gnangia AT mspintl.com]
> Sent: July 18, 2003 12:04 PM
>
> I am using freetds 0.61 with DBD::Sybase on Redhat linux to
> connect to SQL Server 7.0.
...
> I am having an issue with
> running a stored procedure that RETURNS A VALUE. How do I
> retrieve that value.
...
> #!/usr/bin/perl
>
> use DBI;
> $dbh = DBI->connect('DBI:Sybase:server=DEV;', $user, $passwd)
> or die "Cannot
> connect:$@\n";
> $sql = ("declare \@test numeric(9,4) exec TEST
> \@results=\@test OUTPUT");
> $sth=$dbh->prepare($sql);
> $sth->execute;
> while(@d = $sth->fetchrow_array)
> {
> foreach $xyz(@d)
> {
> print "REsult=>$xyz<=\n";
> }
> }

DBD::Sybase returns the procedure's return code as a row, setting a
statement handle attribute to denote the row's type. Your loop isn't enough
afaik; cf. "perldoc DBD::Sybase" for more. I think you need loop more like:

do {
while($d = $sth->fetch) {
print @{$d}, $/;
}
} while($sth->{syb_more_results});

However, FreeTDS 0.61 appears broken wrt this feature in our ct-lib. I just
finished testing the above, and got these errors:

1. I got syb_result_type=4043, but no data.
2. $sth->{syb_more_results} always returns 1.
3. $sth->{syb_result_type} returns -1077946652 past the "end of the data".

The good news is that current CVS (and recent snapshots) work correctly.

I had to rebuild DBD::Sybase to make it link to /usr/local/lib/libct.so.1.
If you're already using libct.so.1, then you need to update just FreeTDS.
If you do have to rebuild DBD::Sybase, it might complain about lacking
tdsiconv.h, which we don't install even though we should. I'm going to look
at the issue more closely this weekend, to see what we really should do, and
if tdsiconv.h is serving a real purpose.

--jkl
-----------------------------------------
The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above. If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the original
message. Please note that we do not accept account orders and/or instructions
by e-mail, and therefore will not be responsible for carrying out such orders
and/or instructions.






Archive powered by MHonArc 2.6.24.

Top of Page