IBM Books

Net.Data Reference


Net.Data Report Variables

These variables help you customize your reports. You must define these variables before using them.

ALIGN


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Controls leading and trailing spaces used with the table processing variables NLIST and VLIST.

Performance Tip: Use ALIGN only when necessary as it requires that Net.Data determine the maximum column length for all columns in the table to calculate padding requirements. This process can impact performance.

When set to YES, ALIGN provides padding to align table processing variables for display. If you want to embed query results in HTML links or form actions, use the default value of NO to prevent Net.Data from surrounding report variables with leading and trailing spaces.

Specify the value of this variable using a DEFINE statement or with the @DTW_ASSIGN() function.

Values

ALIGN="YES"|"NO"

Table 2. ALIGN Values
Values Description
YES Net.Data adds leading and trailing spaces to report variables with spaces to align them for display.
NO Net.Data does not add leading or trailing spaces. NO is the default.

Examples

Example 1: Using the ALIGN variable to separate each column by a space

%DEFINE ALIGN="YES"
<P>Your query was on these columns: $(NLIST)

DTW_DEFAULT_REPORT


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Determines whether Net.Data generates a default report for functions that have no REPORT block. When this variable is set to YES, Net.Data generates the default report. When set to NO, Net.Data suppresses default report generation. Suppressing the default report is useful, for example, if you receive the results of a function call in a table variable and want to pass the results to a different function to process.

Specify the value of this variable using a DEFINE statement or with the @DTW_ASSIGN() function.

Values

DTW_DEFAULT_REPORT="YES"|"NO"

Table 3. DTW_DEFAULT_REPORT Values
Values Description
YES Net.Data generates the default report for functions without REPORT blocks and displays the results at the browser. YES is the default.
NO Net.Data discards the default report for functions without REPORT blocks.

Examples

Example 1: Overriding the default report generated by Net.Data

%DEFINE DTW_DEFAULT_REPORT="NO"

DTW_HTML_TABLE


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Displays results in an HTML table instead of displaying the table in a text-type format (that is, using the TABLE tags rather than the PRE tags).

The generated TABLE tag includes a border and cell-padding specification:

<TABLE BORDER CELLPADDING=2>

Specify the value of this variable using a DEFINE statement or with the @DTW_ASSIGN() function.

Values

DTW_HTML_TABLE="YES"|"NO"

Table 4. DTW_HTML_TABLE Values
Values Description
YES Displays table data using HTML table tags.
NO Displays table data in a text format, using PRE tags. NO is the default.

Examples

Example 1: Displays results from an SQL function with HTML tags

%DEFINE DTW_HTML_TABLE="YES"
 
%FUNCTION(DTW_SQL){
SELECT NAME, ADDRESS FROM $(qTable)
%}

RPT_MAX_ROWS


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Specifies the number of rows that are displayed in a table generated by a function REPORT block.

Specify the value of this variable using a DEFINE statement or with the @DTW_ASSIGN() function.

Performance Tip for OS/400, Windows NT, OS/2, and UNIX: Passing RPT_MAX_ROWS to the database language environment helps you limit the number of rows returned from the language environment, improving performance. To pass RPT_MAX_ROWS to the language environment (for example, DTW_SQL), include this variable as an IN variable in the ENVIRONMENT statement for the database language environments you are using, in the initialization file. See the configuration chapter of Net.Data Administration and Programming Guide to learn more about the database language environment statement.

Values

RPT_MAX_ROWS="ALL"|"0"|"number"

Table 5. RPT_MAX_ROWS Values
Values Description
ALL Indicates that there is no limit on the number of rows to be displayed in a table generated by a function call. All rows will be displayed.
0 Specifies that all rows in the table will be displayed. This value is the same as specifying ALL.
number A positive integer indicating the maximum number of rows to be displayed in a table generated by a function call.

If the FUNCTION block contains a REPORT and ROW block, this number specifies the number of times the ROW block is executed.

Examples

Example 1: Defines RPT_MAX_ROWS in a DEFINE statement

%DEFINE RPT_MAX_ROWS="20"

The above method limits the number of rows any function returns to 20 rows.

Example 2: Uses HTML input to define the variable with an HTML form

Maximum rows to return (0 for no limit):
<INPUT TYPE="text" NAME="RPT_MAX_ROWS" SIZE=3>

The lines in the above example can be placed in a FORM tag to let the application users set the number of rows they want returned from a query.

START_ROW_NUM


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X
X X X X

Purpose

Specifies the row number to begin displaying the results of a Net.Data table in a report. Use this variable together with RPT_MAX_ROWS to break queries with large result sets into smaller tables and use a Next button to navigate through the result table.

