ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

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
  • Manipulating 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:
Successive execution of multiple scheduled tasks: If the previous scheduled task is not completed, the new scheduled task is not executed, and the server sends a notification.
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 open the description of the server or one of its databases (double-click 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 how often the task is executed.
    • and/or whenever starting the HFSQL server. If this option is selected, you must specify whether:
      • the task blocks other tasks. In this case, the HFSQL server will be inaccessible while the task is running.
      • the task should 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.
      Note: To grant data access to a stored procedure launched from a scheduled task, you must use the HDeclareExternal function. This function is used to declare the data sources that will be used in the processes of the stored procedure. When a stored procedure is launched from the HFSQL Control Center, there is no current analysis and HFSQL Client/Server data is not 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 started with HExecuteProcedure from a WINDEV, WEBDEV or WINDEV Mobile application, it uses the analysis of the application and can directly use the HFSQL Client/Server data.
  6. Define the task frequency: month, day, hour.
  7. Give your scheduled task a description and confirm.
  8. The scheduled task appears in the "Scheduled elements" tab of the HFSQL Control Center.

Deleting a scheduled task

To delete a scheduled task:
  1. If necessary, connect to an HFSQL server and open the corresponding 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 open the corresponding 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:
    • "General" tab: Defines the task type (backup or stored procedure) and its status (active or inactive).
    • "Schedule" tab: Sets the execution options for the scheduled task (month, day, time, number of executions, execution at startup).
    • New in version 2025
      "Run history" tab: This tab appears once the scheduled task has been executed automatically. This tab lists the different executions of the scheduled task, indicating:
      • task start date,
      • task status: completed, in progress, failed,
      • running time,
      • user who launched the task,
      • if it was launched manually (with HExecuteScheduling).
  6. Validate.
Scheduled tasks programmatically

Creating a scheduled task

Scheduled tasks are managed programmatically using variables of type hScheduledTask and several WLanguage functions.
To programmatically create a scheduled task:
  1. Create a variable of type hScheduledTask and define the various characteristics of the scheduled task.
  2. Add the scheduled task HAddScheduling (or HAddTask).
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 executed with the user credentials defined by the connection.
  • For compatibility reasons, it is also possible to create a scheduled task for backing up the database. However, it is recommended to create a scheduled backup. For more details, see How to backup HFSQL Client/Server databases?.
New in version 2025

Scheduled task execution history

A history is created when the scheduled task is executed automatically (or with HExecuteScheduling). 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 jobs on an HFSQL server.
New in version 2025
HDeleteSchedulingHistory
Deletes the executions of a scheduled job on an HFSQL server. This job 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 job on an HFSQL server. This job can be a scheduled task (stored procedure), backup, optimization or a materialized view refresh.

Manipulating scheduled tasks in WLanguage

Scheduled tasks can be manipulated using:
  • scheduled task 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.
  • scheduled element 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: The current database on which 
	//		the stored procedure is found will be used
	// - DO NOT specify 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: 04/07/2025

Send a report | Local help