Hi Travis

[EMAIL PROTECTED] wrote:

>Actually, MS SQL has a nice way of doing it that's not specified on there,
>
>ie: SELECT TOP 50 FROM TableX
>
Actually that is specified in

http://www.craigsmullins.com/ssu_0900.htm

but what I don't yet know is how to select say the rows 10-20 from MSSQL

>But you're right, each database has a different way of handling this, if they handle 
>it at all.  
>
which is the main point.

>My thought on this when trying to solve this problem trying to make it database 
>independent is to create another ResultSet object that would handle this for you.  It 
>would also handle other database discrepencies in the actual resultset itself (like 
>getDate() in MS SQL server returns a different value then getDate() in mysql).
>
Looking at the code in BasePeer it seems that the infrastructure is 
there for the limit and offset to be applied in a database independent 
fashion, just that it isn't.  At least in the version I have checked 
out.  I made the following modification on the doSelect method in BasePeer:

    /**
     * Returns all results.
     *
     * @param criteria A Criteria.
     * @return Vector of Record objects.
     * @exception TorqueException
     */
    public static Vector doSelect(Criteria criteria)
        throws TorqueException
    {
        Vector results = null;
        if (criteria.isUseTransaction())
        {
            DBConnection dbCon = beginTransaction(criteria.getDbName());
            try
            {
                results = executeQuery( createQueryString(criteria),
+                                        criteria.getOffset(),
+                                       criteria.getLimit(),
                                        criteria.isSingleRecord(), dbCon );
                commitTransaction(dbCon);
            }
            catch (Exception e)
            {
                // make sure to return connection
                rollBackTransaction(dbCon);
                throw new TorqueException(e);
            }
        }
        else
        {
            results = executeQuery( createQueryString(criteria),
+                                    criteria.getOffset(),
+                                    criteria.getLimit(),
                                    criteria.getDbName(),
                                    criteria.isSingleRecord() );
        }
        return results;
    }

and if I set the MSSQL adaptor to indicate that MSSQL does not support 
native limit, then I get back the right stuff, at least superficially.

CHEERS> SAM



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to