This section explains how you define a rule-based logical view. You need to take special action to deaul with database-generated keys if your logical view shares such a key with an underlying table.
To define a rule-based Logical View:
|1.||Start by defining and testing a new Logical View in the normal way. Provide the SQL Statement, press the Check button so that USoft sets the view to Correct = Yes, then save your work. Or find an existing Logical View that you want to make rule-based, and make sure it has Correct = Yes.|
|2.||Decide which of the three DML actions (insert, update, delete) you want to make rule-based. For each of these actions, set the Use Constraints... flag to Yes. Save your work.|
|NOTE: You don't always need special rules for each DML action. In a view that joins a parent and a child table connected by a Relationship with Delete Rule = Cascading, it is likely that you don't need a special rule for delete action, in which case you keep the setting Use Constraints for Deletes = No.|
|3.||Plan ahead what are the special rules that you want executed for each rule-based DML action in this logical view. |
|4.||In the Columns tab of the Logical View tab or window, make any necessary adjustments to column attribute settings. In particular, since you are providing extra functionality, it is likely that some columns that were initially set to Updatable = No should now get Updatable = Yes. Save your work.|
If the Logical View shares a database-generated key value with an underlying table, you need to take special action if (on Insert into the view) your special rules are going to write that key value into multiple underlying tables. Write a transitional Update constraint against the view that retrieves the next generated key value ahead of time, in other words, before the user action on the view is translated to actions on underlying tables:
|1.||Invoke the GetNextGeneratedUniqueValue() method of the internal <table name> component. The generic INVOKE syntax is:|
|but you can replace the INVOKE keyword by function call Syntax a typical SQL statement of a transitional Update constraint retrieving the key value will look like this:|
SET primary-key = underlying-table.GetNextGeneratedUniqueValue()
WHERE primary-key IS NULL
|2.||Write your special rules as transitional constraints on the Logical View (meaning that the Transition Table attribute is set to the name of the Logical View and you use one or more of the Fire On... flags). You have a design choice here:|
•You can define all the desired behavior on the constraints themselves.
•Alternatively, you can have a transitional constraint call a USoft batch job that executes the desired behavior. Start the constraint SQL with
INVOKE BatchRunner.job-name WITH SELECT ... .
|3.||Before testing, debugging or maintaining the solution, make sure that all the transitional constraints are Active and Correct. |
|TIP: The "Rule-based Implementation" tab in the Logical View tab or window helps you with this step.|
Rule-based logical views
Example: Rule-based logical view