|
|
|
|
|
- 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
HFSQL Client/Server: Scheduled tasks
Available only with this kind of connection
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: - 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).
- Click the "Scheduled elements" tab.
- In the ribbon, in the "Scheduled elements" group, expand "New scheduling" and select "Schedule a task". The wizard for creating a scheduled task starts.
- 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..
- 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.
- Define task frequency: month, day, hour.
- Give your scheduled task a description and validate the wizard.
- The scheduled task appears in the "Scheduled items" tab of the HFSQL Control Center.
Deleting a scheduled task To delete a scheduled task: - If necessary, connect to an HFSQL server and display the appropriate server or database tab.
- Click the "Scheduled elements" tab.
- Select the scheduled task to delete.
- 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: - If necessary, connect to an HFSQL server and display the appropriate server or database tab.
- Click the "Scheduled elements" tab.
- Select the scheduled task to modify.
- 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). - 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 2025Tab "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).
- 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: - Create a variable of type hScheduledTask and describe the various characteristics of the scheduled task.
- 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 2025Scheduled 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:
| | | Clears the execution history of scheduled operations on an HFSQL server. | | 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. | | 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:
| | HAddTask | Adds a scheduled task on the server defined by the connection. | HDeleteTask | Deletes a scheduled task from an HFSQL Client/Server server. | HInfoTask | Returns the characteristics of a scheduled task in a hScheduledTask variable]. | HListTask | Lists the scheduled tasks of an HFSQL Client/Server server for a given connection. | HManageTask | Enables or disables a scheduled task on an HFSQL Client/Server server. | HModifyTask | Modifies a scheduled task on the HFSQL server defined by the connection. |
- planned item management functions (recommended):
| | HAddScheduling | Adds a new scheduled item to an HFSQL server: scheduled task (stored procedure), backup, optimization or refresh of a materialized view. | HDeleteScheduling | Delete a scheduled item on an HFSQL server: scheduled task (stored procedure), backup, optimization, refresh of a materialized view. | HExecuteScheduling | Immediately executes a scheduled item regardless of its scheduling: scheduled task (stored procedure), backup, optimization, refresh of a materialized view. | HListScheduling | Lists scheduled elements defined on an HFSQL server: scheduled tasks (stored procedure), backup, optimization, refresh of a materialized view. | HModifyScheduling | Modify 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()
IF NOT HFileExist(MyConnection, ZIPCODES) THEN
IF NOT HDeclareExternal("ZIPCODES.FIC", "ZIPCODES") THEN
RETURN HErrorInfo()
END
END
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:
HCloseAnalysis()
cntStockedHFSQLProcedure is Connection
cntStockedHFSQLProcedure.Provider = hAccessHFClientServer
cntStockedHFSQLProcedure.User = "ADMIN"
cntStockedHFSQLProcedure.Password = ""
cntStockedHFSQLProcedure.Server = "ServerName:4900"
cntStockedHFSQLProcedure.Database = "DatabaseName"
HOpenConnection(cntStockedHFSQLProcedure)
IF ErrorOccurred = True THEN
Error("Failure establishing the connection to the HFSQL database", HErrorInfo())
RETURN
END
sRes is string
sRes = HExecuteProcedure(cntStockedHFSQLProcedure, "StoredProcedureName")
...
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|