The component of the SQL table allows the management of data in the form of a table. This information is obtained either from the direct execution of an SQL query or from the execution of an XSQL-Script. The main options that this type of box allows:
  • Data visualization in list form
  • Data in the form of a tree
  • Asynchronous transactions
  • Relationship with other components
    • Subgrid
    • Related tables
    • Related to a shopping cart
  • Filter column
  • Search parameters
  • Authorization
  • Table styles
  • Links
  • Selection of records

1 Parameters

Structure

Loading...

1.1 Main Box


wic_jrep_box_sqltable
Label Description
Box ID Box identifier

  • Default: THIS
Parent Box parent identifier
Collapse If has parent, can be hidden and show it on demand

  • Default: 0
  • Values:
    • 1: Yes.
    • 0: No.
Relation Relation with the parent box

  • Values:
    • NULL: Undefined.
    • 1: Subgrid.
Dataset List of columns that are stored in memory for later use (obsolete)
Datasum List of columns under summ calculus in order to show the total
Autoref List of columns with link to the SQL object that have as code the same name of the table for the indicated column, and the link condition is obtained from the column name matching it to the value obtained in the selection.
Find on server Flag indicating if the search is done at server

  • Default: 0
  • Values:
    • 0: Client.
    • 1: Server on typing.
    • 2: Server on demand.
Search Columns to search, to construct dynamic conditions
Pointer Primary-key column of the table where the query tries to access
Filter column
Table name Name of main table of the SQL query. If not filled will be retried automatically
Columns per row Number of columns per row. Zero indicates each record in a single row

  • Default: 0
  • Values:
    • 0: 0.
    • 1: 1.
    • 2: 2.
    • 3: 3.
    • 4: 4.
    • 5: 5.
    • 6: 6.
    • 7: 7.
    • 8: 8.
    • 9: 9.
    • 10: 10.
Expand level Level which defines initial expanded nodes

  • Default: 999
  • Values:
    • 0: Collapsed.
    • 1: 1 level.
    • 2: 2 levels.
    • 3: 3 levels.
    • 4: 4 levels.
    • 5: 5 levels.
    • 999: Expanded.
Compact tree · Scenario: SQL-Table with tree group (applied to 1 or more columns), and aggregation function applied to other columns.
· Issue: At parent nodes (corresponding to a grouped column) lower-level tree with only one child node, the total value of the parent matches the value of the child.
· Solution: Enabling the Compact tree parameter, row father and son are unified. Parents with more than 1 child remain with the same display.

  • Default: 0
  • Values:
    • 1: Yes.
    • 0: No.
Hide totals Hide footer row containing totals

  • Default: 0
  • Values:
    • 1: Yes.
    • 0: No.
Cache Flag to keep the quey in the memory cache area (activated by default)

  • Default: 0
  • Values:
    • 1: Yes.
    • 0: No.
Input Flag showing if the field is 'input'

  • Default: 0
  • Values:
    • 1: Yes.
    • 0: No.
Select Flag indicating if the table allows lines selection.

  • Default: 0
  • Values:
    • 0: No.
    • 1: Multiple.
    • 2: Single row.
Dynamic columns Denotes if the columns might change on each execution

  • Default: 0
  • Values:
    • 1: Yes.
    • 0: No.
Ignore Row Selected

  • Default: 0
  • Values:
    • 1: Yes.
    • 0: No.
Erase Flag showing if the cleaning of data on the screen, involves also to delete them

  • Default: 1
  • Values:
    • 1: Yes.
    • 0: No.
Scroll Specifies whether to display scroll in nested SQLTABLE

  • Default: 1
  • Values:
    • 1: Yes.
    • 0: No.
Min. rows Minimum number of rows to be issued. 0 indicates none (default)
Method Pagination method

  • Default: 0
  • Values:
    • 0: Pages.
    • 1: Infinite scroll.
    • 2: See all.
