cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Morrison <john.morri...@experian.com>
Subject RE: new sql logicsheet!
Date Tue, 05 Sep 2000 15:21:16 GMT
Huh, I don't think my first mail was as clear as I thought *GRIN*!

Yep, I ment get the value twice from the same result set.  I knew it
wasn't possible just using pure JDBC but I wondered if Donald had taken
it into account when he wrote the lib and I just missed how to do it.

It would appear that Donald just wrapped the result set so if I want to
use a value twice I'm going to have to mange his page somehow.  I did
think of trying to write this functionality around the tag but this is not
possible - the queries are taken 'out-of-line' into their own functions and
the previous query passed in, so I can't pass arbitary values around
easily.

Oh well.  As time permits...

>>> Kevin Sonney <kevin@webslingerz.com> 5/September/2000
01:59pm >>>
On Tue, 5 Sep 2000, John Morrison wrote:
> I know the example is a little contrived, what I'm essentially attempting
to
> do is get a result from a result set twice.  JDBC doesn't like this.  What
I'd
> like to know is if there's a way to get around this limitation in your
taglib?

If you mean "get two results from the same resultset", I would think the
answer is going to be no. JDBC *DOES* support this :

ResultSet rs = stmt.executeQuery(queryString);
while (rs.next()) {
	System.out.println(rs.getString("ID"));
	System.err.println(rs.getString("ID"));
}

Which you can easily do in esql like so :

<esql:results>
	<result_1><esql:get-string column="ID"/></result_1>
	<result_1a><esql:get-string column="ID"/></result_1a>
</esql:results>

This gets the same *RESULT* twice. However, if you want to get two
results from the same ResultSet in JDBC, it's better to steam it all into
a Hashtable or Vector (or List, or whatever) than post-process it :

Vector resultList = new Vector();
int resultNumber = 0;
while (rs.next()) {
	resultList.add(rs.getString("ID"));
	resultNumber++;
}
for (i=0; i < resultNumber+1; i++) {
	System.out.println("Current result is "+resultList.get(i));
	if (i > 0) {
		System.out.println("Previous Value is "+resultList.get(i-1));
	} 
	System.out.println("--");
}

Now all of this would have to be done via some really ugly XSP code,
which I'm not coherent enough yet to create (dangit, where's that
coffee??? *grin*)

-- 
+-------------------------------------------+
| Kevin Sonney        kevin@webslingerZ.com |
| Systems Programmer    www.webslingerZ.com |
+-------------------------------------------+





Mime
View raw message