ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / HFSQL / Managing HFSQL Client/Server
  • Overview
  • Scheduled tasks in the HFSQL Control Center
  • Creating a scheduled task
  • Deleting a scheduled task
  • Modifying a scheduled task
  • Scheduled tasks programmatically
  • Creating a scheduled task
  • Scheduled task execution history
  • Handling scheduled tasks in WLanguage
  • Usage example of HDeclareExternal in a stored procedure
  • Example for running the test of a stored procedure
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
HFSQL Client/Server: Scheduled tasks
HFSQL Client/ServerAvailable only with this kind of connection
Overview
Scheduled tasks are used to schedule automated processes. You have the ability to define scheduled tasks on the HFSQL server. These scheduled tasks call a stored procedure.
By calling a stored procedure, you can execute the code of your choice, e.g. custom maintenance, editing statistics, etc.
The scheduled tasks can be managed:
Run several scheduled tasks in succession: If the previous scheduled task is not completed, the new scheduled task is not run, and a notification is sent by the server.
Scheduled tasks in the HFSQL Control Center

Creating a scheduled task

In the HFSQL Control Center, scheduled tasks can be defined at server or database level.
To create a scheduled task:
  1. If necessary, connect to an HFSQL server and display the description of the server or one of its databases (double-click on the server or database name in the tree structure).
  2. Click the "Scheduled elements" tab.
  3. In the ribbon, in the "Scheduled elements" group, expand "New scheduling" and select "Schedule a task". The wizard for creating a scheduled task starts.
  4. Select the task execution mode: the task can be executed:
    • Periodically. Then wizard allows you to define the runtime frequency of the task.
    • and/or whenever starting the HFSQL server. If this option is selected, you must specify whether:
      • the task is blocking: in this case, the HFSQL server will be inaccessible while the task is running..
      • the task must be run in the background: in this case, the HFSQL server can be used as soon as it starts up..
  5. Select:
    • the database containing the stored procedure to run.
    • the set containing the stored procedure to run.
    • the stored procedure to run.
      Caution: For a stored procedure launched from a scheduled task to access data, the HDeclareExternal function must be used.. This function is used to declare the data sources that will be used in the processes of the stored procedure. Indeed, when a stored procedure is launched from the HFSQL Control Center, there is no analysis in progress and HFSQL Client/Server data is not immediately accessible.
      If HDeclareExternal is not used in the code of the stored procedure, the procedure will trigger a fatal error, notified in the log of system events.
      Note: when a stored procedure is launched from a WINDEV, WEBDEV or WINDEV Mobile application using the HExecuteProcedure function, it uses the application's analysis and can therefore directly use HFSQL Client/Server data.
  6. Define task frequency: month, day, hour.
  7. Give your scheduled task a description and validate the wizard.
  8. The scheduled task appears in the "Scheduled items" tab of the HFSQL Control Center.

Deleting a scheduled task

To delete a scheduled task:
  1. If necessary, connect to an HFSQL server and display the appropriate server or database tab.
  2. Click the "Scheduled elements" tab.
  3. Select the scheduled task to delete.
  4. In the ribbon, in the "Scheduled elements" group, click "Delete".
    You also have the ability to use the context menu of the scheduled element ("Delete" option).

Modifying a scheduled task

To modify a scheduled task:
  1. If necessary, connect to an HFSQL server and display the appropriate server or database tab.
  2. Click the "Scheduled elements" tab.
  3. Select the scheduled task to modify.
  4. In the ribbon, in the "Scheduled elements" group, click "Edit".
    You also have the ability to use the context menu of the scheduled element ("Edit" option).
  5. A description window of the scheduled element is displayed. All the characteristics typed in the wizard are grouped in several tabs:
    • Tab "General": Defines whether the task is active and its type (backup or stored procedure).
    • Tab "Scheduling": Sets the execution options for the scheduled task (month, day, time, number of executions, execution at startup).
    • New in version 2025
      Tab "Execution History": This tab appears when the scheduled task has been executed automatically. This tab lists the different automation executions of the scheduled task, indicating:
      • the start date of the task,
      • task status: completed, in progress, error,
      • running time,
      • the user who launched the task,
      • if launched manually (via HExecuteScheduling).
  6. Validate.
Scheduled tasks programmatically

Creating a scheduled task

Scheduled tasks are managed programmatically using a hScheduledTask variable and several WLanguage functions.
To programmatically create a scheduled task:
  1. Create a variable of type hScheduledTask and describe the various characteristics of the scheduled task.
  2. Add the scheduled task using the HAddScheduling function (or the HAddTask function).