Max. rows Maximum number of rows to issue
SQL Stmt SQL Statement

  • Format: SQLCOND_EXPR
Created by

  • Default: USER
Date created

  • Default: CURRENT
Modified by

  • Default: USER
Date updated Updated date

  • Default: CURRENT
Actions
Button Title Notes
LBL_SQLTABLE_TO_REPORT Sql-Table to report null
LBL_SQLTABLE_TO_VTABLE Sql-Table to VTable null

1.2 SQL table output


Todo

wic_jrep_box_sqltable_out
Label Description
Box identifier
Order Output order
Table Table column
Column
Group Columns tree grouping

  • Default: 0
  • Values:
    • 1: Yes.
    • 0: No.
Header group Label header group
Tooltip Description column showed as tooltip
Hide Hide the expression

  • Format: UELSQL_EXPR
Decimals Number of decimals showed (numeric values)

  • Default: -1
Datasum Shows column add up

  • Default: 0
  • Values:
    • 0: No.
    • 1: Sum.
    • 2: Average (AVG).
Searchable Indicates if is a searchable column

  • Default: 1
  • Values:
    • 1: Yes.
    • 0: No.
Input Indicates if columns is editable

  • Default: 0
  • Values:
    • 1: Yes.
    • 0: No.
Object
Enable expression Link activation expression
Condition / js function
Color palette
Action Action code
Actions
Button Title Notes
BUT_RENUMERAR Renumber Actualiza el orden de las columnas dejando un espacio vacío entre columna y columna.

All Sqltable must contain output fields (SQL table outputs) set of columns that you want to display.

If the main statement contains fields that you don't want to display, simply use the attribute hide at output fields.

1.3 Links


Using this option, users can access the definitions of object hyperlinks. If the user possesses the necessary permissions, they will be able to create, modify, and erase these definitions.

A hyperlink represents a path or resource, used to connect a specific report to the universe of possible queries related to the business concepts in the document.

Additionally, with this option users can also access queries of information attached to the object which hyperlinks belong to:
  • Definition of object itself.
  • Registry of object's input fields.
  • Registry of object's output fields.
  • Registry of object query's variables.
  • Registry of hyperlink's assigned variables.
  • Registry of object's descriptive information.
  • Registry of object's headers.
  • Registry of object's restrictions.
  • Registry of object's authorizations.
wic_jrep_box_collnk
Label Description
Hyperlink identifier Name of a component field where links defined here will be added. This field refers to one of the attributes returned by the component's SQL statement. In certain cases, the link may not apply to a given column, if used generically on a component element which represents each row returned by the SQL statement. This is the case for components such as the calendar, image reel, etc.
Box ID Identifier of the box.
Column Column name.
Apply to Flag indicating where to apply styles.

  • Default: 0
  • Values:
    • 0: Cell.
    • 1: Cell (Starts with).
Order Link's display order within the object.
Type Link style type.

  • Default: T
  • Values:
    • T: Text.
    • I: Icon.
    • A: Alarm.
    • P: Process.
Mode Open mode.

  • Default: 0
  • Values:
    • 0: Default.
    • 3: New window.
    • 1: Modal window.
    • 2: Modal & refresh.
Hyperlink Object Code of the object to be linked.
Expression Expression of link activation condition.

  • Format: UELSQL_EXPR
lnk_expr_backup Link expression backup
Hyperlink Command Statement linked to the object.

  • Format: SQLCOND_EXPR
lnk_stmt_backup Link statement backup

The links are widely used to access information from a column value of a Sqltable.

1.4 Styles


A SQL table allows the use of styles (background color, text font, icons, ...) both static and conditional.

wic_jrep_box_sqltable_styles
Label Description
Id Identifier of the box
Column Column name
Expression Expression of style

style_expr_backup
Icon
Text Show text next to icon

  • Default: 1
  • Values:
    • 1: Yes.
    • 0: No.
Apply to Flag indicating where to apply the style

  • Default: 0
  • Values:
    • 0: Cell.
    • 1: Header.
    • 2: Row.
