Thread: ordering of results returned from DatabaseMetaData.getImportedKeys()

ordering of results returned from DatabaseMetaData.getImportedKeys()

From
peter royal
Date:
Here's the situation:

I have a table that has multiple foreign keys to another table, and the
key is a composite key (ie multiple fields).

The results returned from DatabaseMetaData.getImportedKeys() seem
"wrong" in that all the KEY_SEQ 1's are returned first and then all the
2's

The results are:

FK_TABLE_NAME FK_COLUMN_NAME PK_TABLE_NAME  PK_COLUMM_NAME KEY_SEQ
------------------------------------------------------------------
  glsetup      acct1loc        glaccount      gllocnum       1
  glsetup      acct2loc        glaccount      gllocnum       1
  glsetup      acct3loc        glaccount      gllocnum       1
  glsetup      acct1num        glaccount      glmasterid     2
  glsetup      acct2num        glaccount      glmasterid     2
  glsetup      acct3num        glaccount      glmasterid     2

but i would expect something more like:

FK_TABLE_NAME FK_COLUMN_NAME PK_TABLE_NAME  PK_COLUMM_NAME KEY_SEQ
------------------------------------------------------------------
  glsetup      acct1loc        glaccount      gllocnum       1
  glsetup      acct1num        glaccount      glmasterid     2
  glsetup      acct2loc        glaccount      gllocnum       1
  glsetup      acct2num        glaccount      glmasterid     2
  glsetup      acct3loc        glaccount      gllocnum       1
  glsetup      acct3num        glaccount      glmasterid     2

its a simple fix in AbstractJdbc1DatabaseMetaData, I'm just unsure of
whether or not its a valid fix according to the JDBC3 documentation.

This is *ONLY* an issue when you have more than one multi-column FK to
the same table.

So my question is, should the JDBC driver be patched to return what I
expect, or should I modify my code to accommodate what the driver is
returning?
-pete


Re: ordering of results returned from DatabaseMetaData.getImportedKeys()

From
Kris Jurka
Date:

On Wed, 31 Dec 2003, peter royal wrote:

> Here's the situation:
>
> I have a table that has multiple foreign keys to another table, and the
> key is a composite key (ie multiple fields).
>
> The results returned from DatabaseMetaData.getImportedKeys() seem
> "wrong" in that all the KEY_SEQ 1's are returned first and then all the
> 2's
>

What version of the JDBC driver and what version of the database server
are you using?  It should report results as you expect.

Kris Jurka



Re: ordering of results returned from

From
Dave Cramer
Date:
From the javadocs:

Retrieves a description of the primary key columns that are referenced
by a table's foreign key columns (the primary keys imported by a table).
They are ordered by PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME, and
KEY_SEQ.


so what you are seeing is correct according to the docs.

Dave
On Wed, 2003-12-31 at 16:33, Kris Jurka wrote:
> On Wed, 31 Dec 2003, peter royal wrote:
>
> > Here's the situation:
> >
> > I have a table that has multiple foreign keys to another table, and the
> > key is a composite key (ie multiple fields).
> >
> > The results returned from DatabaseMetaData.getImportedKeys() seem
> > "wrong" in that all the KEY_SEQ 1's are returned first and then all the
> > 2's
> >
>
> What version of the JDBC driver and what version of the database server
> are you using?  It should report results as you expect.
>
> Kris Jurka
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly
>
--
Dave Cramer
519 939 0336
ICQ # 1467551