Remarks:
  • To add a scheduled task, you must have:
    • the rights to manage the tasks (hRightsManageTask constant).
    • the rights to run the command linked to the scheduled task.
  • The task will be performed with the identity of the user defined by the connection.
  • For compatibility, it is also possible to create a scheduled task for backing up the. However, it is advisable to create a scheduled backup. For more details, see How to backup HFSQL Client/Server databases?.
New in version 2025

Scheduled task execution history

An execution history is automatically recorded when the scheduled task is automatically executed (or when it is executed using the HExecuteScheduling function). This history can be manipulated programmatically, using a variable of type hSchedulingHistory and the following functions:
New in version 2025
HClearSchedulingHistory
Clears the execution history of scheduled operations on an HFSQL server.
New in version 2025
HDeleteSchedulingHistory
Deletes the executions of a scheduled operation on an HFSQL server. This operation can be a scheduled task (stored procedure), backup, optimization or a materialized view refresh.
New in version 2025
HListSchedulingHistory
Lists the executions of a scheduled operation on an HFSQL server. This operation can be a scheduled task (stored procedure), backup, optimization or a materialized view refresh.

Handling scheduled tasks in WLanguage

Scheduled tasks can be manipulated via:
  • scheduled task management functions:
    HAddTaskAdds a scheduled task on the server defined by the connection.
    HDeleteTaskDeletes a scheduled task from an HFSQL Client/Server server.
    HInfoTaskReturns the characteristics of a scheduled task in a hScheduledTask variable].
    HListTaskLists the scheduled tasks of an HFSQL Client/Server server for a given connection.
    HManageTaskEnables or disables a scheduled task on an HFSQL Client/Server server.
    HModifyTaskModifies a scheduled task on the HFSQL server defined by the connection.
  • planned item management functions (recommended):
    HAddSchedulingAdds a new scheduled item to an HFSQL server: scheduled task (stored procedure), backup, optimization or refresh of a materialized view.
    HDeleteSchedulingDelete a scheduled item on an HFSQL server: scheduled task (stored procedure), backup, optimization, refresh of a materialized view.
    HExecuteSchedulingImmediately executes a scheduled item regardless of its scheduling: scheduled task (stored procedure), backup, optimization, refresh of a materialized view.
    HListSchedulingLists scheduled elements defined on an HFSQL server: scheduled tasks (stored procedure), backup, optimization, refresh of a materialized view.
    HModifySchedulingModify a scheduled item on an HFSQL server: scheduled task (stored procedure), backup, optimization, refresh of a materialized view.
Usage example of HDeclareExternal in a stored procedure
The following procedure declares a data file with HDeclareExternal in order to be able to use it in a scheduled task:
PROCEDURE NameOfStoredProcedure()

// Check the existence of the logical file
IF NOT HFileExist(MyConnection, ZIPCODES) THEN
	// File not known, it must be declared
	// Caution: to declare a new file in a stored HFSQL procedure, you must:
	// - DO NOT use a connection: This is the current base on which the 
	//		the stored procedure is found will be used
	// - DO NOT give a full path: the file will be searched in the current database.. 
	//		You have the ability to specify a subdirectory of the database. 
	//  - specify the full name of the file with its extension (.FIC)
	IF NOT HDeclareExternal("ZIPCODES.FIC", "ZIPCODES") THEN
		// Error while declaring the file
		RETURN HErrorInfo()
	END
END

// Use the data file
// FOR EACH ZIPCODES 
//	//Process...
// END

// Process OK, without error
RETURN ""
Example for running the test of a stored procedure
The following code is used to run the test of a stored procedure in conditions similar to the ones of its execution in a schedules task:
// Close the current analysis (the scheduled task has no current analysis)
HCloseAnalysis()
// Declare the connection to the HFSQL database 
// This database contains the stored procedure
cntStockedHFSQLProcedure is Connection
cntStockedHFSQLProcedure.Provider = hAccessHFClientServer
cntStockedHFSQLProcedure.User = "ADMIN"
cntStockedHFSQLProcedure.Password = ""
cntStockedHFSQLProcedure.Server = "ServerName:4900"
cntStockedHFSQLProcedure.Database = "DatabaseName"
// Establish the connection with the HFSQL database
HOpenConnection(cntStockedHFSQLProcedure)
IF ErrorOccurred = True THEN
	Error("Failure establishing the connection to the HFSQL database", HErrorInfo())
	RETURN
END
// Run the HFSQL stored procedure and retrieve its result
sRes is string
sRes = HExecuteProcedure(cntStockedHFSQLProcedure, "StoredProcedureName")
// Exploit the result
...
Minimum version required
  • Version 10
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 02/19/2025

Send a report | Local help