Add Table Command

To define a table from within MQL use the Add Table command.

This page discusses:

Syntax

add table NAME user USER_NAME [ADD_ITEM {ADD_ITEM}];

Or

add table NAME system [ADD_ITEM {ADD_ITEM}];
  • NAME is the name of the table you are defining. Table names cannot include asterisks.
  • USER_NAME can be included with the user keyword if you are a business administrator with person access defining a table for another user.
  • system refers to a table that is available for system-wide use, and not associated with the session context.

    You must include either the user or system keyword.

  • ADD_ITEM provides additional information about the table. The Add Table clauses are:
    [!|in|notin|not]active
    column [label STRING_VALUE] COLUMN_TYPE_DEF [COLUMN_DEF_ITEM]
    description VALUE
    icon FILENAME
    [!|not]hidden
    property NAME [to ADMINTYPE NAME] [value STRING]
    units | [picas] | points | inches | 
    visible USERNAME{,USERNAME}
    history STRING
  • The column clause must be used for each required column of the table, to specify the COLUMN_TYPE_DEF . All other clauses and subclauses are optional.
  • The history clause applies only to system tables; it does not apply to user tables.

Units Clause

This clause specifies the units of page measurement. There are three possible values: picas, points, or inches.

units picas

Or

units points

Or

units inches

Without a unit of measurement, 3DSpace cannot interpret the values of any given header, footer, margin, or field size. Because picas are the default unit of measurement, 3DSpace automatically assumes a picas value if you do not use a Units clause.

Picas are the most common units of page measurement in the computer industry. Picas use a fixed size for all characters. Determining the size of a field value is easy when using picas as the measurement unit. Simply determine the maximum number of characters that will be used to contain the largest field value. Use that value as your field size. For example, if the largest field value will be a six digit number, you need a field size of six picas. This is not true when using points.

Points are standard units used in the graphics and printing industry. A point is equal to 1/72 of an inch or 72 points to the inch. Points are commonly associated with fonts whose print size and spacing varies from character to character. Unless you are accustomed to working with points, measuring with points can be confusing and complicated. For example, the character “I” might not occupy the same amount of space as the characters “E” or “O.” To determine the maximum field size, you need to know the maximum number of characters that will be used and the maximum amount of space required to express the largest character. Multiply these two numbers to determine your field size value.

Inches are common English units of measurement. While you can use inches as your unit of measurement, be aware that field placement can be difficult to determine and specify. Each field is composed of character string values. How many inches does each character need or use? If the value is a four-digit number, how many inches wide must the field be to contain the value? How many of these fields can you fit across a table page? Considering the problems involved in answering these questions, you can see why picas are a favorite measuring unit.

Column Clause

This clause defines each column in the table. When a column is added to a system table, it will be propagated to all tables derived from that table.

The Column clause is made up of several subclauses. Each Column clause must have a Businessobject, Relationship, or Set subclause, unless the table column is usable only on the web. All other subclauses are optional:

