|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: sybase global variables
Date: Sep 20 2000 4:45PM
Matthew E Studley writes:
> Hi - me again
>
> Trying to get the value of the IDENTITY column on a table in which I've
> just inserted. doing 'SELECT @@IDENTITY'.... seem to get back
>
> {
> 'COL(1)' => '0'
> };
>
Dunno, unless you're doing the select on a different connection for
some reason...
Here's a script that works:
create table testident (id numeric(5,0) identity, val varchar(25))
#!/usr/local/bin/perl -w
use strict;
use Sybase::CTlib;
my $dbh = new Sybase::CTlib 'sa', '', 'SYBASE';
$dbh->ct_sql("use testdb");
$dbh->ct_sql("insert testident(val) values('test #1')");
my $d = $dbh->ct_sql("select \@\@identity");
print "$d->[0]->[0]\n";
__END__
prints 1, 2, 3 etc... after each insert....
Michael
--
Michael Peppler -||- Data Migrations Inc.
mpeppler@peppler.org -||- http://www.mbay.net/~mpeppler
Int. Sybase User Group -||- http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com
|