Skip to Content.
Sympa Menu

freetds - Re: Getting @@IDENTITY back from MSSQL

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Scott Cain <scain AT athersys.com>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: Getting @@IDENTITY back from MSSQL
  • Date: Fri, 09 Nov 2001 16:06:07 -0500


Brian,

It appears that it is a truncation problem. I ran with DBI->trace(3) on, and
the
value there was truncated as well.

Unfortunately, when I tried to install 0.53pre1, it appeared to go smoothly,
but now I
am getting "connect: Network unreachable" from DBI. I am using an interface
file in
/usr/local/freetds that is identical to the interface file that used to be
there.
Also, if it matters, I upgraded DBI to 1.20 (thinking that may be the source
of the
problem); no luck.

Any suggestions?

Scott

Brian Bruns wrote:

> Hi,
>
> I thought we had squished all the truncation bugs, can you try 0.53pre1
> (or CVS) and let me know if it shows up there as well?
>
> Brian
>
> > Hello,
> >
> > I am writing Perl (5.6.1) on a linux box (RH 7.1) with FreeTDS (0.51) and
> > DBI (1.19) to talk to a MSSQL server on a win2000 box. I want to get
> > @@IDENTITY from the last insert I made (@@IDENTITY contains that value of
> > the last autoincrement on a primary key).
> >
> > Here is test code I created:
> >
> > #!/usr/local/bin/perl -w
> > use DBI;
> > use strict;
> >
> > $ENV{'SYBASE'} = '/usr/local/freetds';
> > $ENV{'TDSVER'} = 70;
> >
> > my $server = "server";
> > my $db = "db";
> > my $user = "sqluser";
> > my $passwd = "sqluserpasswd";
> >
> > my $dbh =
> > DBI->connect("dbi:Sybase:server=$server;database=$db",$user,$passwd)
> > or die "--$!--\n";
> >
> > my $sth = $dbh->prepare(' insert into sctemp (scratch) values (42)
> > select @@IDENTITY as foo');
> > $sth->execute;
> >
> > my $data = $sth->fetchrow_hashref;
> > my $seqid= $$data{foo};
> > my $err = $sth->errstr;
> > print "$seqid, $err\n";
> >
> > The problem I have is that $seqid seems to be getting truncated, ie, the
> > value of @@IDENTITY is about 20, but the value of $seqid that gets printed
> > out is 2. The query works fine as written in the Query Analyzer on
> > Windows. At this point, it feels like a problem with FreeTDS. In
> > addition to fetchrow_hashref, I tried fetch and fetchrow_array. Any
> > ideas?
> >
> > Thanks,
> > Scott
>
> ---
> You are currently subscribed to freetds as: [scain AT athersys.com]
> To unsubscribe, forward this message to $subst('Email.Unsub')

--
_____________________________________________________________
This message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is
prohibited. If you are not the intended recipient, please
contact the sender by reply e-mail and destroy all copies of
the original message.
_____________________________________________________________
Scott Cain, Ph. D. Ph :(216) 431-9900
Bioinformatics Specialist Fax:(216) 361-9596
Athersys, Inc.
3201 Carnegie Avenue
Cleveland, OH 44115-2634
_____________________________________________________________






Archive powered by MHonArc 2.6.24.

Top of Page