column [label STRING_VALUE] COLUMN_TYPE_DEF [COLUMN_DEF_ITEM]
  • If the label keyword is not used, the column heading is the expression.
  • STRING_VALUE is the text that is to appear in the heading of the column.
  • COLUMN_TYPE_DEF can be any of the following:
    businessobject QUERY_WHERE_EXPRESSION
    relationship QUERY_WHERE_EXPRESSION
    set QUERY_WHERE_EXPRESSION
  • QUERY_WHERE_EXPRESSION is an expression that is evaluated on each object in the table with the results placed in the Table cell.

    The QUERY_WHERE_EXPRESSION is used with businessobject, relationship, or set keyword. When applied to relationships, the information presented in the column will only be available from an indented table, where relationships are apparent. Relationship information will be blank in table cells that represent business objects and vice verse. A flat or regular table shows only the properties of the business objects it contains as expressed in the column definition. While the same table definition can be used as both a flat and indented table, generally the usage determines how the table is defined.

    Omit the businessobject, relationship, or set keyword for a table column that is to be used only on the web. Other column settings will indicate whether it is a check box, image, and so on.

  • COLUMN_DEF_ITEM is a column subclause that provides additional information about the value to be printed. These subclauses define information such as the size and scale of the columns, the order in which the columns should be placed on the page, and the links used within the columns.
    Column Definition Description
    name COLUMN_NAME The name to assign to the column, for example: column name colname1
    size WIDTH HEIGHT The default size of a column is determined by its contents, and the font size used for dialogs. The defaults are recommended; however, you can set column sizes using the other column subclauses. The width and height can be explicitly set using the Size clause with width and height values respectively.
    minsize MIN_WIDTH MIN_HEIGHT The minimum width and/or height of the column, for example: column units picas minsize 20 12
    scale PERCENTAGE_VALUE Percentage of the entire table to be used for this column. For example, use scale 25 for a 4-column table of equal column width.
    href HREF_VALUE The link data to the JSP. The Href link is evaluated to bring up another page. Many table columns will not have an Href value at all. The Href string generally includes a fully qualified JSP filename and parameters, which can contain embedded macros and expressions for mapping to database schema. For more information, see MQL Concepts: Using Macros and Expressions in Configurable Components.
    alt ALT_VALUE Alternate text displayed until any image associated with the column is displayed and also as "mouse over text."
    range RANGE_HELP_HREF_VALUE For use in Web tables only to specify the JSP that gets a range of values and populates the column with the selected value.
    update UPDATE_URL_VALUE The URL address for updating the column.
    program SORT_PROGRAM_NAME Defines a program for sorting the table columns.
    order NUMBER The order of the column within the table. For example, order 3 would place the column as the third in the table.

    If the column is modified for any reason, this column might not remain third in the table even if the order number is still 3. For more information, see Understanding How Column Order Is Processed.

    sorttype alpha|numeric|other|none Determines how the column is sorted.
    add user [USER_NAME|all] For use in web forms only to specify who will be allowed access to the column.
    setting NAME VALUE For use in web forms only. Settings are general name/value pairs that can be added to a column as necessary. They can be used by JSP code, but not by hrefs on the Link tab.
    remove user [USER_NAME|all] For use in web forms only to specify who will not be allowed access to the column.
    remove setting NAME VALUE For use in web forms only to remove settings.
    autoheight [true|false] Autoheight and autowidth are both false by default, even if height/width have not been specified. If you set the size with the size clause, you can change back to the default size by setting the autoheight and autowidth clauses to true.
    autowidth [true|false]
    edit [true|false] Determines whether users can edit cells in the column.
    [!|not]hidden Determines whether the column is hidden.

For example, each of the following are valid column clauses:

column businessobject attribute["Target Cost"] - attribute["Actual Cost"]
column relationship name
column relationship attribute[Quantity]

Selectable items can be operated on as numerical expressions.

Understanding How Column Order Is Processed

The order in which columns appear in a table do one always follow the order number given to the column. Column modifications are processed in the order that they are specified in the modify table command. This means if a column is added with an order number, K, that is greater than the total number (N) of columns in the table, K is reset to N+1. If a column is added with an order number, K, that is less than N, all of the columns with order numbers greater than K will be bumped up by 1. The order numbers of columns in a table are always consecutive and can never have gaps.

For example, if we start with an 11 column table and:

  • A column A is added with order number 14 which becomes column 12.
  • A column B is added with order 21 which becomes column 13.
  • A column C is added with order 15 which becomes column 14.
  • A column D is added with order 13 which becomes column 13, bumping B to 14 and C to 15.

You might expect the columns to be DACB but in fact they are ADBC. Table columns must be modified in order.

History Clause

The history keyword adds a history record marked “custom” to the system table that is being added. The STRING argument is a free-text string that allows you to enter some information describing the nature of the addition. For more information, see Adding History to Administrative Objects.

The history clause applies only to system tables; it does not apply to user tables.

Example

The following is an example of a complete Add Table command:

add table TestTable system 
column name colname1 
sorttype none 
setting "Column Type" Image 
setting "Image Size" format_mxThumbnailImage 
column name colname2 
label emxProduct.Table.Name 
businessobject name 
href "${COMMON_DIR}/emxTree.jsp?treeMenu=type_PLCProductLine" 
sorttype none 
setting "Registered Suite" ProductLine 
setting "Show Type Icon" true 
setting "Target Location" content 
column name colname3 
label emxProduct.Table.Description 
businessobject description 
sorttype none 
setting "Registered Suite" ProductLine 
column name colname4 
label emxProduct.Table.State 
businessobject current 
sorttype none 
setting "Admin Type" State 
setting "Registered Suite" ProductLine 
column name colname5 
label emxProduct.Table.Owner_GlobalPM 
businessobject owner 
sorttype none 
setting Export true 
setting "Registered Suite" ProductLine 
setting format user 
column name colname6 
sorttype none 
setting "Column Type" File 
setting "Registered Suite" Components 
column name colname7 
href "${COMMON_DIR}/emxTree.jsp?mode=replace&treeMenu=type_PLCProductLine" 
sorttype none 
setting "Column Icon" "images/iconNewWindow.gif" 
setting "Column Type" icon 
setting "Popup Modal" false 
setting "Registered Suite" ProductLine 
setting "Target Location" popup;