Up Prev Next
From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: Probably Trivial: Finding Largest Primary Key used in Table
Date: Jul 10 2005 12:17PM
On Sat, 2005-07-09 at 23:27 +0700, Jay Listo wrote:
> BTW, how do I do this in Perl using DBI and DBD::Sybase
> I tried...
> my $maxsth = $dbh->primary_key_info(undef, $dbuser, 'TABLE_NAME');
> die "Unable to prepare SELECT MAX Key statement $DBI::errstr"
> unless $maxsth;
> $getMaxKey = $maxsth->fetchall_arrayref
> || die "Couldn't get the MAX KEY $DBI::errstr";
> ....but $getMaxKey is not yet the value from "select max(keycol) from
primary_key_info() will give you the PK column(s) (IIRC). It doesn't
give you the current highest value.
You need to take the data returned here and build the appropriate select
statement to get the data you're looking for.
Michael Peppler - email@example.com - http://www.peppler.org/
Sybase on Linux FAQ: http://www.peppler.org/FAQ/linux.html