This section shows you how to invoke Net.Data using direct request. When you use direct request, you do not specify the name of a macro in the URL. Instead, you specify the Net.Data language environment, the SQL statement or a program to be executed, and any additional required parameter values within the URL, using a syntax defined by Net.Data. See DTW_DIRECT_REQUEST: Enable Direct Request Variable to learn how to enable and disable direct request.
The SQL statement or program and any other specified parameters are passed directly to the designated language environment for processing. Direct request improves performance because Net.Data does not need to read and process a macro. The SQL, ODBC, Oracle, Java, System, Perl, and REXX Net.Data-supplied language environments support direct request, and you can call Net.Data using a URL, an HTML form, or a link.
A direct request invokes Net.Data by passing parameters in the query string of the URL or the form data. The following example illustrates the context in which you specify a direct request.
<a href="http://server/cgi-bin/db2www/?direct_request">any text</a>
Where direct_request represents the direct request syntax. For example, the following HTML link contains the direct request:
<a href="http://server/cgi-bin/db2www/?LANGENV=DTW_PERL&FUNC=my_perl(hi)"> any text</a>
The syntax for invoking Net.Data with direct request can contain a call to either a database or a non-database language environment.
Syntax
>>-?--+--------------------------------------------------------------+-- ----+-| Database language environment call |-----+-> | .-HTML--. | '-| Non-database language environment call |-' '-DTW_DOCUMENT=--+-XML---+---&--+---------------------------+--' '-STYLESHEET=--filename--&--' >-------------------------------------------------------------->< Database language environment call .-------------------------------. V | |------+-------------------------+--+--LANGENV =----------------> '-| Form data entry |--&--' .-------------------------------. V | >-------dblangenv----&-------+-------------------------+--+-----> '-| Form data entry |--&--' >-----+-SQL=--sql_stmt-------------------------------------+----> '-FUNC=--stored_proc_name--(--| Parameter list |--)--' .-------------------------------. V | >--------+-------------------------+--+-------------------------| '-&--| Form data entry |--' Form data entry |---DATABASE----+-----------------------+--=---VALUE------------| +-DB_CASE---------------+ +-DTW_HTML_TABLE--------+ +-LOGIN-----------------+ +-PASSWORD--------------+ +-RPT_MAX_ROWS----------+ +-SHOWSQL---------------+ +-START_ROW_NUM---------+ '-user_defined_variable-' Parameter list .-,-------------------------------------------------------------. V | |-----+-IN--parm_type--+-parm_value--------+---------------------+--+-> | '-"--parm_value--"--' | +-OUT--parm_type--+-parm_name--+---------------------------+ | '-parm_name--' | '-INOUT--parm_type--+-parm_name--+---+-parm_value--------+-' '-parm_name--' '-"--parm_value--"--' >---------------------------------------------------------------| Non-database language environment call |---LANGENV=------lang_env----&---FUNC--=--program_name---------> .-,-----------------------. V | >----(-----+-------------------+--+---)-------------------------| '-"--parm_value--"--'
Parameters
The following examples show the different ways you can invoke Net.Data while using the direct request method.
The following examples use direct request to invoke Net.Data through links.
Example 1: A link that invokes the Perl language environment and calls a Perl script that is in the EXEC path statement of the Net.Data initialization file
<a href="http://server/cgi-bin/db2www/?LANGENV=DTW_PERL&FUNC=my_perl(hi)"> any text</a>
Example 2: A link that invokes the Perl language environment, as in the previous example, but passes a string with URL-encoded values for the double quote and the space characters
<a href="http://server/cgi-bin/db2www/?LANGENV=DTW_PERL&FUNC=my_perl (%22Hello+World%22)">any text</a>
Tip: | You must encode certain characters, such as spaces and double quotes, within URLs. In this example, the double quotes characters and spaces within the parameter value must be encoded as %22 or the + character, respectively. You can use the built-in function DTW_URLESCSEQ to encode any text that must be encoded witin a URL. For more information on the DTW_URLESCSEQ function, see its description in Net.Data Reference. |
The following examples use direct request to invoke Net.Data through forms.
Example 1: An HTML form that results in the execution of an SQL query using the SQL language environment, connects to the CELDIAL database, and queries a table
<form method="post" action="http://server/cgi-bin/db2www/"> <input type=hidden name="langenv" value="dtw_sql" /> <input type=hidden name="database" value="celdial" /> <input type=hidden name="sql" value="select * from table1 where col1=$(inputname)" /> Enter Customer name: <input type=text name="inputname" value="john" /> <input type=submit /> </form>
This example contains a variable substitution in the SQL statement to make the WHERE clause dynamic.
The following examples use direct request to invoke Net.Data through URLs.
Example 1: A URL that results in the execution of an SQL query using the SQL language environment
http://server/cgi-bin/db2www/?LANGENV=DTW_SQL&DATABASE=CELDIAL &SQL=select+*+from+customer
Example 2: A URL that invokes the Perl language environment and calls an executable file that is not in the EXEC path statement of the Net.Data initialization file
http://server/cgi-bin/db2www/?LANGENV=DTW_PERL&FUNC=/u/MYDIR/macros/myexec.pl
Example 3: A URL that invokes the System language environment and calls an external Perl script
http://server/cgi-bin/db2www/?LANGENV=DTW_SYSTEM& FUNC=perl+/u/MYDIR/macros/myexec.pl
Example 4: A URL that invokes the REXX language environment, calls a REXX program, and passes parameters to the program
http://server/cgi-bin/db2www/?LANGENV=DTW_REXX&FUNC=myexec.cmd(parm1,parm2)
Example 5: A URL that calls a stored procedure and passes parameters to the SQL language environment
http://server/cgi-bin/db2www/?LANGENV=DTW_SQL&FUNC=MY_STORED_PROC (IN+CHAR(30)+Salaries)&DATABASE=CELDIAL