|
|
|
|
- Overview
- Scheduled tasks in the HFSQL Control Center
- Creating a scheduled task
- Deleting a scheduled task
- Modifying a scheduled task
- Scheduled tasks through programming
- Remarks
- 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
The scheduled tasks are used to schedule automatic tasks. You have the ability to define scheduled tasks on the HFSQL server. These scheduled tasks can correspond to: - the call to a stored procedure,
- the backup of the database.
The call to a stored procedure is used to run the code of your choice, for example custom maintenance, editing statistics, ... 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, the scheduled tasks can be defined at server level. To create a scheduled task: - Connect (if necessary) to an HFSQL server.
- Double-click the name of HFSQL server in the tree structure.
- The right section of Control Center displays a tab with the server name.
- Click the "Scheduled elements" tab.
- In the ribbon, in the "Scheduled elements" group, expand "New scheduling" and select "Schedule a task".
- Select the runtime mode of the task: the task can be run:
- 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 locking: in this case, the HFSQL server will not be accessible during the task execution.
- the task must be run in background task: in this case, the HFSQL server can be used as soon a it is started.
- Select:
- the database containing the stored procedure to run.
- the set containing the stored procedure to run.
- the stored procedure to run.
Caution: In order for a stored procedure started from a scheduled task to access the data, you must use HDeclareExternal. 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 started from the HFSQL Control Center, there is no current analysis and the 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. Remark: when a stored procedure is started by HExecuteProcedure from a WINDEV, WEBDEV or WINDEV Mobile application, it uses the application analysis and can directly use the HFSQL Client/Server data.
- Define the frequency of the task: month, day, hour.
- Give a description to your scheduled task and validate.
- The scheduled task appears in the HFSQL Control Center.
Deleting a scheduled task To delete a scheduled task: - Connect (if necessary) to an HFSQL server.
- Double-click the name of HFSQL server in the tree structure.
- The right section of Control Center displays a tab with the server name.
- 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: - Connect (if necessary) to an HFSQL server.
- Double-click the name of HFSQL server in the tree structure.
- The right section of Control Center displays a tab with the server name.
- 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:
- "General" tab: Defines whether the task is enabled as well as its type (backup or stored procedure).
- "Schedule" tab: Defines the runtime options of scheduled task (month, day, time and number of executions, execution at start).
- "Backup" tabs: These two tabs define the options taken into account if the scheduled task corresponds to a backup.
- Validate.
Scheduled tasks through programming The scheduled tasks are managed through programming via the advanced hScheduledTask type and via several WLanguage functions. To programmatically create a scheduled task: - Create a variable of type hScheduledTask. Specify the characteristics of the scheduled task via the hScheduledTask properties.
- Add the scheduled task with HAddTask.
The following WLanguage functions can also be used to manage the scheduled tasks:
| | 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. |
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. 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:
PROCÉDURE 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 = HExécuteProcédure(cntStockedHFSQLProcedure, "StoredProcedureName")
...
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|