A Schema Command represents an action your Data Abstract application wants to execute on the database, like calling a stored procedure, Inserting/Updating/Deleting records or running any kind of custom query that performs data manipulations.
Each Schema Command has a collection of parameters and statements. A Statement contains a reference to certain database connection, it's data table or stored procedure. A Parameter can be used to filter the records retrieved from a data table for certain conditions, to pass new data to insert/update/delete statements, or to simply provide parameters that a certain operation or stored procedure requires.
The Schema Modeler provides several methods to create new Delta-Commands; from manually adding them, using drag & drop, to using the table view.
Creating a New Command in the Table view
The quickest way to create new commands, is to use the Create Delta-Commands menu item. This will add 3 new Schema Commands: INSERT, UPDATE and DELETE, based on the particular Schema Table that was selected. Each command will contain Statements from the Schema Table with an appropriate SQL or AutoSQL statement inside.
To use this feature, right click on the Table you are interested in from the Tables folder in the Schema tree, and click on the Create Delta-Commands menu item.
Creating a Command using Drag & Drop
A quick way to create new Commands, is to drag a Stored Procedure from the Connection Manager window and drop it into the Commands folder in the Schema tree.
This will generate a new Schema Command that contains a Statement which references the appropriate Connection from the Connection Manager and the Stored Procedure.
Creating a Command manually
Another way to create a new Schema Commands is to do so manually. To add a new Schema Command you can either:
- Right Click on the Commands folder in the Schema tree and select the Add button.
- Click on the Add New Command button on the Commands collection view.
You then need to click on the green + icon, which is the Add button, in the Statement section and proceed to the Statement view and set that up as appropriate. Choosing the required Connection or ConnectionType and select required TargetTable.
By default each new statement uses AutoSQL, you will need to choose the TargetTable from those available (based on the Connection you choose). The Command can also point to a stored procedure in the database. Parameters for Schema Command will be added automatically if needed.
Editing Schema Command properties
The Schema Command view allows you to configure the schema command's properties.
It is split into four sections:
- General section here you must enter a unique name for the Command, and you can provide an optional description of what the command is used for. There is also a flag to specify if the command is available publicly; when it is false then the command is only available for use in the serve
- Data section provides a XML syntax aware editor that allows you to set/edit the Dynamic Where statement.
- Misc section allows you to specify an optional string as a Custom Attribute(s) that can be used as part of the Business Rules scripting
- Content section shows the Parameters and Statements that are currently defined for the select Command. There are buttons to add or remove a parameter or statement, and you can double-click on one to quickly go to the appropriate view. Clicking on the Statements or Parameters hyperlinks will open appropriate collection view.
When you have made modifications the bottom right of the Command view will indicate this. Make sure to save the changes you have made by clicking on
File->Save. You can also discard the changes you've made if you are unhappy with them.