PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN

  • 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
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
HFSQL Client/Server: Scheduled tasks
HFSQL Client/ServerAvailable only with this kind of connection
Overview
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:
  1. Connect (if necessary) to an HFSQL server.
  2. Double-click the name of HFSQL server in the tree structure.
  3. The right section of Control Center displays a tab with the server name.
  4. Click the "Scheduled elements" tab.
  5. In the ribbon, in the "Scheduled elements" group, expand "New scheduling" and select "Schedule a task".
  6. 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.
  7. 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.
  8. Define the frequency of the task: month, day, hour.
  9. Give a description to your scheduled task and validate.
  10. The scheduled task appears in the HFSQL Control Center.

Deleting a scheduled task

To delete a scheduled task:
  1. Connect (if necessary) to an HFSQL server.
  2. Double-click the name of HFSQL server in the tree structure.
  3. The right section of Control Center displays a tab with the server name.
  4. Click the "Scheduled elements" tab.
  5. Select the scheduled task to delete.
  6. 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. Connect (if necessary) to an HFSQL server.
  2. Double-click the name of HFSQL server in the tree structure.
  3. The right section of Control Center displays a tab with the server name.
  4. Click the "Scheduled elements" tab.
  5. Select the scheduled task to modify.
  6. 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).
  7. 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.
  8. 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:
  1. Create a variable of type hScheduledTask. Specify the characteristics of the scheduled task via the hScheduledTask properties.
  2. Add the scheduled task with HAddTask.
The following WLanguage functions can also be used to manage the scheduled tasks:
HAddTaskAdds a scheduled task on the server defined by the connection.
HManageTaskEnables or disables a scheduled task on 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.
HModifyTaskModifies a scheduled task on the HFSQL server defined by the connection.
HDeleteTaskDeletes a scheduled task from an HFSQL Client/Server server.
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.
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:
//  - use NO connection: The current database on which
// the stored procedure is found will be used
//  - specify NO full path: The file will be sought 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
RESULT 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 = HExécuteProcédure(cntStockedHFSQLProcedure, "StoredProcedureName")
 
// Exploit the result
...
Minimum version required
  • Version 10
This page is also available for…
Comments
Click [Add] to post a comment