Composite tasks and how to create them

In many cases, routine processes that are repeated at regular intervals do not consist of a single task, but instead, it consists of a sequence of tasks. In this case, we suggest using composite tasks in DBeaver.

For example, you can import data from one database and then load it to another database or create a dump of a production database and then restore it on stage.

This is a series of articles about tasks in DBeaver. Here you can read the other parts:

Working with tasks: how to get started
Database Tasks View: all your tasks in one place
Composite tasks and how to create them (now you are here)
How to use Scheduler for your tasks

How composite tasks make life easier

Let’s go back to our hero Louis and look at how composite tasks can make his job easier. One of his work tasks is the analytical research of customers who place orders on the site. Louis does not want to use a production database for this, so he has to regularly transfer the tables he needs to the stage and work with fresh data. He knows that doing it manually each time is not very convenient, which is why he has decided to use a composite task.

Louis can create a composite task in the same way as a single task. This can be done using the main menu or the Database Tasks View, which we talked about in a previous article. To learn more about creating composite tasks, please visit our Wiki.

As Louis does such an analysis regularly, he has a special SQL script that he keeps saved in DBeaver. So, this script can be reused for his composite task. But now he needs to create tasks to export data from one database and import it to another. Both adding existing and creating new tasks are available in the wizard.

Using the toolbar on the right side of the wizard, Louis first adds the script he already has. To do this, he creates a new task with the script’s execution. Next, he needs to create two more tasks for data export and import.

After entering the name of the task for data export and selecting the desired task type from the list, he sets the settings he needs and just click the Save task button. The same thing is with the data import.

You can read more about creating single tasks in our article.

Then Louis needs to arrange the tasks in the order in which they should be performed. This can be done by dragging them with the mouse. After adding the necessary tasks, he clicks the Save task button. A new composite task will appear in the Database Tasks View list.

It is important to remember that the tasks included in a composite task are always performed sequentially and must be added in the correct order.

To check that everything is working correctly, Louis needs to select his task from the list and clicks the Run button in the top toolbar.

Well done! Thanks to this composite task, our hero will save a lot of time and effort.

Composite task in a composite task

Impressed by his success, Louis is going further, and he thinks it’s a great idea to have his analytics results sent to his boss’s email once a week. To accomplish this, he wants another SQL script to be executed after his composite task is completed.

Louis knows that it’s possible to use a composite task inside another composite task, and he decided to try how it works. Sounds a little crazy, but why not?

Using the same wizard, Louis adds an already existing composite task and a ready-made SQL script and again clicks the Save task button.

Louis launches his new task to check its work and soon hears an exclamation of delight from the boss’s office. When he is satisfied with the results, he goes to grab a well-deserved cup of coffee.

Louis did a great job, so it’s time to digress a bit from his story. Now you can become a hero like him too and use composite tasks as a great way to be creative with your routines. Best of luck and look forward to seeing you in the next part of our article series.

Author: