Page 1 of 1

Using LIMIT in SQL Query

Posted: Tue Nov 14, 2006 9:16 am
by warrenk
I am trying to paginate my query results. When I use the LIMIT in my SQL statement, I get the following error:

'Token Limit Was Not Valid'

From what I uderstand the LIMIT parameter can't be used with a ODBC_EXEC? If so, is there another parameter I can use in my SQL statement that allows me to specify starting record and limit the number of records in my results?

Posted: Tue Nov 14, 2006 9:32 am
by aaronhall
Queries are interpreted by the database, not the API. What database are you using?

Posted: Tue Nov 14, 2006 9:46 am
by warrenk
I am trying to pull the results from a AS400 database.

Posted: Tue Nov 14, 2006 11:22 am
by volka
warrenk wrote:I am trying to pull the results from a AS400 database.
meaning: it's a DB2?

LIMIT is a mysql extension to sql.
Funny, IBM set up a page called
http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0602tham2/ wrote:Leveraging MySQL skills to learn DB2 Express: DB2 versus MySQL administration and basic tasks
http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0602tham2/ wrote:However, to limit the resultset being returned, MySQL uses the keyword, LIMIT, while DB2 Express uses FETCH FIRST n ROWS to limit resultset being returned

Posted: Tue Nov 14, 2006 12:06 pm
by warrenk
Volka,

You are correct...it is DB2.

This adds a twist to what I am trying to do. The LIMIT parameter made it so easy to paginate my results. Oh well...back to the drawing board.

Thanks for your help!
Warren

Posted: Tue Nov 14, 2006 12:34 pm
by califdon
Warren, you might consider the possibility of importing data from the DB2 table(s) into MySQL and then using the LIMIT feature of MySQL.

Posted: Tue Nov 14, 2006 1:02 pm
by volka
Or you might read an article about how to achive pagination with db2 ;)

http://www-128.ibm.com/developerworks/d ... alani.html

Posted: Tue Nov 14, 2006 1:05 pm
by warrenk
Volka,

Thanks for your help! I was just on the internet searching for a way to do this without the LIMIT. You saved me lots of stress!!!! :D

Warren