The most predominant use of Net.data is for displaying content from the database using SQL select statements.
%function(dtw_sql) list() {
SELECT * FROM QIWS/QCUSTCDT WHERE CDTDUE > 0
%}
%html(macro) {
@list()
%}
The complete source code and be viewed at sqldemo1.
CUSNUM | LSTNAM | INIT | STREET | CITY | STATE | ZIPCOD | CDTLMT | CHGCOD | BALDUE | CDTDUE | --------------------------------------------------------------------------------------------------------- 938485 | Johnson | J A | 3 Alpine Way | Helen | GA | 30545 | 9999 | 2 | 3987.50 | 33.50 | --------------------------------------------------------------------------------------------------------- 389572 | Stevens | K L | 208 Snow Pass | Denver | CO | 80226 | 400 | 1 | 58.75 | 1.50 | --------------------------------------------------------------------------------------------------------- 475938 | Doe | J W | 59 Archer Rd | Sutter | CA | 95685 | 700 | 2 | 250.00 | 100.00 | --------------------------------------------------------------------------------------------------------- 192837 | Lee | F L | 5963 Oak St | Hector | NY | 14841 | 700 | 2 | 489.50 | .50 | ---------------------------------------------------------------------------------------------------------You can see that displaying a database file can be accomplished with just a couple of statements using Net.data. The response has been automatically formatted into the default fixed grid format by Net.data. This has been achieved by using a Net.data %function block. Net.data just needs to know the environment in which to execute the function, DTW_SQL, in this case, and the statement to be executed, an SQL select in this case. You can see that the syntax for invoking the function is to place the function name prefixed with the @ token somewhere within the %html block. The function block itself must be defined prior to the %html block. This is because Net.data interprets the source code from the top down, loading up function blocks as it goes, which means a function must have been loaded before Net.data encounters a line with the syntax to execute the function, in this case, @list().
%function(dtw_sql) list() {
SELECT CUSNUM, LSTNAM, INIT, STREET, CITY
FROM QIWS/QCUSTCDT WHERE CDTDUE > 0
%report { <table border="2" cellspacing="2" cellpadding="2"
style="border-collapse: collapse; border: solid 1pt black;">
%row { <tr>
<td>$(V1)</td>
<td>$(V2)</td>
<td>$(V3)</td>
<td>$(V4)</td>
<td>$(V5)</td>
</tr>
%} </table>
%}
%}
The complete source code and be viewed at sqldemo2
| 938485 | Johnson | J A | 3 Alpine Way | Helen |
| 389572 | Stevens | K L | 208 Snow Pass | Denver |
| 475938 | Doe | J W | 59 Archer Rd | Sutter |
| 192837 | Lee | F L | 5963 Oak St | Hector |
<tr>
<$(N1)</td>
<$(N2)</td>
<$(N3)</td>
<$(N4)</td>
<$(N5)</td>
</tr>
The complete source code and be viewed at sqldemo3
| CUSNUM | LSTNAM | INIT | STREET | CITY |
| 938485 | Johnson | J A | 3 Alpine Way | Helen |
| 389572 | Stevens | K L | 208 Snow Pass | Denver |
| 475938 | Doe | J W | 59 Archer Rd | Sutter |
| 192837 | Lee | F L | 5963 Oak St | Hector |