Re: MS SQL Server: Select Distinct on text datatype

From: Andrey Razumovsky (razumovsky.andre..mail.com)
Date: Mon Aug 04 2008 - 03:39:15 EDT

  • Next message: Lachlan Deck: "Re: MS SQL Server: Select Distinct on text datatype"

    This is definitely MS SQL's issue, not Cayenne's. Only thing I can
    recommend, if you can allow that, select all rows and then seed
    out duplicate rows manually

    2008/8/4, Matthias Moeser <matthia..sh.com.au>:
    >
    > Hi!
    >
    > We are using Cayenne with Microsoft SQL Server. We get a
    > com.microsoft.sqlserver.jdbc.SQLServerException: "The text data type cannot
    > be selected as DISTINCT because it is not comparable."
    >
    > The problem is that the following query is not allowed in MS SQL Server:
    >
    > SELECT DISTINCT column FROM table;
    >
    > where "column" is of datatype "text". So i think that cayenne does
    > somewhere such a DISTINCT query on a "text" datatype column.
    >
    > The datatype "text" in MS SQL server is a variable-length data with a
    > maximum length of 2^31 - 1 (2,147,483,647) characters, Varchar() can have
    > only maximum 8000 character.
    >
    > What can I do? I need the "text" datatype.
    >
    > Thank you
    > Matthias
    >
    >
    > org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    > at
    > org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.jav
    > a:228)
    > at
    > org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.ja
    > va:450)
    > Caused by: java.lang.Exception: The text data type cannot be selected as
    > DISTINCT because it is not comparable.
    > com.microsoft.sqlserver.jdbc.SQLServerException: The text data type
    > cannot be selected as DISTINCT because it is not comparable.
    > at
    > com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Un
    > known Source)
    > at
    > com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown
    > Source)
    > at
    > com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePrepare
    > dStatement(Unknown Source)
    > at
    > com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.
    > doExecute(Unknown Source)
    > at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown
    > Source)
    > at
    > com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown
    > Source)
    > at
    > com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown
    > Source)
    > at
    > com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown
    > Source)
    > at
    > com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unk
    > nown Source)
    > at
    > org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.j
    > ava:73)
    > at
    > org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryActi
    > on.java:58)
    >



    This archive was generated by hypermail 2.0.0 : Mon Aug 04 2008 - 03:40:34 EDT