|
|
|
|
|
- Overview
- Importing the structure of files
- The import steps
- Taking into account the evolution of PostgreSQL database
- Programming
- 1. Establishing the connection
- 2. Running queries
- 3. Retrieving the result
- 4. Closing the connection
PostgreSQL Native Connector: Programming with HFSQL functions
Disponible solo con este tipo de conexión
To use a PostgreSQL database with the Native Access Connector, you need to import the PostgreSQL table structure into the WINDEV or WEBDEVanalysis. . Differences compared to SQL programming: Queries are not required to manipulate PostgreSQL data. You can use HFSQL functions directly to read data, search, apply filters, etc. However, the structure of PostgreSQL files must be imported into the WINDEV or WEBDEV analysis. Importing the structure of files The import steps To perform this import: - Launch the data model editor: click on
among the quick access buttons. - On the "Análisis" tab, in the "Creación" group, expand "Importar" and select "Import file/table descriptions...".
- The wizard starts. A connection to the PostgreSQL database is automatically established and associated with the data files imported into the analysis. This connection will have to be used to handle the PostgreSQL data file programmatically.
In the different steps of the wizard, choose the following options:- Database type: PostgreSQL.
- 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 PostgreSQL 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 PostgreSQL tables.
1. Establishing the connection To establish the connection to the PostgreSQL database, call HOpenConnection and specify the name of the connection to open. The connection name was defined when importing the structure of files into the analysis. Caution: If you use another syntax, the name of the database to be used must be specified. To modify some parameters of this connection (username or password for example), call HConnect. Remarks: - If you try to read the file directly (HReadFirst, ...), the connection associated with the file description in the analysis will be automatically opened.
- You have the ability to set the "Server Port" for the connection to the PostgreSQL server. Simply add the corresponding string to the extended information of the connection (HDescribeConnection or HOpenConnection).
- Example 1: "Server Port=3306;" to connect to port 3306 on the PostgreSQL server.
- Example 2: "Server Port=3306; Client Flag=0;"
- ...
For more details, see the documentation about PostgreSQL.
- The management mode of the Unicode items can be configured during the connection.
To use Unicode strings, the "UTF8" charset must be specified when creating the PostgreSQL database. Warning: in this case, all channels will be Unicode channels.. To manage the Unicode items, the "WD Unicode Support" option must be added into the extended information of the connection (HDescribeConnection or HOpenConnection). If "WD Unicode Support = 0", the management of the Unicode format is disabled for the connection. All the values will be converted (if necessary) by the server into the default character set. In this case, the performance is improved but the Unicode items are not supported. If "WD Unicode Support = 1" (default value), the management of the Unicode format is enabled for the connection. All the exchanges with the server will be performed in Unicode. The Native Connector manages the necessary conversions by using the character set defined by ChangeCharset. Caution: The ChangeCharset function must be used BEFORE opening the connection.. The connection must be closed and reopened after each call to ChangeCharset in order for the data to be properly converted to the specified character set.
2. Running queries - 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.
HExecuteQuery(CUSTOMER_84, "PostgreSQLDatabase", hQueryWithoutCorrection)
HExecuteSQLQuery(QryCustomer, "PostgreSQLDatabase", hQueryWithoutCorrection, "SELECT NAME FROM CUSTOMER")
3. Retrieving the result In this version, the records cannot be locked by the lock options of these functions. Only the locks set with SQLLock are supported. 4. Closing the connection HCloseConnection is used to close the connection to the database once all the necessary queries have been run.
Esta página también está disponible para…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|