## ## Document History ## ## Created (peeje01) ## 27-Apr-1999 (peeje01) ## Change include file name from -h.html to _h.html ## 02-Apr-2004 (fanra01) ## Bug 112091 ## Editorial changes from griel02. ##
The select statement is as before but now we include the test. If we receive fewer than 5 rows (ii_rowcount != 5) we insert the HTML to visit another page which is a facsimilie of this page but commits the transaction before running exactly the same query. This allows us to restart from the beginning of the result set.
Our solution appears below:
<html>
<head>
<title>Shakespeare's Plays</title>
</head>
<body>
<FORM ACTION="/ice-bin/oiice.dll/playgroup/plays[play_allWrap.html]"
METHOD="POST">
<!-- #ICE REPEAT
DATABASE = `icetutor`
SQL=`select * from plays`
TRANSACTION=`Complete`
CURSOR=`Works`
ROWS=`5`
TYPE=`TABLE`
-->
<!-- #ICE IF ( `:ii_rowcount` != `5` )
THEN=`<p>
<b>
<a href="/ice-bin/oiice.dll/playgroup/plays[play_allWrapSub.html]">
Re-start from the beginning
</a></b><p>`
-->
<!-- #ICE DECLARE=`session.e_playTxn=Complete` -->
<!-- #ICE DECLARE=`session.e_playTxnCommitted=FALSE` -->
<p>
<INPUT TYPE="submit" NAME="More" VALUE="More" >
<!-- #ICE REPEAT INCLUDE=`plays[play_SessionControl_h.html]` -->
</FORM>
</body>
</html>
The interesting part of the file is:
<!-- #ICE IF ( `:ii_rowcount` != `5` )
THEN=`<p>
<b>
<a href="/ice-bin/oiice.dll/playgroup/plays[play_allWrapSub.html]">
Re-start from the beginning
</a></b><p>`
-->
If the number of rows returned is not 5 then it must
be less than 5. We must test the inequality here because the
if statement performs string comparisons. If the
number of rows is less than 5 (we have reached the end of
the result set), we wish to give the user the oppertunity to
visit a 'reset' page. The then branch of the
if inserts the required link.
To start again, the first thing we must do is to
commit the previous transaction:
<!-- #ICE COMMIT=`:e_playTxn` -->
We then start exactly the same transaction again, giving the illusion that the user has visited the same file. Notice that the action on pressing the more button is to return to the original file.
Question: Could this functionality be achieved in one file? If not, why not?
<html>
<head>
<title>Shakespeare's Plays</title>
</head>
<body>
<!-- #ICE COMMIT=`:e_playTxn` -->
<!-- #ICE
DATABASE = `icetutor`
SQL=`select * from plays`
TRANSACTION=`Complete`
CURSOR=`Works`
ROWS=`5`
TYPE=`TABLE`
-->
<!-- #ICE DECLARE=`session.e_playTxn=Complete` -->
<!-- #ICE DECLARE=`session.e_playTxnCommitted=FALSE` -->
<FORM ACTION="/ice-bin/oiice.dll/playgroup/plays[play_allWrap.html]"
METHOD="POST">
<INPUT TYPE="submit" NAME="More" VALUE="More" >
</FORM>
<!-- #ICE REPEAT INCLUDE=`plays[play_SessionControl_h.html]` -->
</body>
</html>