While using SQL to perform database queries is most common, it is important to understand that almost any SQL statement can be invoked from Net.data. This is because Net.data has been built to support various language environments and SQL is just one of them. In essence, Net.data simply reads any SQL statement that you embed in a DTW_SQL function block and passes it to the native SQL environment for execution. A convenient technique is to first test an SQL statement by starting interactive SQL from a green green, STRSQL, entering the SQL statement there and when satisified cut and paste it into a Net.data SQL block.
%html(macro) {
<center>
<b>SQL Demo Example 4
<p>Deleting stored procedure QGPL/DEMOPROC01
@deleteProc()
<p>Creating stored procedure QGPL/DEMOPROC01
@createProc()
<p>Executing stored procedure QGPL/DEMOPROC01
@runProc()
<p>List database file QGPL/SQLDEMOTBL created by DEMOPROC01
@list()
</center>
%}
Prior to the %html block there are 4 DTW_SQL function blocks defined.
Each of these functions is executed within the %html block. However, only the final
@list function generates any output. The preceding functions manage the creation
and execution of an SQL PROCEDURE.
The aim of this example is to create an SQL PROCEDURE named DEMOPROC01
whose purpose is to create a database table name SQLDEMOTBL in QGPL and also
populate it with some test records. The resulting database table is subsequently
displayed using the @list() function.
Deleting stored procedure QGPL/DEMOPROC01
Creating stored procedure QGPL/DEMOPROC01
Executing stored procedure QGPL/DEMOPROC01
List database file QGPL/SQLDEMOTBL created by DEMOPROC01
CLIENTNO | AREA | CLIENTNAME | ------------------------------- 1001 | CA | JOHN DOE | ------------------------------- 1010 | DC | FANNY MAE | -------------------------------