DBD::ODBC extended error information



How do I get the extended error information utilizing DBD::ODBC?

MSSQL seems to return several levels of error information, however the
$DBI::errstr only contains the first one.

I am using Perl 5.8.0 on windows with DBI and DBD::ODBC. I have a high
thruput script that I am trying to utilize the odbc_exec_direct
attribute for.

I prepare and exec raw SQL like so:

my $statementHandle = $gDBConn->prepare($sql);

if(not ($statementHandle->execute()))
{
$error = $DBI::errstr;

When I turn on the odbc_exec_direct attr, any statement that fails (and
previously would return the appropriate error message) now returns:
[Microsoft][ODBC SQL Server Driver]Associated statement is not prepared
(SQL-HY007)(DBD: dbd_describe/SQLNumResultCols err=-1)

I believe that the error information that I need is the next one
returned (i.e., SQL-23000, cannot insert dupe row), however I have not
found out how to 'drill down' thru the errors.

Thanks,
G

.