getPrimaryKeys - again

Dirk Zöttl <[email protected]>
Newsgroups gmane.comp.db.mckoi
Message-ID <[email protected]>
Hi Toby,

in your answer from 3 Nov, 2004 17:32:14 to my request requiring
key segment sequence numbers starting at 1 you agreed to commit
the changes I proposed.

But after checking the latest nightly archive (13 Dec) I could not
see any changes in .\src\com\mckoi\database\Database.java .

Sincerely
Dirk

 > Dirk,
 >
 > It's not clear from the JDBC specification that KEY_SEQ should not be
 > zero based, but it does appear most other JDBC implementations start
 > at 1.  I will commit this change.
 >
 > Thanks,
 > Toby.
 >
 > Dirk Zöttl wrote:
 >
 >> Hi all,
 >>
 >> I have a problem with the data returned from:
 >>
 >>   java.sql.DatabaseMetaData.getPrimaryKeys(String,String,String)
 >>
 >> As stated in the API docs the ResultSet is ordered by COLUMN_NAME.
 >> To save a list or array of key columns ordered by sequence within
 >> the primary key I (and maybe others) use the column SEQ_NO.
 >>
 >> In the following function I get an ArrayIndexOutOfBoundsException
 >> since McKoi returns SEQ_NO zero based.
 >>
 >> String[] getPrimaryKeyColumns(DatabaseMetaData dbMeta,
 >>                               String schema,
 >>                               String tabName) throws SQLException {
 >>   String[] keyCols = new String[20];
 >>   int keyCount = 0;
 >>   ResultSet rset = dbMeta.getPrimaryKeys(null, schema, tabName);
 >>   while (rset.next()) {
 >>     String colName = rset.getString(4);
 >>     int seq_no = rset.getInt(5);
 >>     keyCols[seq_no - 1] = colName;
 >>     keyCount = Math.max(keyCount, seq_no);
 >>   }
 >>   rset.close();
 >>   return ArrayUtil.subArray(keyCols, 0, keyCount);
 >> }
 >>
 >>
 >> Most databases (Oracle, DB/2, MaxDB, Sybase, Informix, PostgeSQL
 >> etc.) return column sequence numbers unit based.
 >>
 >> In contrast McKoi returns column sequence numbers here zero based,
 >> whereas the function getColumns returns them unit based.
 >>
 >> I propose to move to unit based column sequence numbers for all
 >> meta-data functions. This could be done with the following changes
 >> to the McKoi 1.0.3 source code in file:
 >>
[...snip...]
-- 
Eckenfelder GmbH & Co.KG
-Dirk Zöttl-

Am Röderweg 1
99819 Wenigenlupnitz
http://www.eckenfelder.de
mailto:[email protected]


---------------------------------------------------------------
Mckoi SQL Database mailing list  http://www.mckoi.com/database/
To unsubscribe, send a message to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.