Net.Data Books

Administration and Programming Guide for OS/390

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, 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. It assumes that Net.Data was configured using Net.Data directories, as previously described in Configuring Net.Data for Use with CGI and Configuring Net.Data for Use with ICAPI or GWAPI, and illustrates the context in which you specify a direct request for the Perl language environment.

<A HREF="http://server/netdata-cgi/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/netdata-cgi/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 |-----+-----------><
      '-| Non-database language environment call |-'
 
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
 
|---+----------------+--=---VALUE-------------------------------|
    +-DB_CASE--------+
    +-DB2PLAN--------+
    +-DB2SSID--------+
    +-DTW_HTML_TABLE-+
    +-LOCATION-------+
    +-RPT_MAX_ROWS---+
    '-SHOWSQL--------'
 
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

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.

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

DB2PLAN
Specifies the DB2 plan to be used when accessing the local DB2 subsystem.

DB2SSID
Specifies the DB2 subsystem ID to be used when accessing the local DB2 subsystem.

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

LOCATION
Specifies the name of the remote server to which the local DB2 subsystem should pass the SQL request.

RPT_MAX_ROWS
Specifies the maximum number of rows within a table that a function will return in a report.

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

START_ROW_NUM
Specifies the row number in a table for a function to use as the start of its report.

VALUE
Specifies the value of the Net.Data variable.

LANGENV
Specifies the target language environment for the SQL statement or stored procedure call.

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

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. The examples assume that Net.Data was configured using Net.Data directories as previously described in Configuring Net.Data for Use with CGI and Configuring Net.Data for Use with ICAPI or GWAPI

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/netdata-cgi/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/netdata-cgi/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

<FORM METHOD="POST"
 ACTION="http://server/netdata-cgi/db2www/">
<INPUT TYPE=hidden NAME="LANGENV" VALUE="DTW_SQL">
<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/netdata-cgi/db2www/?LANGENV=DTW_SQL&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/netdata-cgi/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/netdata-cgi/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/netdata-cgi/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/netdata-cgi/db2www/?LANGENV=DTW_SQL&FUNC=MY_STORED_PROC
   (IN+CHAR(30)+Salaries)&DTW_HTML_TABLE=YES


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