Re: Probably Trivial: Finding Largest Primary Key used in Table
Michael Peppler <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.dbi.sybase |
|---|---|
| Message-ID | <[email protected]> |
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 > TABLE_NAME" 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 -- Michael Peppler - [email protected] - http://www.peppler.org/ Sybase DBA/Developer Sybase on Linux FAQ: http://www.peppler.org/FAQ/linux.html