I plan to provide Primary Key metadata in DBD::Oracle.
This topic is on the DBI-1.18 ToDo list, no interface is
defined so far.
Attached is my proposal for such an interface.
Steffen Goeldner
*** DBI-1.18/DBI.pm Mon Jun 04 21:01:40 2001
--- DBI.pm Mon Jun 18 10:12:45 2001
***************
*** 289,294 ****
--- 289,295 ----
tables => { U =>[1,2,'[ \%attr ]' ] },
table_info => { U =>[1,2,'[ \%attr ]' ] },
+ primary_key_info=> { U =>[1,2,'[ \%attr ]' ] },
type_info_all => { U =>[1,1] },
type_info => { U =>[1,2] },
get_info => { U =>[2,2] },
***************
*** 1043,1048 ****
--- 1044,1053 ----
shift->_not_impl('table_info');
}
+ sub primary_key_info {
+ shift->_not_impl('primary_key_info');
+ }
+
sub tables {
my ($dbh, @args) = @_;
my $sth = $dbh->table_info(@args);
***************
*** 2596,2601 ****
--- 2601,2671 ----
See also page 306 of the (very large) SQL/CLI specification:
http://www.jtc1sc32.org/sc32/jtc1sc32.nsf/Attachments/DF86E81BE70151D58525699800643F56/$FILE/32N0595T.PDF
+
+
+ =item C<primary_key_info> I<NEW>
+
+ B<Warning:> This method is experimental and may change.
+
+ $sth = $dbh->primary_key_info( \%attr );
+
+ Returns an active statement handle that can be used to fetch information
+ about columns that make up the primary key for a table.
+
+ The following attributes may be used as selection criteria:
+
+ %attr = (
+ TABLE_CAT => $CatVal # String value of the catalog name
+ , TABLE_SCHEM => $SchVal # String value of the schema name
+ , TABLE_NAME => $TblVal # String value of the table name
+ );
+
+ Note: The support for the selection criteria is driver specific.
+ If the driver doesn't support catalogs and/or schemas, it may ignore
+ these criteria.
+
+ The arguments TABLE_CAT, TABLE_SCHEM and TABLE_NAME don't accept search
+ patterns.
+
+ The statement handle returned has at least the following fields in the
+ order shown below. Other fields, after these, may also be present.
+
+ B<TABLE_CAT>: The catalog identifier.
+ This field is NULL (C<undef>) if not applicable to the data source,
+ which is usually the case.
+ This field is empty if not applicable to the table.
+
+ B<TABLE_SCHEM>: The schema identifier.
+ This field is NULL (C<undef>) if not applicable to the data source,
+ and empty if not applicable to the table.
+
+ B<TABLE_NAME>: The table identifier.
+
+ B<COLUMN_NAME>: The column identifier.
+
+ B<KEY_SEQ>: The column sequence number (starting with 1).
+ Note: This field is named B<ORDINAL_POSITION> in SQL/CLI.
+
+ B<PK_NAME>: The primary key constraint identifier.
+ This field is NULL (C<undef>) if not applicable to the data source.
+
+ For more detailed information about the fields and their meanings,
+ you can refer to:
+
+ http://msdn.microsoft.com/library/psdk/dasdk/odch6fn7.htm
+
+ If that URL ceases to work then use the MSDN search facility at:
+
+ http://search.microsoft.com/us/dev/
+
+ and search for C<SQLPrimaryKeys returns> using the exact phrase option.
+ The link you want will probably just be called C<SQLPrimaryKeys> and will
+ be part of the Data Access SDK.
+
+ See also page 266 of the current SQL/CLI Working Draft:
+
+
+http://www.jtc1sc32.org/sc32/jtc1sc32.nsf/Attachments/DF86E81BE70151D58525699800643F56/$FILE/32N0595T.PDF
+
=item C<tables> I<NEW>