Collapse AllExpand All

11.2.1. MetaSQL Editor

To create a new MetaSQL Statement, select the NEW button. The following screen will appear:

Create New MetaSQL Statement

The MetaSQL Editor can be used to create new MetaSQL Statements or edit those already found on the MetaSQL Statements master list. Once created, new MetaSQL Statements can be added to the master list, making them available for use in the application. To edit an existing MetaSQL Statement, simply load the statement into the editor from the Database you are currently connected to. Then edit the statement and save it back to the Database once editing is complete.

The body of a MetaSQL Statement is an SQL SELECT, UPDATE or DELETE statement. (The user must have been granted the ExecuteMetaSQL privilege to run the UPDATE or DELETE statement.) Passed parameters can be utilized to control how the statement operates (using an IF, ELSE, ENDIF construct) and their values can be inserted. The core xTuple PostBooks Edition contains many statements that can be used as examples.

The MetaSQL Editor toolbar has icon shortcuts for New, Open, Save, Undo, Cut, Copy, and Paste. The Editor menu has many options to simplify the development of MetaSQL Statements, including viewing and editing the Parameter List, executing the query, and viewing the query results.

When saving a new MetaSQL Statement, you are presented with the following options:

Save (Database)

Saves the MetaSQL Statement into the Database you are currently connected to, with the option of also saving the statement to a file.

Save (File)

Saves the MetaSQL Statement to a file.

Save As (Database or File)

Allows you to save the MetaSQL Statement with a different name to either the Database your are currently connected to or to a file.

If you are saving the MetaSQL Statement to the database using alternate information (i.e., Save As), the following screen will appear:

Save As MetaSQL Options

When saving a MetaSQL Statement to the database using alternate information, you are presented with the following options:

Schema

You would normally select the "public" schema. However, there are situations where you may want to define the MetaSQL Statement in a different schema.

Group

Enter the Group for the MetaSQL Statement. This is the major grouping for statements and normally reflects the type or source of information. Some examples are arHistory, purchaseOrders, etc.

Name

Enter the Name for the MetaSQL Statement. This is detailed name for the statement within the Group.

Grade

Enter the Grade number for the MetaSQL Statement. If there are multiple MetaSQL Statements with the same Group/Name, the one with the highest Grade number will be used. It is a good idea to save changes to statements with a higher Grade number so, if necessary, you can refer to the original statement before implementing the changes. Use the menu option File > Save As Database to change the Grade of a statement.

Notes

Enter any notes or comments related to the MetaSQL Statement.