Invoking Net.Data without a Macro (Direct Request)

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>

Direct Request Syntax

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

DTW_DOCUMENT
Specifies the type of document that Net.Data should return as output. The allowable values are XML or HTML. This parameter is optional, and if not specified then HTML is assumed.

DTW_STYLESHEET
Specifies the stylesheet that Net.Data should use when displaying XML. This parameter is optional and is only relevant when DTW_DOCUMENT=XML.

stylesheet
Specifies the filename on the server for the stylesheet.

Database language environment call
Specifies a direct request to Net.Data that invokes a database language environment.

Form data entry
Parameters that allow you to specify the settings of SQL variables or to request simple HTML formatting. See the variables chapter of Net.Data Reference to learn more about these variables.

DATABASE
Specifies the database to which Net.Data should pass the SQL request. This parameter is required.

DB_CASE
Specifies the case (upper or lower) for SQL statements.

DTW_HTML_TABLE
Specifies whether Net.Data should return an HTML table or a pre-formatted text table.

DTW_DOCUMENT
Specifies whether Net.Data should display the results as XML or HTML. Allowable values are XML or HTML. HTML is the default when the keyword is not specified.

LOGIN
Specifies the database user ID.

PASSWORD
Specifies the database password.

RPT_MAX_ROWS
Specifies the maximum number of rows that a function should return in its report.

SHOWSQL
Specifies whether Net.Data should hide or display the SQL statement being executed.

START_ROW_NUM
Specifies the number of the row where a function should start its report.

user_defined_variable
Variables that are passed to Net.Data and provide required information or effect Net.Data behavior. User-defined variables are variables that you define for your application.

VALUE
Specifies the value of the Net.Data variable.

LANGENV
Specifies the target language environment for the SQL statement or stored procedure call. If the language environment is one of the database language environments, the database name must also be specified.

dblangenv
The name of the database language environment:
  • DTW_SQL
  • DTW_ODBC
  • DTW_ORA

SQL
Indicates that the direct request specifies the execution of an in-line SQL statement.

sql_stmt
Specifies a string that contains any valid SQL statement that can be executed using dynamic SQL.

FUNC
Indicates that the direct request specifies the execution of a stored procedure.

stored_proc_name
Specifies any valid DB2 stored procedure name.

parm_type
Specifies any valid parameter type for a DB2 stored procedure.

parm_name
Specifies any valid parameter name.

parm_value
Specifies any valid parameter value for a DB2 stored procedure.

IN
Specifies that Net.Data should use the parameter to pass input data to the stored procedure.

INOUT
Specifies that Net.Data should use the parameter to both pass input data to the stored procedure and return output data from the language environment.

OUT
Specifies that the language environment should use the parameter to return output data from the stored procedure.

Non-database language environment call
Specifies a direct request to Net.Data that invokes a non-database language environment.

LANGENV
Specifies the target language environment for the execution of the function.

lang_env
Specifies the name of the non-database language environment:
  • DTW_PERL
  • DTW_REXX
  • DTW_SYSTEM

FUNC
Indicates that the direct request specifies the execution of a program.

program_name
Specifies the program containing the function to be executed.

parm_value
Specifies any valid parameter value for the function.

Direct Request Examples

The following examples show the different ways you can invoke Net.Data while using the direct request method.

HTML Links

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.

HTML Forms

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.

URL

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


[ Top of Page | Previous Page | Next Page | Index ]