template::paginator::get_data (public)

 template::paginator::get_data statement_name name datasource query \
    id_column page

Defined in packages/acs-templating/tcl/paginator-procs.tcl

Sets a multirow data source with data for the rows on the current page. The pseudocolumn "all_rownum" is added to each row, indicating the index of the row relative to all rows across all pages.

Parameters:
statement_name (required)
name (required)
The reference to the paginator object.
datasource (required)
The name of the datasource to create.
query (required)
The query to execute, containing IN (CURRENT_PAGE_SET).
id_column (required)
The name of the ID column in the display query (required to order rows properly).
page (required)

Partial Call Graph (max 5 caller/called nodes):
%3 ns_dbquotelist ns_dbquotelist template::paginator::get_row template::paginator::get_row (public) template::paginator::get_row_ids template::paginator::get_row_ids (public) template::util::list_to_lookup template::util::list_to_lookup (public) template::paginator::get_data template::paginator::get_data template::paginator::get_data->ns_dbquotelist template::paginator::get_data->template::paginator::get_row template::paginator::get_data->template::paginator::get_row_ids template::paginator::get_data->template::util::list_to_lookup

Testcases:
No testcase defined.
Source code:
    set ids [get_row_ids $name $page]

    # calculate the base row number for the page
    upvar 2 __page_firstrow firstrow
    set firstrow [get_row $name $page]

    # build a hash of row order to order the rows on the page
    upvar 2 __page_order row_order
    template::util::list_to_lookup $ids row_order

    # substitute the current page set
    if { $query eq "" } {
        set query [uplevel 2 "db_map ${statement_name}_partial"]
    }

    set in_list [::ns_dbquotelist $ids]
    if { ! [regsub CURRENT_PAGE_SET $query $in_list query] } {
        error "Token CURRENT_PAGE_SET not found in page data query  ${statement_name}_partial: $query"
    }

    if {$in_list eq ""} {
        uplevel 2 "set $datasource:rowcount 0"
        return
    }



    # execute the query such that the unsorted data source is created in the
    # current stack frame.  Generate a multirow data source in the calling
    # stack frame as we go, using the order lookup created above to ensure
    # that the rows are properly sorted.  Do it in the calling stack frame
    # so that bind variables may be used.
    uplevel 2 "

    set __page_cnt 0
    db_foreach $statement_name \"$query\" -column_array row {
        incr __page_cnt
        set i \$__page_order(\$row($id_column))
        upvar 0 $datasource:\$i __page_sorted_row
        array set __page_sorted_row \[array get row\]
        set __page_sorted_row(rownum) \[expr \$i + \$__page_firstrow - 1\]
    }

    set $datasource:rowcount \${__page_cnt}
    "

    #   uplevel 2 "

    #     db_multirow __page_data $statement_name \"$query\" {
    #       set i \$__page_order(\$row($id_column))
    #       upvar 0 $datasource:\$i __page_sorted_row
    #       array set __page_sorted_row \[array get row\]
    #       set __page_sorted_row(rownum) \[expr \$i + \$__page_firstrow - 1\]
    #     }

    #     set $datasource:rowcount \${__page_data:rowcount}
    #   "
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
packages/acs-templating/tcl/paginator-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: