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 / Funciones HFSQL
  • Trigger on the functions for manipulating Table controls
  • Variables used to manage the triggers
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Adds or modifies a trigger on an HFSQL data file. A trigger is a WLanguage procedure automatically called by the HFSQL engine whenever an HFSQL function is run. UPDATE, INSERT and DELETE queries also trigger execution of the trigger (note: the trigger is not triggered on tables accessed via a Native Connector).
For more details, see Managing triggers.
HFSQL ClassicHFSQL Client/Server This function is only available on the client side. Use <Connection variable>.DescribeServerTrigger to define a server trigger for an HFSQL Client/Server database.
Example
// Dans le code d'initialisation du projet
LOCAL
	ResultatTrigger is boolean
// Création du Trigger pour le fichier de données Client
ResultatTrigger = Client.DécritTrigger("HAJOUTE,HMODIFIE,HSUPPRIME,HRAYE,HECRIT", ...
	"VerifDroitUtilisateur", hTriggerBefore)
// Avec "VerifDroitUtilisateur" une procédure globale du projet
IF ResultatTrigger = False THEN
	 Error("Erreur sur un trigger : " + HErrorInfo)
	 RETURN
END
Syntax
<Result> = <HFSQL data file>.DescribeTrigger(<List of HFSQL functions> , <WLanguage procedure> , <Type of trigger>)
<Result>: Boolean
  • True if the operation was performed,
  • False if a problem occurs. HErrorInfo is used to identify the error.
<HFSQL data file>: Name of data file
Logical name of an HFSQL data file.
<List of HFSQL functions>: 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:
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure that will be run when a trigger is activated on the specified HFSQL functions.
<Type of trigger>: Integer constant
Indicates the type of trigger.
hTriggerAfterThe procedure is run after the HFSQL function.
hTriggerBeforeThe procedure is run before the HFSQL function.
Remarks

Trigger on the functions for manipulating Table controls

Table field manipulation functions (<Table>.Add, <Table>.AddLine, <Table>.Delete, <Table>.Modify, etc.) implicitly use the following HFSQL functions: <Source>.Add, <Source>.Delete and <Source>.Modify.
When using one of these functions for handling tables, 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.
Warning
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.
New in version 2025
H.TriggerFunctionNumber
Constant used to identify the function that triggered the trigger:
  • htrgHAjoute The function that triggered the trigger is <Source>.Add.
  • htrgHEcrit The function that triggered the trigger is <Source>.Write.
  • htrgHModifies The function that triggered the trigger is <Source>.Modify.
  • htrgHRaye The function that triggered the trigger is <Source>.Cross.
  • htrgHSuppresses The function that triggered the trigger is <Source>.Delete.
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.
Component: wd300hf.dll
Versión mínima requerida
  • Versión 25
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