Style Style code

  • Case: Upshift

1.5 Authorizations


wic_jrep_box_celldata_auth
Label Description
box_id Box identifier
Insert If can Insert

  • Default: 0
  • Values:
    • 1: Yes.
    • 0: No.
Delete Grant to delete

  • Default: 0
  • Values:
    • 1: Yes.
    • 0: No.
Update Role to update

  • Default: 0
  • Values:
    • 1: Yes.
    • 0: No.
Expression/SQL Expression to evaluate to prohibit an authorization.

Reason Reason by which prohibe the authorization

Created by

  • Default: USER
Date created

  • Default: CURRENT
Modified by

  • Default: USER
Date updated Updated date

  • Default: CURRENT

2 Syntax

In SQL Table sentences can be written in XML or standard SQL.

2.1 SQL Syntax

The statements can be expressed in SQL (Structured Query Language). Normally it is used for simple queries and it is not possible to make calls to procedures or XSQL-Script, so it is always recommended to use standard XML or SQL syntax (ANSI SQL).

Copy
SELECT * FROM store;

2.2 XML Syntax

It is recommended to use the XML syntax for two reasons:

  • Portability: A sentence expressed in XML allows its execution in database managers of different manufacturers (Informix, BD2, Oracle, etc.). If it is expressed in standard SQL it can be executed successfully in some manager, but instead it may not be feasible in others, since it depends on the functions and commands used in the statement.
  • Security: The system analyzes the XML statements for the application of user roles. If this is assigned a security role for the entities that make up the FROM clause of the statement, whose joins are not of type OUTER or LEFT JOIN, the system inherits the existing conditions in that role and adds them to the WHERE clause of the statement during its execution.

Using JUEL Expressions

Passing column values from the main select has changed from #value to using JUEL ${value}. If this value needs to be passed as a literal string (without quotes), then it needs to be done like ${value?literal}.

2.2.1 Example: Query

Copy
<select>
    <columns>*</columns>
    <from table='store'>
        <join table='sales'>
            <on>store.store_id = sales.sotre_id</on>
        </join>
    </from>
    <where>
        store.country = #country
    </where>
</select>

2.2.2 Example: Stored process

In addition, the use of XML syntax allows the execution of XSQL-Script processes. If the last statement in the table is a call to a process, it must return an instance that can be represented by the table, that is, a virtual table or a resultSet. The example shown below makes a call to the getSalesByCountry process:

Copy
<call name='getSalesByCountry'>    
    <args>
        <arg>#country</arg>
    </args>
</call>

2.2.3 Example: Embedded process

It is also possible to execute embedded processes. This method works just like the execution of stored processes, with the difference that the process is written directly in the statement of the table.

Copy
<call>    
    <args>
        <arg>#country</arg>
    </args>
<![CDATA[
<xsql-script>
    <args>
        <arg name='p_country' type='string' />
    </args>
    <body>
        <vtable name='v_result'>
            <select>
                <columns>*</columns>
                <from table='store'>
                    <join table='sales'>
                        <on>store.store_id = sales.sotre_id</on>
                    </join>
                </from>
                <where>
                    store.country = <p_country />
                </where>
            </select>
        </vtable>

        <return><v_result /></return>
    </body>
</xsql-script>
]]>
</call>

3 Transaction

A SQL table also allows to modify the content in the database. A modification in the database of type Insert, Modify or Delete is called transaction. For a SQL table to allow transactions, a series of parameterization features must be taken into account:

  • It must have editable columns. A column is defined as editable by the Editable indicator of the column entity of output columns.
  • The statement must return the result of an SQL query, that is, a call to XSQL-Script can not be made.
  • The SQL statement must return the rowid internal column of the main table, selected in the FROM clause of the statement.

3.1 Transaction management

