- Importing the structure of files
- The import steps
- Taking into account the evolution of the DB2 database
- 1. Opening the connection
- 2. Running queries
- 3. Retrieving the result
- 4. Closing the connection
- Optimizing HFSQL functions
Native DB2 Connector: Programming with HFSQL functions
Available only with this kind of connection
To use a DB2 database with Native Connector (also called "Native Access"), the structure of DB2 tables must be imported into the WINDEV or WEBDEV analysis
Differences compared to SQL programming: The queries are not required to handle the DB2 data. Indeed, the HFSQL functions can be directly used to read data, perform searches, implement filters, ... However, the structure of DB2 files must be imported into the WINDEV or WEBDEV analysis.
Remark: From version 19, HFSQL is the new name of HyperFileSQL.
Importing the structure of files
The import steps
- Start the data model editor: click on among the quick access buttons.
- Under the "Analysis" pane, in the "Creation" group, scroll down "Import" and select "Import file/table descriptions".
- The wizard starts. A connection to the DB2 database is automatically established and it is associated with the files imported into the analysis. This connection will have to be used to handle the DB2 data file by programming.
In the different wizard screens, choose the following options:
- Type of database: DB2.
- Characteristics of the connection: Data server, User and password, database.
- The application will access the data in the current format.
- When the connection is established, all you have to do is select the tables that will be imported into the WINDEV or WEBDEV analysis. These tables can be handled by programming with the HFSQL functions of WLanguage. These tables will be displayed in blue in the data model editor.
Taking into account the evolution of the DB2 database
To take into account the evolutions of the tables imported in the analysis editor, under the "Analysis" pane, in the "Analysis" group, scroll down "Synchronization" and select "Update analysis from external databases".
A wizard starts, allowing you to:
- analyze the differences for the imported tables,
- analyze the differences for all the DB2 tables.
1. Opening the connection
To open the connection to the DB2 database, use HOpenConnection
and specify the name of the connection to open. The connection name was defined when importing the structure of files into the analysis.
To modify some parameters of this connection (user name or password for example), call HConnect
Remark: If you try to read the file directly (HReadFirst, ...), the connection associated with the file description in the analysis will be automatically opened.
2. Running queries
- HExecuteQuery: is used to run a preset query with the query editor.
- HExecuteSQLQuery: is used to run a query by specifying the SQL code of query and the name that will be assigned to this SQL code.
// Initialize the "Customer_84" query
HExecuteQuery(CUSTOMER_84, "DB2Database", hQueryWithoutCorrection)
HExecuteSQLQuery(CustomerQry, "DB2Database", hQueryWithoutCorrection, ...
"SELECT NAME FROM CUSTOMER")
4. Closing the connection
is used to close the connection to the database when all the necessary queries have been run.
Optimizing HFSQL functions
- The "Browsing table" controls based on queries are optimized: the content of the Table control can be sorted by clicking one of its columns.
- To avoid re-running the same query several times when browsing its result, we advise you to use the hNoRefresh constant (if the data is modified by a single computer for example).
This page is also available for…
Click [Add] to post a comment