I'm stumped. I need to access the next nth row
in a query loop to show version differences between posts.
I'm using <cfquery>
to output the revisions by group, and this is my expected output:
Rev4
diff(rev4.title, original.title)
diff(rev4.brief, rev2.brief)
Rev3
diff(rev3.body, rev2.body)
Rev2
diff(rev2.brief, original.brief)
diff(rev2.body, original.body)
Original
query.title
query.brief
query.body
I initially thought to use Java methods to get the next query row. This does not work:
I tagged this with Java because ColdFusion allows us to use Java methods on queries objects, but it's not documented so merely knowing of its existence does not help me.
Anyone can show me a [better] way to do this?
The code structure I thought of:
<cfoutput query="revisions" group="revisionGUID">
#revision.revisionGUID#
<cfoutput>
// conditional logic to get diff();
<cfoutput>
</cfoutput>
Sorry that I don't know Coldfusion, but it sounds like (Java) scrollable resultSet might be useful.
From the oracle info page:
5.1 Scrolling
A result set created by executing a statement may support the ability to move backward (last-to-first) through its contents, as well as forward (first-to-last). Result sets that support this capability are called scrollable result sets. Result sets that are scrollable also support relative and absolute positioning. Absolute positioning is the ability to move directly to a row by specifying its absolute position in the result set, while relative positioning gives the ability to move to a row by specifying a position that is relative to the current row. (link: result set enhancements)
And the ResultSet api briefly mentions it at the top:
A default ResultSet object is not updatable and has a cursor that moves forward only. Thus, you can iterate through it only once and only from the first row to the last row. It is possible to produce ResultSet objects that are scrollable and/or updatable. The following code fragment, in which con is a valid Connection object, illustrates how to make a result set that is scrollable and insensitive to updates by others, and that is updatable. See ResultSet fields for other options.
http://download.oracle.com/javase/1.4.2/docs/api/java/sql/ResultSet.html
Hope this helps you find what you are looking for =)