Subject: | Identity Column identification issue w/ ASE 15.0+ |
Sybase ASE 15.0 changed the output of sp_help and inserted a column
before the Identity column in the output. If the code in set_up_table
is patched per below, this should work for all versions of ASE.
--- orig/Class/DBI/Sybase.pm 2006-09-14 07:55:22.000000000 -0500
+++ new/Class/DBI/Sybase.pm 2010-09-24 14:47:07.002848000 -0500
@@ -94,15 +94,11 @@
$class->columns( TEXT => map { $_->[5] eq 'text' ? $_->[3] : () }
@$col );
# now find the IDENTITY column
- $sth = $dbh->prepare("sp_help $table");
- $sth->execute();
+ $sth = $dbh->prepare("select name from syscolumns where 1=1 AND
status & 128 = 128 AND object_name(id) =?");
+ $sth->execute($table);
- # the first two resultsets contain no info about finding the
identity column
- $sth->fetchall_arrayref() for 1 .. 2;
$col = $sth->fetchall_arrayref();
-
- my ($identity) = grep( $_->[9] == 1, @$col ); # the 10th column
contains a boolean denoting whether it's an IDENTITY
- $class->columns( IDENTITY => $identity->[0] ) if $identity; #
store the IDENTITY column
+ $class->columns( IDENTITY => $col->[0][0] ) if $col->[0]; #
store the IDENTITY column
}
# Fixes a DBD::Sybase problem where the handle is still active.