TOC PREV NEXT INDEX



Map Form Data into the Database Query


At this point, you may notice that regardless of what you type into the form, you get the same results. That is because the SQLStatement module does the same query every time. What we really need is to modify the query so that the data that came in from the form is inserted into the query instead of searching on the same criteria each time. To accomplish this:

  1. Select the SQL Mapping Tool node of the SQLStatement Module.

The mapping node shows two tables. The table on the left is a split list that shows all of the keywords (A.K.A. Literals) that were in your SQL statement. If you go back to the SQL Query Builder node you'll notice that the items that appeared on the left of the table are all in the SQL Query. The table on the right is a list of the data that has been produced by all of the preceding modules. By selecting a word on the left table and then selecting the data that you want to substitute for that word, you can "Map" data into the query.

Generally this mapping feature is used to take data that came in from the form and insert it into the query, which is precisely what we're going to do in this tutorial in the following steps...

  1. Select the "HW" line on the keyword table on the left.
  2. Select the "productCode" line on the variable substitution table on the right. this should make the word "productCode" appear to the right of the word "HW" in the keyword table.
  3. Select the line with "1500" on it in the keyword table.
  4. Select the line with the word "maxPrice" from the table on the right.
  5. Select the keyword table line containing the number "15".
  6. Select the variable substitution table line with the word "quantity".

The keyword table should now look like:

HW
productCode
1500
maxPrice
15
quantity

To test that this worked, go back to the web browser, select the back button to get back to the Catalog Search Form, change the search values, perhaps selecting 'software' instead of 'hardware', and re-submit the form. Notice that you now get different results depending on what you entered in the form.


Data Representations, Inc.
http://www.datarepresentations.com
support@datarepresentations.com
sales@datarepresentations.com
TOC PREV NEXT INDEX