## ## 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. ## Using the SELECTOR option

Using the SELECTOR Option

We have seen how to retrieve a result set from the database. Now we would like to retrieve the plays according to type. We note that for the purposes of these examples the schema is somewhat denormalised. Normalisation and the subsequent adjustment of the queries is left as an exercise for the reader.

One way of presenting Web users with a choice is to use the combo box. Ingres Web Deployment Option will automatically generate the necessary HTML tags to generate a combo box element for us when we specify the type SELECTOR for an SQL query. We must supply a variable name to contain the value selected by the user and we specify this by using the ATTR keyword to name the variable type: e_type.

File: play_typeList.html


<html>
<head>
<title>Select a Type: Shakespeare's Plays</title>
</head>
<body>
<h1>Select a Type: Shakespeare's Plays</h1>
<FORM ACTION="/ice-bin/oiice.dll/playgroup/plays[play_subSet.html]"
	METHOD="POST">

<!-- #ICE REPEAT INCLUDE=`plays[play_TxnCndCmt_h.html]` -->

<!-- #ICE DECLARE=`session.e_type='select play type'` -->
<!-- #ICE REPEAT
	DATABASE = `icetutor` 
	SQL=`select distinct type from plays`
	TRANSACTION=`t_typeList` 
	CURSOR=`Works` 
	ROWS=`10`
	TYPE=`SELECTOR`
	ATTR=`NAME=e_type`
-->
<!-- #ICE COMMIT=`t_typeList` -->
<p>
<INPUT TYPE="submit" NAME="Display" VALUE="Display" ALT="Show  Plays of this type">
</FORM>
<!-- #ICE REPEAT INCLUDE=`plays[play_SessionControl_h.html]` -->
</body>
</html>

There are three interesting areas in this example. The first is in the select statement:

	SQL=`select distinct type from plays` 
here we are selecting the various play types from the table (we need to specify distinct because we have denormalised the schema).

Next we see that the TYPE of the result set has been changed from the default (TABLE) to the type SELECTOR. This automatically generates the HTML tags required for a combo box. We use the ATTR keyword to set the variable name for this combo box:

	TYPE=`SELECTOR`
	ATTR=`NAME=e_type`

Finally, we tidy up the transaction immediately by committing it at once (there is no need to hold it open, in contrast to the one in the previous document):

<!-- #ICE COMMIT=`t_typeList` -->

Having set the HTML variable e_type on the form we now include a submit button to send the successful controls (in particular e_type) to the next (display) document, play_subSet.html. We examine this document next.