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 MetaSQL 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 As (File)

Saves the MetaSQL statement to a file. The system will show the directory where the last save occurred.

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. The system will show the directory where the last save occurred.

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.