Assuming ODBC gives the 'database independant method', see DBD::ODBC doc
for ODBC mechanism to do this. 

Will also need to check ODBC API reference on SQLPrimaryKey call on
which this DBD::ODBC call is based. ODBC doc desecribes the result set
of info about the primary key columns.

----------------- Sample Code ------------------------------------
    #-- Make the DBD::ODBC call to get primary key metedata.
    #-- Note: $dbh->func and the last parameter identify the 'private'
    #-- functions that a specific DBD driver may proivde (not available
    #-- from the general DBI interface.
    my $sth = $dbh->func($Parm{DbName}, $Parm{Schema}, $Parm{TableName},
                         'GetPrimaryKeys');
    if (not $sth) {
        #-- Error handling
        exit;
    }

    #-- Fetch all rows in the result set of column metadata.
    while (my $RowHashRef = $sth->fetchrow_hashref()) {
          #-- Process result set for ODBC request.
    }


Tim Harsch wrote:
> 
> Hi all,
>     Is there any database independant method, namely thru DBI, of determing which 
>column of a table is the primary key?
>     If not, has there been any discussion amongst the developers to include it in 
>the DBI spec?
> 
> Thanks,
> Tim Harsch

-- Bill
------------------------------------------------------------------------
Metagenix, Inc:  Leading the Way in Data Migration.
Web:  http://www.metagenix.com/ for more details.
Bill Cowan, [EMAIL PROTECTED], 919-490-0034 X-218, Fax: 919-490-0143

Reply via email to