This article shows how to execute a Drop table and then a Create table, based on the metadata.
We have a table named "EMPLOYEE" in the "SUPPORT01" schema. This table has three columns and a primary key.
We want our process to drop the table, and re-create it, using the metadata information.
The first step is an SqlOperation Action, named "SqlOperation : drop". We drag and drop the EMPLOYEE table on it.
Here is code in the expression editor for this action :
This code refers to the $EMPLOYEE metadata link, and calls the technical function "tech:dropDdl()" of this Metadata. This function returns the Sql code for dropping the table.
We checked "Errors Accepted" in the properties, so that the process can continue if the table does not exist yet. Note the yellow triangle at the top left corner of the Action's box.
The second step is another SqlOperation Action, named "SqlOperation : create". We also drag and drop the EMPLOYEE table on it.
The code for this action is :
It refers to the $EMPLOYEE metadata link, and calls the technical function "tech:creationDdl()" which returns the Sql code for creating the table.
Here is the generated code when Preparing the process :
After execution, if the table would not exist before, here is the session report in analytics :
We can see the warning on the drop action. And the process continued.