Understanding SQml BORDER=

Basics of SQmlTM-Web

This section covers the following:

If you are not familiar with HTML, HTML forms, or SQL, you might want to check out some of the sites below before reading this tutorial. There are also many Beginner's Guides to HTML (just look for them with your favorite search engine):

HTML Guides:

SQL Guides:

Brief Overview of HTML Forms

HTML forms must have a method and an action designated in their form tag. Form tags look something like this:

	<FORM METHOD="method" ACTION="url">.

The METHOD tells the computer how to send the information. The "post" method gives the most flexibility, so it is the one that is used most often. The URL tells the form where to send the information gathered by the input tags.

HTML input tags look something like this:

 <INPUT NAME="name" TYPE="type" VALUE="value">.

NAME is the name of the variable that will hold the value selected by the user of the form. The different input types are: text, textarea, checkbox, radio, and select (creates a pulldown menu). VALUE is the the number or text that will be associated with the NAME if the user checks a box, clicks a radio button, or selects a menu item. Text and textarea do not use the VALUE element because the value is entered by the user.

Example:

<INPUT NAME="color" TYPE="checkbox" VALUE="brown"> BROWN
BROWN

Once we have a value associated with a name, we need a submit button. The submit button triggers the action defined in the FORM tag and the information is sent to another file for processing.

 Example: <INPUT TYPE="SUBMIT" VALUE="Submit Data">
 

For more information on HTML forms visit the sites mentioned above.

Where SQmlTM comes in

First let's start with some basic guidelines:

  1. The form sending the information to the SQmlTM file must have the ACTION: "/cgi-bin/sqml/filename.sqml"
  2. The names of the values being passed from an HTML form must be identical to the variable names in th SQmlTM file.
  3. Variables in the SQmlTM file may not contain underscores.
  4. The SQmlTM file must connect to the database in order to retrieve information. This is done in the connect tag:
     <sql.connect userid="username/passwd@t:computername">
    
  5. Variables created by the SQmlTM cursor may only be used between the beginning of that cursor and that cursor's end tag. The information retrieved cannot be seen outside these boundaries.
  6. While inside the cursor tag, variables are preceded by a colon (Example: ":variable"). While outside the tag, variables are preceded by an (&) and followed by a (;) (Example: "&variable;").

    Try These Demo Examples

    Below are some examples of forms that send data to SQmlTM files. Each form contains a link to a copy of the SQmlTM file that processes the information. I recommend viewing the SQmlTM source both before you submit and after you have seen the output. The SQmlTM material is in red and the comments explaining the SQmlTM code are in grey. In some of the examples I have numbered the cursors for clarity. These numbers are not in the actual script. You should also helpful to view the source for the HTML form by clicking the top of your browser: first on View, then on Document Source.

    Practice 1: In this example, the value that names a product line is passed from an HTML form to an SQmlTM file. The value passed is inserted into a SQmlTM iterative cursor (<sql.iter>). Specifically, the value is inserted into the cursor's where clause so the value may be used to narrow the database query. The data retrieved will represent only the product line that was chosen in the HTML form. The data retrieved is assigned to variables in the into statement. After the values have been assigned to variables, they are used in the document.

    The <sql.iter> cursor acts like cursors in most languages. It releases the information retrieved by the select statement one row at a time. Each row retrieved is used to fill in the document's variable values. The cursor loops until it is empty.

    Practice 2: In this example, three values are passed from an HTML form. We still use the value which names a product line. The two new values represent the low number and high number in a price range. They are all used in the where clause to narrow the search.

    Practice 3: This example uses four variables sent from an HTML form. They are the same three that were used before plus the value which describes a color. They are also inserted into the where clause. This example also shows how to get around the problem of null values by using a SQL*PLUS function. This problem occurs when a variable is not assigned a value. For instance, someone might leave a text field blank.

    Practice 4: This example is very similar to Practice 3. In fact, The HTML form is exactly the same. The difference is in the SQmlTM file that processes the information sent by the form. When you look at the SQmlTM source code, you will see two cursors. The first one is the same as it was in the last example. The second one contains a variable in its where clause. This variable was created in the first cursor's into statement. The information retrieved in the first cursor is used in the second cursor, the nested cursor. In this case, we used the value retrieved for the product's number.

    The second cursor will then retrieve information pertaining to one specific product. The second cursor selects from a different table than the first cursor. It will loop until all its rows have been used. Once the second cursor is finished, the first cursor releases another row for processing. This pattern will continue until the first cursor empties.

    Note the placement of the second cursor and its end tag (</sql.iter>). See how this placement allows the table to become either as large or as small as it needs to be?

    Customer Catalog Search: This example expands on the previous examples. The HTML form allows customers to search for products according to several different criteria. The SQmlTM file the information is sent to contains four cursors. Each cursor selects from a different table. The first and second cursors use values passed from the form in their where clauses. The third and fourth cursors use the product number retrieved by the first cursor.

    Distributor Catalog Search: This example is a lot like the Customer Catalog Search. The HTML form is a little different though. It uses check boxes. In the form we are giving the user the option to choose one or more product lines and one or more status. This data must be handled a little differently than other data we have seen used in the cursor. When you look at the SQmlTM source, notice how the parentheses are placed in the where clause.

Back To PreviousBack to Previous Page


© copyright 1997 Agave Software Design, Inc.Mail to: - All rights reserved.
Programming and Structure © copyright 1997 FS3 Internet Marketing, Inc. - All rights reserved.