Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Freddy Flintpedra

Greenhorn
+ Follow
since Jul 11, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Freddy Flintpedra

from the same resource as above, for Postgres:
Someone pointed this out to me for MSSQL 7 -- see how it flips the ORDER BY from DESC in the inner query to ASC in the 'final page' outer query -- pretty ingenious:

see also:
http://www.jguru.com/forums/view.jsp?EID=1060440
I would say the advantages of HTTP are:
-well defined standard that is fairly easy to write clients and servers for
-interoperable, cross-platform, cross-language, ubiquitous
-caching, proxies, load balancing... there are lots of well-known and fairly easy ways to scale systems built around HTTP
-the most used method [GET] is the most optimized, and the 1.1 protocol goes to great lengths to define how intermediate systems can cache objects -- following the HTTP principles gives you a lot of leverage to design your system to achieve maximum performance
-for me, the GET, PUT, and DELETE operations are just like the actions I end up coding over and over in Stateless Session facades for Data Transfer Objects...
-human and machine readable, just like XML (at least XML used to be...
disadvantages:
-plain text headers are somewhat inefficient (message bodies can be compressed and returned with a "Content-Encoding: gzip" entity header)
risks:
-corruption of the protocol by avoiding the core verbs (web services are too POST-centric for me)
-web browser mentality: to really understand HTTP, stop thinking of browsers and servers, since browsers really only do GET and POST, most people aren't aware that PUT and DELETE are verbs they could be using...
do a web search for:
Representational State Transfer
think of REST as using HTTP verbs (GET, PUT, POST, DELETE) to act on data objects, and you will have a solid foundation to build on.
when you need something from another node, use GET
when you want to store something to another node, use PUT
when you want to remove something from another node, use DELETE
when you want to change the state of an object on another node, use POST
17 years ago
I would have to say HTTP, since then you are that much closer to being able to communicate with anything else that can also communcate via HTTP, not just java apps over RMI
SOAP is basically RPC over HTTP, and is in many ways lacking
do a web search for:
Representational State Transfer
think of REST as using HTTP verbs (GET, PUT, POST, DELETE) to act on data objects, and you will have a solid foundation to build on.
when you need something from another node, use GET
when you want to store something to another node, use PUT
when you want to remove something from another node, use DELETE
when you want to change the state of an object on another node, use POST
17 years ago
in the Oracle example, the greater-than symbol followed by a right-parenthesis became a smiley face -- make sure you add a ')' before TALIAS
This is not a question, but some answers I have come up with in the past couple of days that I thought I'd share:

one option would be to use statement.setFetchSize(int) to limit the size of results returned -- call this prior to calling statement.executeQuery()
-------------------------------------------------
Otherwise, there are ways to control the resultset size via the SELECT statement as well, the exact way to do it depends on your database:
-----------------------------
Oracle:
select your results and explicitly add the rownum to the result, then select against that and use a between clause on the rownum, like this:
SELECT TALIAS.* FROM (SELECT ROWNUM AS RWN, <column-names> FROM (SELECT <column-names> FROM table_name WHERE <....> ORDER BY <...> TALIAS) WHERE TALIAS.RWN BETWEEN 1 AND 15
plug in your column names and table name, where conditions, etc. TALIAS is an statement-scope alias for the inner SELECTion result.
just plug in different values for the BETWEEN numbers and you can control the size of the result set and your overall window to it....
-----------------------------
MySQL:
much easier, use the limit keyword at the end of your query:
All rows:
SELECT columnA, columnB FROM table_name WHERE columnA=condition LIMIT 0, -1
first 10 rows:
SELECT columnA, columnB FROM table_name WHERE columnA=condition LIMIT 10
next 20 rows:
SELECT columnA, columnB FROM table_name WHERE columnA=condition LIMIT 11, 20
LIMIT begin-index, number-to-return (-1 is all remaining rows, so LIMIT 0, -1 is the entire result set, while LIMIT 101, -1 would be all remaining results after the 100th)
---------------------------
HSQLDB:
also much easier, use the limit keyword at the beginning of your query, with no comma, and 0 in the second position means all remaining results:
all rows:
SELECT LIMIT 0 0 columnA, columnB FROM table_name WHERE columnA=condition
first 10 rows:
SELECT LIMIT 0 10 * FROM table_name WHERE columnA=condition
next 20 rows:
SELECT LIMIT 11 20 * FROM table_name WHERE ColumnA=condition
---------------------------
MSSQL (I think only applies to 2000, not 7):
TOP is similar to LIMIT for MySQL
SELECT TOP 100 * FROM table_name
you could simulate paging by subsequently calling:
SELECT TOP 200 * FROM table_name
and skipping over the first 100 rows in the resultset (not pretty but it would work)

If you have a single-valued key that you sort on, you can use TOP and a WHERE clause to paginate the result set:
SELECT TOP 100 * FROM table_name WHERE key_column > ?
and parameterize the ? with 0, 100, 200, etc.

If the key is a compound key, then you can select data into a temp table with an identity column, and then pick intervals from this one. This is similar to the Oracle way to do it.
I don't know MSSQL syntax well enough to give an example of how to select into a temp table while adding an auto-increment int column. If someone does know, please post an example of how to do it!
Once you have the temp table:
SELECT * FROM temp_table WHERE new_auto_inc_key_column BETWEEN start AND end
---------------------------
hope this helps -- I just ran into the same problem myself yesterday