By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,478 Members | 1,833 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,478 IT Pros & Developers. It's quick & easy.

JDBC: what exactly does nullsAreSortedHigh() return?

P: n/a
Hi all,

I am a bit confused about the method
java.sql.DatabaseMetaData.nullsAreSortedHigh(). What exactly does this
return? If this returns true, are nulls considered as the highest
value? Or does this mean that nulls comes first when sorted in
ascending order (opposite in meaning to the first).

Consider this.

- Oracle returns false. Nulls are last when sorted in ascending order.

- MSSQL2K returns true. Nulls are first when sorted in ascending
order.

- Postgres returns true. Nulls are last when sorted in ascending
order.

Now, behavior of Oracle and Postgres is same in terms of sort order,
but they return different values.

Who is right?
Nov 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Vikas Rana wrote:

Hi all,

I am a bit confused about the method
java.sql.DatabaseMetaData.nullsAreSortedHigh(). What exactly does this
return? If this returns true, are nulls considered as the highest
value? Or does this mean that nulls comes first when sorted in
ascending order (opposite in meaning to the first).

Consider this.

- Oracle returns false. Nulls are last when sorted in ascending order.

- MSSQL2K returns true. Nulls are first when sorted in ascending
order.

- Postgres returns true. Nulls are last when sorted in ascending
order.

Now, behavior of Oracle and Postgres is same in terms of sort order,
but they return different values.

Who is right?


It seems that the Oracle driver is wrong. I interpret nullsAreSortedHigh() the same as
Postgres.

That is, a true return from nullsAreSortedHigh() means Nulls are last when sorted in
ascending order.

This is the interpretation that FirstSQL/J uses.

--
Lee Fesperman, FirstSQL, Inc. (http://www.firstsql.com)
================================================== ============
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)
Nov 23 '05 #2

P: n/a
Vikas Rana wrote:
Hi all,

I am a bit confused about the method
java.sql.DatabaseMetaData.nullsAreSortedHigh(). What exactly does this
return? If this returns true, are nulls considered as the highest
value? Or does this mean that nulls comes first when sorted in
ascending order (opposite in meaning to the first).

Consider this.

- Oracle returns false. Nulls are last when sorted in ascending order.

- MSSQL2K returns true. Nulls are first when sorted in ascending
order.

- Postgres returns true. Nulls are last when sorted in ascending
order.

Now, behavior of Oracle and Postgres is same in terms of sort order,
but they return different values.

Who is right?


Here's the info from JDK1.4.2:

nullsAreSortedHigh

public boolean nullsAreSortedHigh()
throws SQLException

Retrieves whether NULL values are sorted high. Sorted high means
that NULL values sort higher than any other value in a domain. In an
ascending order, if this method returns true, NULL values will appear at
the end. By contrast, the method nullsAreSortedAtEnd indicates whether
NULL values are sorted at the end regardless of sort order.

Returns:
true if so; false otherwise
Throws:
SQLException - if a database access error occurs
So it seems that both Oracle and MSSQL are wrong...

Derek

Nov 23 '05 #3

P: n/a
On Wed, 02 Jun 2004 23:25:50 -0700, Vikas Rana wrote:
Hi all,

I am a bit confused about the method
java.sql.DatabaseMetaData.nullsAreSortedHigh(). What exactly does this
return? If this returns true, are nulls considered as the highest value?
Or does this mean that nulls comes first when sorted in ascending order
(opposite in meaning to the first).

Consider this.

- Oracle returns false. Nulls are last when sorted in ascending order.

- MSSQL2K returns true. Nulls are first when sorted in ascending order.

- Postgres returns true. Nulls are last when sorted in ascending order.

Now, behavior of Oracle and Postgres is same in terms of sort order, but
they return different values.

Who is right?


It depends on whether Oracle is returning true or false from
nullsAreSortedAtEnd. If this method returns truw then it does not
matter what is returned by nullsAreSortedHigh. Nulls will always be
last no matter what sort order you choose.

Chuck

Nov 23 '05 #4

P: n/a
On Wed, 02 Jun 2004 23:25:50 -0700, Vikas Rana wrote:
Hi all,

I am a bit confused about the method
java.sql.DatabaseMetaData.nullsAreSortedHigh(). What exactly does this
return? If this returns true, are nulls considered as the highest value?
Or does this mean that nulls comes first when sorted in ascending order
(opposite in meaning to the first).

Consider this.

- Oracle returns false. Nulls are last when sorted in ascending order.

- MSSQL2K returns true. Nulls are first when sorted in ascending order.

- Postgres returns true. Nulls are last when sorted in ascending order.

Now, behavior of Oracle and Postgres is same in terms of sort order, but
they return different values.

Who is right?


It depends on whether Oracle is returning true or false from
nullsAreSortedAtEnd. If this method returns truw then it does not
matter what is returned by nullsAreSortedHigh. Nulls will always be
last no matter what sort order you choose.

Chuck

Nov 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.