Report Layout
myDBR handles report layout automatically, centering elements by default. When a report includes multiple result sets, each is treated as a separate block and centered below the previous one.
You can easily arrange elements side-by-side using the dbr.keepwithnext command. An optional parameter allows you to define the spacing around these elements.
A common layout requirement is to place elements side-by-side within a report. In the following example, we have four result sets that we want to position in a 2x2 grid.
create procedure sp_DBR_Layout()
begin
select 'First result set' as 'First';
select 'Second result set' as 'Second';
select 'Third result set' as 'Third';
select 'Fourth result set' as 'Fourth';
end
Arranging Elements Side-by-Side
The dbr.keepwithnext command should be placed before the first element in a row.
create procedure sp_DBR_Layout()
begin
select 'dbr.keepwithnext';
select 'First result set' as 'First';
select 'Second result set' as 'Second';
select 'dbr.keepwithnext';
select 'Third result set' as 'Third';
select 'Fourth result set' as 'Fourth';
end
The resulting report will look like this:
Using Templates for Advanced Layouts
For full control over data presentation, use templates via the dbr.template command. A template is an HTML/CSS/JavaScript block containing placeholders for your data. Using templates allows you to separate layout logic from data retrieval, significantly simplifying report maintenance.
Custom Layouts with HTML
If you need to insert basic HTML directly into your report, you can use the dbr.html command, for example, to wrap result sets in an HTML table. Note that templates are preferred for complex layouts to ensure maintainability. The following example demonstrates result sets placed side-by-side with a custom margin:
create procedure sp_DBR_Layout()
begin
select 'dbr.html', '<table class="center"><tr valign=top><td>';
select 'First result set' as 'First';
select 'dbr.html', '</td><td width="50px"></td><td>';
select 'Second result set' as 'Second';
select 'dbr.html', '</td></tr><tr><td>';
select 'Third result set' as 'Third';
select 'dbr.html', '</td><td width="50px"></td><td>';
select 'Fourth result set' as 'Fourth';
select 'dbr.html', '</td></tr></table>';
end
Let's examine the layout commands:
select 'dbr.html', '<table class="center"><tr valign=top><td>';
This initializes an HTML table with the center class (refer to userstyle.css for details) and valign="top" to align result sets at the top. The final <td> tag opens the container for the first result set.
select 'dbr.html', '</td><td width="50px"></td><td>';
This closes the first cell and creates a 50-pixel spacer before opening the next cell. Finally, the table structure is closed:
select 'dbr.html', '</td></tr></table>';
The resulting layout will look like this: