Collapse AllExpand All

2.2. Entering a Query

For this exercise, we will demonstrate the MetaSQL Editor functionality using a very basic and simple query. The goal of the exercise is to leave you with an understanding of fundamental MetaSQL Editor mechanics. You are free to perform more complex and extensive testing on your own.

Now that we are connected to a database—in this case, an xTuple database—we can write a simple query and then test the results. To enter a query, simply type in the MetaSQL Editor's main text field, as shown in the following screen:

Simple SQL query with embedded MetaSQL

Note

Test queries may be saved for future use by selecting either the Save or Save As options from the File menu.

As you can see, the query begins with standard SQL. We are seeking to SELECT four pieces of item information from the item table. Our MetaSQL is inserted within the WHERE clause. The MetaSQL states that the item_number for the selected item must match a specified item_code. The term item_code is a parameter. We can set different values for the item_code parameter using the MetaSQL Editor—and then run the query to test the results.

However, before we run the query, we must first define the parameter item_code and assign it a value.