PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US

  • Overview
  • Scheduled tasks in the HFSQL Control Center
  • Creating a scheduled task
  • Deleting a scheduled task
  • Modifying a scheduled task
  • Scheduled tasks by programming
  • Notes
  • Example for using 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/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
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:
Note: From version 19, HFSQL is the new name of HyperFileSQL.
Versions 17 and later
iPhone/iPad This feature is now available for the iPhone and iPad applications.
New in version 17
iPhone/iPad This feature is now available for the iPhone and iPad applications.
iPhone/iPad This feature is now available for the iPhone and iPad applications.
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. Select the HFSQL Client/Server server in the tree structure on the left of the screen.
  2. Select the "Scheduled elements" tab.
  3. Click the "Create" button and select "New scheduled task". The wizard for creating a scheduled task starts.
  4. Enter the information about the scheduling: runtime month, day, hour.
  5. Indicate the content of scheduled task:
    • Stored procedure: specify the name of the database and the name of the set containing the stored procedure, then select the procedure.
      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.
      Note: when a stored procedure is started from a WINDEV, WEBDEV or WINDEV Mobile application by HExecuteProcedure, it is using the application analysis and therefore it can directly use HFSQL Client/Server data.
    • A backup:
      • Specify the elements that will be saved: the server content, a specific database or a selection of databases.
      • Specify whether the indexes must be saved.
      • Specify the backup directory and the stored procedures that will be run before and/or after the backup.
      • Specify (if necessary) the maximum number of backups that must be stored on the server. The oldest backups will be automatically erased.
        Note: The backup will not be performed if the server is switched off. The backup will be performed at the next available date when the server is switched on.
  6. Give a description to your scheduled task and validate.
  7. The scheduled task appears in the HFSQL Control Center.
In the HFSQL Control Center, the scheduled tasks can be defined at server level.
To create a scheduled task:
  1. Connect (if necessary) to a 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. Versions 23 and later
    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.
    New in version 23
    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 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.
      Note: when a stored procedure is started from a WINDEV, WEBDEV or WINDEV Mobile application by HExecuteProcedure, it is using the application analysis and therefore it 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. Select the HFSQL Client/Server server in the tree structure on the left of the screen.
  2. Select the "Scheduled elements" tab.
  3. Select the scheduled task to delete.
  4. Click the "Delete" button.
To delete a scheduled task:
  1. Connect (if necessary) to a 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 popup menu of the scheduled element ("Delete" option).

Modifying a scheduled task

To modify a scheduled task:
  1. Select the HFSQL Client/Server server in the tree structure on the left of the screen.
  2. Select the "Scheduled elements" tab.
  3. Select the scheduled task to modify.
  4. Click "Modify". A description window of scheduled task 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).
    • "Backup" tabs: These two tabs define the options taken into account if the scheduled task corresponds to a backup.
  5. Validate.
To modify a scheduled task:
  1. Connect (if necessary) to a 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 popup 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 by programming
The scheduled tasks are managed by programming via the advanced hScheduledTask type and via several WLanguage functions.
To create a scheduled task by programming:
  1. Create a hScheduledTask variable. Specify the characteristics of 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:
Versions 12 and later
HAddTask
New in version 12
HAddTask
HAddTask
Adds a scheduled task on the server defined by the connection.
Versions 12 and later
HDeleteTask
New in version 12
HDeleteTask
HDeleteTask
Deletes a scheduled task from a HFSQL Client/Server server.
Versions 14 and later
HInfoTask
New in version 14
HInfoTask
HInfoTask
Returns the characteristics of a scheduled task in a hScheduledTask variable].
Versions 12 and later
HListTask
New in version 12
HListTask
HListTask
Returns the list of scheduled tasks found on a HFSQL Client/Server server for a given connection.
Versions 12 and later
HManageTask
New in version 12
HManageTask
HManageTask
Enables or disables a scheduled task on a HFSQL Client/Server server.
Versions 14 and later
HModifyTask
New in version 14
HModifyTask
HModifyTask
Modifies a scheduled task on the HFSQL server defined by the connection.
Notes
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.
Example for using 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()

// 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 sub-directory 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
RESULT ""
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 required version
  • Version 10
This page is also available for…
Comments
Click [Add] to post a comment