AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / Conectores Nativos/Accesos Nativos / Conector Nativo DB2
  • Overview
  • Importing the structure of files
  • The import steps
  • Taking into account the evolution of the DB2 database
  • Programming
  • 1. Opening the connection
  • 2. Running queries
  • 3. Retrieving the result
  • 4. Closing the connection
  • Optimizing HFSQL functions
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
DB2 Native Connector: Programming with HFSQL functions
Conectores NativosDisponible solo con este tipo de conexión
Overview
To use a DB2 database with the Native Access Connector, you need to import the DB2 table structure into the WINDEV or WEBDEVanalysis. .
Differences from SQL programming: To manipulate DB2 data, queries are not mandatory. In fact, you can directly use HFSQL functions to read your data, perform searches and filters, etc. However, it is necessary to import the DB2 file structure into the WINDEV or WEBDEV analysis.
Importing the structure of files

The import steps

  1. Launch the data model editor: click on Load project analysis among the quick access buttons.
  2. On the "Análisis" tab, in the "Creación" group, expand "Importar" and select "Import file/table descriptions...".
  3. 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 programmatically.
In the different steps of the wizard, choose the following options:
  • Database type: DB2.
  • Connection features: 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 through 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 account of changes to tables imported into the data model editor, in the "Análisis" pane, in the "Análisis" group, pull down "Sincronización " 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.
Programming

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 (username or password for example), call HConnect.
Note If you try to read the file directly (function HReadFirstfunction, etc.), the connection associated with the file description in the analysis will be opened automatically.

2. Running queries

HExecuteQuery and HExecuteSQLQuery are used to run queries on the current database.
  • HEExecuteQuery: executes a predefined query using the query editor.
  • HExecuteQuerySQL: allows you to execute a query by directly specifying the query's SQL code and the name to be allocated to this SQL code.
// Initialize the "Customer_84" query
HExecuteQuery(CUSTOMER_84, "DB2Database", hQueryWithoutCorrection)
HExecuteSQLQuery(CustomerQry, "DB2Database", hQueryWithoutCorrection, ...
		"SELECT NAME FROM CUSTOMER")

3. Retrieving the result

The result is browsed using all the classic read functions: HReadFirst, HReadNext, HReadSeek, ...

4. Closing the connection

HCloseConnection is used to close the connection to the database once all the necessary queries have been run.

Optimizing HFSQL functions

  • Table control based on a data file is optimized. You can sort the contents of a Table control by clicking on 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).
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 11/01/2025

Señalar un error o enviar una sugerencia | Ayuda local