START_ROW_NUM

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

Purpose

Specifies the starting row number in a table that will get processed in a function REPORT block or during the generation of a default report if a REPORT block is not specified.

The database language environments use this variable to determine the starting row in the result set to begin processing. To subtantially improve performance for large result sets, use this variable with RPT_MAX_ROWS to break queries with large result sets into smaller tables.

OS/400, Windows NT, OS/2, and UNIX users: To pass this variable to the language environment, include it as an IN parameter in the database language environment's ENVIRONMENT statement in the Net.Data initialization file. To learn more about the database language environment statement, see the configuration chapter of the Net.Data Administration and Programming Guide for your operating system.

OS/390 users: START_ROW_NUM is implicitly passed to the database language environments when it is defined in the macro.

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. The default value is 1.

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 | Index ]