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 PostgreSQL
  • 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
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
PostgreSQL Native Connector: Programming with HFSQL functions
Native Connectors (Native Accesses)Available only with this kind of connection
Overview
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.
Remark: Queries executed with HExecuteQuery and HExecuteSQLQuery are automatically "corrected" to be compatible with PostgreSQL.
Importing the structure of files

The import steps

To perform this import:
  1. Launch the data model editor: click on Load project analysis among the quick access buttons.
  2. On the "Analysis" tab, in the "Creation" group, expand "Import" and select "Import file/table descriptions...".
  3. 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 "Analysis" pane, in the "Analysis" group, pull 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 PostgreSQL tables.
Programming

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

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, "PostgreSQLDatabase", hQueryWithoutCorrection)
HExecuteSQLQuery(QryCustomer, "PostgreSQLDatabase", hQueryWithoutCorrection, "SELECT NAME FROM CUSTOMER")

3. Retrieving the result

The result is browsed using all the classic read functions: HReadFirst, HReadNext, HReadSeek, ...
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.
Versión mínima requerida
  • Versión 9
Comentarios
Como referenciar a uma porta diferente
https://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/4122-atencao-versao-28-driver-nativo-postgresql-teve-uma/read.awp
Boller
06 06 2023

Última modificación: 11/01/2025

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