db_multirow_group_last_row_p (public)
db_multirow_group_last_row_p -column column
Defined in packages/acs-tcl/tcl/01-database-procs.tcl
Used inside the code_block to db_multirow to ask whether this row is the last row before the value of 'column' changes, or the last row of the result set.
This is useful when you want to build up a multirow for a master/slave table pair, where you only want one row per row in the master table, but you want to include data from the slave table in a column of the multirow.
Here's an example:
# Initialize the lines variable to hold a list of order line summaries set lines [list] # Start building the multirow. We add the dynamic column 'lines_pretty', which will # contain the pretty summary of the order lines. db_multirow -extend { lines_pretty } orders select_orders_and_lines { select o.order_id, o.customer_name, l.item_name, l.quantity from orders o, order_lines l where l.order_id = o.order_id order by o.order_id, l.item_name } { lappend lines "$quantity $item_name" if { [db_multirow_group_last_row_p -column order_id] } { # Last row of this order, prepare the pretty version of the order lines set lines_pretty [join $lines ", "] # Reset the lines list, so we start from a fresh with the next row set lines [list] } else { # There are yet more order lines to come for this order, # continue until we've collected all the order lines # The 'continue' keyword means this line will not be added to the resulting multirow continue } }
- Switches:
- -column (required)
- The name of the column defining the groups.
- Returns:
- 1 if this is the last row before the column value changes, 0 otherwise.
- Author:
- Lars Pind <lars@collaboraid.biz>
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.