Developers/Setup tasks/Implementation/SQL statements

How you organize your SQL statements depends on what your task is supposed to do. In the easiest case, your setup task shall only change a single column of a well-known table. Then, a single SQL statement is sufficient:

If more statements are necessary for changing a single column and there are no dependencies, you can provide a list of SQL statements. They can be directly processed by using the _executeList method inherited by the abstract task class:

Things get more complicated if your setup task shall change more than one column in a single table. As it's necessary to test if each column already exists, the _process method needs to know which column it has to test and what statements should be executed. Thus, using the column name as key is a good idea:

Also, changing columns in different tables is possible. Remember that these tables should be in the same domain! This requires providing table and/or column names separately:

You can also use a list of SQL statements in the later two cases.

Note: Use ANSI SQL compatible statements for best compatibility. This includes using double quotes (") for all identifiers (e.g. table, column or index names).

<< Previous: Implementation - Dummy example | Next: Implementation - Dependencies >>