Transactions are carried out line by line. This does not have much meaning in terms of insertion or deletion, obviously, only lines, or complete records, can be inserted or deleted. As for data modification, the fact that the transaction is per line means that the connection to the server is established every time changes are saved in a line. As a result, changes to the selected line are sent to the server for each modification transaction.

Transactions on the database are performed asynchronously; that is, before any modification the system allows the user to continue working normally, even if he does not receive a response from the server. At the moment the server returns a response, if it is satisfactory, the system does not issue any notification; conversely, in case there has been an error, the system notifies the error by means of a message and backs off the changes made.

3.1.1 Insert

The insertion of a new record is initiated by the insert button, which adds a new line as the first record of the table; it appears directly in edit mode so that it can modify its content.

During the insertion, the system automatically obtains the references to columns of the main form whenever there is a foreign key (FOREIGN KEY) that relates the main entity of the SQL table with the main entity of the form.

3.1.2 Modify

To edit the data in the table, just click on the row that you want to modify, when it goes into edit mode. In order to save the changes in the database, you must confirm the changes made using the ENTER key. Analogously, it is also possible to cancel the modification at any time by means of the Esc key.

Another way to edit the data in the SQL Table is using the Features form, to access this option you can double click on the rowid of the row or also make a secondary click on the row you want to modify and choose the option Edit row. This option gives comfort when editing rows of many columns.

3.1.3 Delete

To delete a record, first, you must click secondary on the row you want to delete; then, choose the option Delete row to carry out the action. In any case, before deleting a record, the user's confirmation is always requested.

3.2 Transaction authorizations

It is possible to program authorizations against the enabled transactions of the SQLtable. The expressions defined in authorizations form limit transactions according to a condition.

In the event of UPDATE and DELETE transaction, this condition can be based on:

  • SQLtable fields (of the modified or deleted row)
  • Cursor data of the main object
  • Constants

In the event of INSERT transaction, this condition can only be based on:

  • Cursor data of the main object
  • Constants

NOTE

The expression defines the condition that prohibites/disables authorizations.

4 Relationship with other components

A table can be linked to other components of the form, specifically, with another table or with a shopping basket. For this, a series of parameters is available in the SQL table entity:

  • First, it is necessary to indicate, through the Parent parameter, the identifier of the parent component; that is, the component whose data determines the information to be displayed in the current table.
  • Second, the relationship parameter indicates the type of relationship between the components. The relationships that can be established are: Subgrid and Related Box.
  • Finally, in the case of a subtable it is possible to indicate if the dependent table is shown collapsed in the initial load.

4.1 Subgrid

A subtable is a table that shows information directly related to each row of its parent table. As a result, the subtable is displayed nested to the parent table so that it does not occupy any cells in the grid of the form.

The execution of the SQL statement depends directly on the Collapsed indicator. In this way, if the indicator is active, the SQL statement is not executed until each subtable is displayed. On the contrary, if the indicator is deactivated, the sentence is executed in the initial load. In any case, the SQL statement is executed for each row of the parent table.

4.2 Related tables

This function is deprecated since version 2019.1

Use Box subscriptions instead it

A related table allows the information in an SQL table to be conditioned by a selection of previous records in another SQL table of the form.

The execution of the SQL statement is conditional on the selection of rows of the parent table; consequently, the SQL statement is not executed until some row of the parent table is selected. In the same way, each time the selection is modified, the sentence will be executed again.

4.2.1 References to the parent table

Since the information of a related table depends on the selection in the parent table, it is necessary to obtain the selected values to execute the SQL statement. For this, the syntax # field_name is used, where field_name is a column of the parent table, which must be defined as the output column in the definition of the parent.

It should be noted that the syntax is the same as for accessing the form fields; consequently, a related table can not directly access the fields of the main form. If you need information from the form, you must select that information in the parent table so that it is visible from the related one.

On the other hand, it must be taken into account that the parent table can allow multiple selection. In this case, the expression #nombre_campo is replaced by the values of the all selected rows separated by commas ( nombre_campo1, nombre_campo2, ..., nombre_campoN). This transformation is oriented to use the expression inside an IN clause of SQL.