Performance tip for OS/400, OS/2, Windows NT, and UNIX: Ensure that START_ROW_NUM is specified as an IN variable on the ENVIRONMENT statement for the database LE. Otherwise the database LE returns the result set starting at the first row. If not specified on the ENVIRONMENT statement, Net.Data must discard the rows up to the specified row, rather than the LE not returning the rows in the first place.

Specify the value of this variable using a DEFINE statement or with the @DTW_ASSIGN() function.

Values

START_ROW_NUM="number"

Table 6. START_ROW_NUM Values
Values Description
number A positive integer indicating the row number with which to begin displaying a report.

If START_ROW_NUM is specified in a database language environment's environment statement in the initialization file, this number specifies the row number of the result set processed by the database language environment.

If START_ROW_NUM is not passed to the language environment, this number specifies the row number of the Net.Data table used to display a report.

Examples

Example 1: Scrolling with HTML form Next and Previous buttons

%define {
  DTW_HTML_TABLE      = "YES"
  START_ROW_NUM       = "1"
  RPT_MAX_ROWS        = "10"
  totalSize           = ""
  includeNext         = "YES"
  includePrev         = "YES"
  includeLast         = "YES"
  includeFirst        = "YES"
%}
 
%function(DTW_SQL) myQuery(){
  select * from NETDATADEV.CUSTOMER
%}
 
%function(DTW_SQL) count(OUT size){
  select count(*) from NETDATADEV.CUSTOMER
  %report{
    %row{
      @DTW_ASSIGN(size,V1)
    %}
  %}
%}
 
%html(report) {
  %{ get the total number of records if we haven't already %}
  %if (totalSize == "")
    @count(totalSize)
  %endif
 
  %{ set START_ROW_NUM based on the button user clicked %}
  %if (totalSize <= RPT_MAX_ROWS)
    %{ there's only one page of data %}
    @DTW_ASSIGN(START_ROW_NUM, "1")
    @DTW_ASSIGN(includeFirst, "NO")
    @DTW_ASSIGN(includeLast, "NO")
    @DTW_ASSIGN(includeNext, "NO")
    @DTW_ASSIGN(includePrev, "NO")
  %elif (submit == "First Page" || submit == "")
    %{ first time through or user selected "First Page" button %}
    @DTW_ASSIGN(START_ROW_NUM, "1")
    @DTW_ASSIGN(includePrev, "NO")
    @DTW_ASSIGN(includeFirst, "NO")
  %elif (submit == "Last Page")
    %{ user selected "Last Page" button %}
    @DTW_SUBTRACT(totalSize, RPT_MAX_ROWS, START_ROW_NUM)
    @DTW_ADD(START_ROW_NUM, "1", START_ROW_NUM)
    @DTW_ASSIGN(includeLast, "NO")
    @DTW_ASSIGN(includeNext, "NO")
  %elif (submit == "Next")
    %{ user selected "Next" button %}
    @DTW_ADD(START_ROW_NUM, RPT_MAX_ROWS, START_ROW_NUM)
    %if (@DTW_rADD(START_ROW_NUM, RPT_MAX_ROWS) > totalSize)
      @DTW_ASSIGN(includeNext,"NO")
      @DTW_ASSIGN(includeLast, "NO")
    %endif
  %elif (submit == "Previous")
    %{ user selected "Previous" button %}
    @DTW_SUBTRACT(START_ROW_NUM, RPT_MAX_ROWS, START_ROW_NUM)
    %if (START_ROW_NUM <= "1" )
      @DTW_ASSIGN(START_ROW_NUM,"1")
      @DTW_ASSIGN(includePrev,"NO")
      @DTW_ASSIGN(includeFirst,"NO")
    %endif
  %endif
 
  %{ run the query to get the data %}
  @myQuery()
 
  %{ output the correct buttons at the bottom of the report %}
  <center>
  <form method="POST" action="report">
  <input name="START_ROW_NUM" type="hidden" value="$(START_ROW_NUM)">
  <input name="totalSize" type="hidden" value="$(totalSize)">
  %if (includeFirst == "YES" )
  <input name="submit" type="submit" value="First Page">
  %endif
  %if (includePrev == "YES" )
  <input name="submit" type="submit" value="Previous">
  %endif
  %if (includeNext == "YES" )
  <input name="submit" type="submit" value="Next">
  %endif
  %if (includeLast == "YES" )
  <input name="submit" type="submit" value="Last Page">
  %endif
  </form>
  </center>
%}


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