freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Brian Bruns" <camber AT ais.org>
- To: freetds AT franklin.oit.unc.edu
- Subject: Re: Getting @@IDENTITY back from MSSQL
- Date: Fri, 9 Nov 2001 12:34:36 -0500
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
-
Getting @@IDENTITY back from MSSQL,
Scott Cain, 11/09/2001
- <Possible follow-up(s)>
- Re: Getting @@IDENTITY back from MSSQL, Michael Peppler, 11/09/2001
- Re: Getting @@IDENTITY back from MSSQL, Brian Bruns, 11/09/2001
- Re: Getting @@IDENTITY back from MSSQL, Scott Cain, 11/09/2001
- Re: Getting @@IDENTITY back from MSSQL, Brian Bruns, 11/09/2001
- Re: Getting @@IDENTITY back from MSSQL, Scott Cain, 11/09/2001
- Re: Getting @@IDENTITY back from MSSQL, Scott Cain, 11/12/2001
Archive powered by MHonArc 2.6.24.