Copy
<select>
    <columns>*</columns>
    <from table='warehouse_inventory' />
    <where>
        product_id IN (#product_id)
    </where>
</select>

5 Tree grouping

A SQL table allows the grouping of records in the form of a tree from one or more columns in the table. To do this, you must activate the Group indicator in the parameterization of output fields in the columns that are to be included in the grouping. In addition, the execution of the SQL statement must return the records ordered by the columns of the grouping and these must be consecutive. To have a clearer idea of the tree grouping, let's see an example:

Year City Store Sales
2010 Barcelona Diagonal 200.000
2010 Barcelona Gracia 300.000
2010 Madrid Atocha 200.000
2011 Barcelona Gracia 300.000
2011 Madrid Atocha 100.000
2011 Madrid Plz.España 250.000

If the previous records are grouped, for example, by 'Year' and 'City', the following result is obtained:

City Store Sales
>2010 700.000
>>Barcelona 500.000
>>> Diagonal 200.000
>>> Gracia 300.000
>>Madrid 200.000
>>> Atocha 200.000
>2011 650.000
>>Barcelona 300.000
>>> Gracia 300.000
>>Madrid 350.000
>>> Atocha 100.000
>>> Plz. España 250.000

In addition to establishing a grouping of the columns, it is possible to specify an initial depth of the tree. This option is applied when loading the form and once the application is loaded, it allows to expand and collapse nodes. To indicate the depth is done with the attribute Expand Level that is in the definition tab of the SQL-Table. This attribute allows the selection of five levels of depth in addition to the possibility of showing the tree closed (collapsed) or fully open (expanded)

Note

  • Situation: SQL-Table with tree grouping (applied to 1 or N columns), and aggregation function applied to other columns.
  • Problem: At the parent nodes (corresponding to a grouped column) with the lowest level of the tree, with only 1 child node, the total value of the parent matches the value of the child.
  • Solution: Activating the Compact tree parameter, the parent row and the child row are unified. Parents with more than 1 child remain with the same visualization.

6 Grouping headers

A SQL table allows the grouping of columns from a label. To do this, you must indicate the label code in the Header group field within the parameterization of output fields, in all those columns that are to be included in the grouping. The informed tag code must previously exist in the Groups of Headers dictionary. In addition, for the display of the header label to be correct, it must be indicated without jumps between columns. Let's see an example of grouping headers:

7 Table Styles

A SQL table allows the use of styles (background color, text font, icons, ...) both static and conditional. The first ones are those styles that are always applied, the second depend on an application expression.

A style record is defined either to assign an icon or to add a style. For this reason, both the icon code and the style code can be left blank, but not both at the same time.

8 Filter column

A column of the table can be used as a filter column, so that instead of being added to the table a drop-down with the different values of the column is shown. In this way, at the moment of selecting a value from the drop-down list, the rows of the table corresponding to the selected value are filtered. The filtering process, which is performed with each selection in the drop-down, is executed locally from the data obtained in the initial execution of the SQL statement; therefore, it does not entail any access to the server or the database.

To indicate that a column acts as a filter, the column must be informed in the field 'filter column' in the parameterization of the SQL table. The drop-down contains the different values corresponding to the column indicated in the records selected in the table. If a list of possible values (logical Include) exists for the indicated column, all the defined values will be shown, including those that have not been selected in the execution of the SQL statement.

9 Vertical tables

A vertical table is not exactly a table, since the SQL statement must return a single record. To enable an SQL table as a vertical table, you simply have to report a number greater than zero as the number of display columns. In this way, the columns of the record returned by the SQL statement are represented vertically by distributing the data according to the indicated number of columns. Therefore, the appearance of a vertical table is more similar to a data component (formdata) than to an SQL table. In addition, a vertical table is not compatible with the functions of an SQL table such as multiple selection, search, groupings, etc.

10 Links

SQL tables allow hyperlinks on values returned by the execution of the SQL statement, thus allowing the user to deepen the information of a database.

There are four types of destination mode:

  • Default: The link opens in the same window.
  • New window: The link opens in a new window.
  • Modal window: The link opens in a modal window.
  • Modal & refresh: The link opens in a modal window and refreshes the main form.

10.1 Link to object

10.2 Link to Javascript function

This mode is used, for example, to activate searches in a SQLTable that has searches, or to open menu options of a TreeView component that is manual, that is, the tree is opened on demand, thus remaining related components.

Copy
return ("Hello!");

11 Selection of records

The system offers the possibility of interacting with the SQL tables from the different actions of a form (buttons, events, transactions, etc.). To access the data of a table it is essential to inform the mnemonic code, which allows to refer to a specific table within the form.

When data is retrieved from a table, only the data of the selected rows is obtained. By default a SQL table only allows to select a row at the same time, the selection is made by clicking directly on the row. In order to select more than one row, the Multiselection indicator must be activated in the table definition. In this way, a column is enabled with the checkboxes that allow selecting more than one row at the same time.

To access the selection of rows from the server side, use the following JavaScript function:

Copy
<script>
    var selection_rs = Ax.context.selection["BOX_MNEMO"];

</script>

12 Search

12.1 Search parameters

SQL tables allow searches on the records returned by the execution of the SQL statement; in this way, the user can limit the number of rows according to a certain criterion.

The activation of the search in SQL tables was carried out at the level of columns, for which purpose the Query Allowance indicator is available. In this way, only the introduction of search parameters is allowed for those columns that have this indicator activated. This indicator is activated by default, in this way, most SQL tables allow searches for all its columns.

12.2 Find on server

SQL tables allow searches on the records returned by the execution of the SQL statement; in this way, the user can limit the number of rows according to a certain criterion.

The activation of the search in SQL tables was carried out at the level of columns, for which the Searchable indicator is available which is found in the 'SQL Table output'. In this way, only the introduction of search parameters is allowed for those columns that have this indicator activated. This indicator is activated by default, in this way, most SQL tables allow searches for all its columns.

  • Local(Client): Generally, the search in SQL tables is done locally, on the data obtained in the initial execution of the SQL statement. In this way, every time a new search is made, no connection is established with the server or the database is accessed.
  • Server

    In any case, it is possible to force queries to be made on the server instead of locally; In this way, each time a new search parameter is entered, the SQL statement with the search parameters entered is executed on the server. In addition, if the search is performed on the server, the SQL statement is not executed in the initial load of the page but waits for some search condition to be entered to execute it. Generally, the server search execution is used for very heavy queries that require defining a filter to optimize the query, for this reason the execution of the query is delegated.

    • Server on typing: The search is carried out as text is being introduced.
    • Server on demand: The search is performed when the enter key is pressed.

12.3 Features

When a search is active, the grid shows one record with the different search fields. Each field has a filter button. If you press the button, a filter help window will be open. The window will help you to filter the records of the grid, with a search field greater than the grid search field and an item list with the different values that the field can allow.

The different values of select list are the different values that can have the field on the data store. If the SQL table has filters in other fields, the list only shows the different values after applying the filters.

We must take into account next exception: When SQL table search on the server the data aren't on local and we don't show the list with different values. In this case, only show items' values when the field have an include.

13 Dynamic columns

This field is related to the SQL table output. When it is deactivated, only the columns indicated in the SQL table output will be shown in the output of the form. On the other hand when the field is activated, all the columns of the SELECT Statement of the SQL Table will be represented, being able to optionally parameterize the ones that are desired in the SQL table output.

In the following image, some columns are optionally parameterized, which will be shown in the output.

Next, you can see an example of a table with dynamic columns and another without dynamic columns that are defined identically both in the Select Statement of the SQL table and in the SQL table output. You can see how in the table with dynamic columns more columns are added since the whole SELECT Statement is represented.