Displaying items by tag: Componentstyle KM
As the name suggests, "SQL Structured Substitution API" provides a more straightforward and structured way of generating code using ODI knowledge modules. In the documentation and examples provided by Oracle, the following pattern is used to generate code:
- Variables are created and initialized using Groovy code in Groovy Task-local and/or Groovy KM-local sections of KM steps. In the Groovy code present on the examples, I have found that only read functions are used. I didn't find any example where the AST (i.e. the various objects exported using INSERT, QUERY and so on variables) is manipulated.
- The variables mentioned above are then used on the Command Text section of KM steps to generate the code.
Therefore when we need to change the statement generated by an IKM we can do it by writing our custom code in some Groovy variables and then use these variables in the Command Text section. It is also possible to write text directly in the Command Text section. There is also a third possibility which I want to illustrate in this blog: manipulating the AST structure. This means that we do not necessarily touch the Command Text section or create Groovy variables but make our changes directly in AST. Example of such changes could be:
- create predefined mapping expression for technical fields
- add some tables in the FROM clause (i.e. adding a join with the table containing the surrogate keys)
Follow the link below to see how you can create a new component-style IKM on which the AST used to generate the code is modified: