
80 DB2 for OS/390 and z/OS Powering the World’s e-business
Figure 5-6 shows a sample Net.Data macro and the input and output windows it
generates at the browser.
Figure 5-6 Sample Net.Data macro
The example in Figure 5-6 prompts for a last name to be found in an Employee
Directory and returns a list of matches. Note the sections of the macro:
The define section identifies parameterized standard information, such as the
Web page header.
The HTML section, named getlast, defines the format of the first Web page,
the variable to store the user’s entry, and the result page where the result will
be returned. The implicit variable, MATCH, will be used in the SQL statement.
The function section defines the query to be performed. Note that the implicit
variable, MATCH, is used in the SQL predicate. The function section in this
example also has a report section, which specifies how the answer set is to
be formatted.
The HTML section, named Report, shows the invocation of the SQL
statement.
%DEFINE(
STDHDR="Employee Directory"
DTATBASE="SAMPLE"
%)
%HTML(getlast)
<HTML>
<FORM METHOD="POST"
ACTION="/CGI-BIND/DB2WWW/CGDEMO8.DBW/REPORT">
$(STDHDR)<p>
Enter Last Name: <b>
<INPUT SIZE=20 NAME="MATCH"><INPUT TYPE=SUBMIT
TYPE="SEARCH">
</FORM>
</HTML>
%)
%FUNCTION(DTW_SQL) getname() (
Select * from EMPLOYEE WHERE
LASTNAME='$(MATCH)'
%REPORT(
Employee Name:<br>
%ROW (
<BR>
$(V1) $(V2)
%)
%)
%)
%HTML (REPORT) (
@getname()
%)
Define section
HTML input page
and implicit variable
definition
Function block and
Implicit variable
definition
HTML output page
Employee Directory
Enter Last name:
Winston Submit
Browser Screens
Employee Names:
Harry
Winston
James
Winston
Julia
Winston
Xavier
Winston