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 / Funciones WLanguage
  • Triggers of the same type
  • Trigger on the functions for manipulating Table controls
  • Variables used to manage the 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
HDescribeServerTrigger (Function)
HFSQL Client/ServerDisponible solo con este tipo de conexión
Adds or modifies a server trigger. A server trigger is a stored procedure automatically called by the HFSQL engine whenever an HFSQL function is run.
Note Server trigger manipulation functions are advanced functions. The server triggers can be created directly in the data model editor. For more details, see Server triggers.
Ejemplo
// Create a data file
IF HCreation(Cedex) = False THEN
	Error(HErrorInfo())
ELSE
	Info("Data file created")
END
// Change data file directory
IF HChangeDir(Cedex, ".\FRANCE\") = False THEN Error(HErrorInfo())

// Create a trigger on an HFSQL Client/Server data file
IF HDescribeServerTrigger("CNX_TEST", "TriggerTEST", "ProcedureTEST", hTriggerAfter, ...
	"Cedex", "HAdd, HModify") = False THEN Error(HErrorInfo())
// Add records
Cedex.ZipCode = "30000"
Cedex.City = "NIMES"
HAdd(Cedex)
Cedex.ZipCode = "34000"
Cedex.City = "MONTPELLIER"
HAdd(Cedex)
Sintaxis

Describing a server trigger (logical files) Ocultar los detalles

<Result> = HDescribeServerTrigger(<Trigger> , <Stored procedure> , <Type of trigger> , <Logical HFSQL Client/Server files> [, <List of HFSQL functions>])
<Result>: Boolean
  • True if the operation was performed,
  • False if a problem occurs. HErrorInfo is used to identify the error.
<Trigger>: Character string
Name of the trigger to create. This name will be used to handle the trigger in the functions for managing server triggers.
<Stored procedure>: Procedure name
Name of the WLanguage stored procedure that will be run when activating the trigger. This procedure accepts no parameter.
<Type of trigger>: Integer constant
Indicates the type of trigger.
hTriggerAfterThe stored procedure is run after the HFSQL function.
hTriggerBeforeThe stored procedure is run before the HFSQL function.
<Logical HFSQL Client/Server files>: Character string
Logical name of one or more HFSQL Client/Server data files. To specify several names, the names of the data files must be separated by a comma (",").
<List of HFSQL functions>: Optional character string
Name of one or more HFSQL or TableXXX functions on which the trigger must be implemented. To specify several names of functions, the names of functions must be separated by a comma (","). You have the ability to define triggers on the following functions:Triggers are also run on INSERT queries (trigger of HAdd), UPDATE queries (trigger of HModify) and DELETE queries (trigger of HDelete).

Describing a server trigger on the physical files associated with a connection Ocultar los detalles

<Result> = HDescribeServerTrigger(<Connection> , <Trigger> , <Stored procedure> , <Type of trigger> [, <Physical HFSQL Client/Server files> [, <List of HFSQL functions>]])
<Result>: Boolean
  • True if the operation was performed,
  • False if a problem occurs. HError is used to identify the error.
<Connection>: Character string or Connection variable
Connection to use. This connection corresponds to:
<Trigger>: Character string
Name of the trigger to create. This name will be used to handle the trigger in the functions for managing server triggers.
<Stored procedure>: Procedure name
Name of the WLanguage stored procedure that will be run when activating the trigger. This procedure accepts no parameter.
<Type of trigger>: Integer constant
Type of trigger to create:
hTriggerAfterThe stored procedure is run after the HFSQL function
hTriggerBeforeThe stored procedure is run before the HFSQL function
<Physical HFSQL Client/Server files>: Optional character string
Physical name of one or more HFSQL Client/Server data files associated with the connection ("CUSTOMER.FIC" for example). To specify several names, the names of the data files must be separated by a comma (","). If this parameter is not specified or is an empty string (""), the trigger will be enabled on all the data files of the database.
<List of HFSQL functions>: Optional character string
Name of one or more HFSQL or TableXXX functions on which the trigger must be implemented. To specify several names of functions, the names of functions must be separated by a comma (","). You have the ability to define triggers on the following functions: Triggers are also run on INSERT queries (trigger of HAdd), UPDATE queries (trigger of HModify) and DELETE queries (trigger of HDelete).

Creating a trigger from the description in the analysis Ocultar los detalles

<Result> = HDescribeServerTrigger(<Connection> , <Trigger>)
<Result>: Boolean
  • True if the operation was performed,
  • False if a problem occurs. HError is used to identify the error.
<Connection>: Character string or Connection variable
Connection to use. This connection corresponds to:
<Trigger>: Character string
Name of the trigger described in the analysis.
Observaciones

Triggers of the same type

If several triggers of the same type are defined on the same data file for the same operation, these triggers will be run according to the alphabetical order of their names.

Trigger on the functions for manipulating Table controls

The table field manipulation functions (TableAdd, TableAddLine, TableDelete, TableModify, etc. ) implicitly use the following HFSQL functions: HAdd, HDelete and HModify.
When using one of these functions for manipulating Table controls, if a trigger is defined for the corresponding HFSQL function, the trigger is automatically activated.

Variables used to manage the triggers

A procedure (or stored procedure) of the trigger type receives no parameters. However, some HFSQL state variables are positioned before each call:
H.FileNameCharacter string: Logical name of the data file for which the trigger is activated.
Warning Depending on the logical name used by the application, the value of the variable H.FileName variable may be different (using aliases, for example). It is recommended to use:
  • MyFile.DescribedName to find out the logical name of the data file being manipulated (without taking aliases into account).
  • MyFile.PhysicalName to find out the physical name of the data file being manipulated.
H.ActionCharacter initialized to "A" for a Before trigger and to "P" for an After trigger.
H.TriggerFunctionString: Name of the HFSQL function that triggered the trigger.
Advertencia
The Variable H.FunctionTrigger is deprecated in favour of the variable H.FunctionTriggerNumber. The information given by the Variable is independent of the language used to run the application.
Novedad versión 2025
H.TriggerFunctionNumber
Constant used to identify the function that triggered the trigger:
  • htrgHAjoute The function that triggered the trigger is HAdd.
  • htrgHEcrit The function that triggered the trigger is HWrite.
  • htrgHModifies The function that triggered the trigger is HModify.
  • htrgHRaye The function that triggered the trigger is HCross.
  • htrgHSuppresses The function that triggered the trigger is HDelete.
H.ToDoDuring the execution of a before trigger:
  • cancelling the execution of the current HFSQL function by assigning "A" to the HFSQL state variable: H.ToDo = "A". In this case, the action is not performed and the function (HAdd, HModify, etc.) returns True (no error).
  • cancelling the execution of the ongoing HFSQL function by assigning "E" to the HFSQL state variable: H.AFaire = "E". In this case, the action is not performed and the function (HAdd, HModify, etc.) returns False. The error message reads: "Action on data file XXX has been interrupted by the trigger".

Note In the case where a "BEFORE" and an "AFTER" trigger are associated with an HFSQL function, if the "BEFORE" trigger cancels the execution of the HFSQL function (by setting H.AFaire to "A"), the "AFTER" trigger is not triggered.
Clasificación Lógica de negocio / UI: Lógica de negocio
Componente: wd300hf.dll
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: 12/06/2025

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