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 / WLanguage / Administrar bases de datos / HFSQL / Gestión de desencadenadores
  • Definition
  • Using triggers
  • Relevant databases
  • HFSQL Classic and HFSQL Client/Server
  • Benefits
  • Available types of triggers
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
Definition
A trigger is a WLanguage procedure automatically called by the HFSQL engine whenever a modification is performed (addition, deletion, modification, ...) on a record of a data file.
A trigger is used to associate a WLanguage process with one or more HFSQL functions without having to worry about the location of these functions in the code. The triggers associated with the HFSQL functions used are run even for the windows or for the code created by a wizard.
Using triggers

Relevant databases

The triggers can be applied to all types of data files:
  • HFSQL Classic,
  • HFSQL Client/Server,
  • Native Connectors (Oracle, AS/400, etc.),
  • ODBC,
  • OLE DB, ...

HFSQL Classic and HFSQL Client/Server

HFSQL Classic and HFSQL Client/Server allow you to define the triggers.
In HFSQL Classic mode, the triggers are handled through programming via the WLanguage functions. These triggers can be used on all the databases. For more details, see The triggers.
In Server mode, two types of triggers are available:
  • The triggers run on the client. These triggers are equivalent to the Classic mode and they are handled programmatically.
  • The Server triggers run on the server. These triggers are associated with the stored procedures found on the server. These triggers are directly defined in the analysis (for an advanced use, they can also be defined and handled through programming). For more details, see The server triggers.
Note: Triggers and threads If functions trigger triggers in different threads, the procedure executed in the trigger uses the HFSQL context corresponding to that of the current function (one HFSQL context per thread).

Benefits

Using a trigger allows you to:
  • Reduce the code size. For example, using a trigger allows you to group the processes associated with one or more HFSQL functions (check for duplicates, consistency of data, ...).
  • Make the code easier to read.
  • Simplify the future evolutions of the application.
Warning A file modification via a request does not trigger the client triggers (constant hFileModify used in HExecuteQuery).
Available types of triggers
Two types of triggers are available:
  • The "BEFORE" triggers:
    A "BEFORE" trigger is called before the execution of a FSQL function (HAdd, HModify, HDelete, ...) or before the execution of a function for managing the Table controls based on a data file.
    A "BEFORE" trigger can be used for example to check the consistency of data for the items of a record. With this type of trigger, an HFSQL variable can be initialized in order to cancel the execution of the associated HFSQL function.
  • The "AFTER" triggers:
    An "AFTER" trigger is called after the execution of an HFSQL function (except if the program was interrupted during the execution of this function) or after the execution of a function for managing the Table controls based on a data file.
    An "AFTER" trigger can be used to manage the process of errors for example.
Versión mínima requerida
  • Versión 12
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

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