|
Tables and relations
Visualization of relations between tables is one of SqlDBU's key features. The following text has more details about how achieve it.
If the setup does not contain any appropriate entry, the table will be represented with all it's columns. In order to display only a subset of columns the table needs to have this entry (SELECT statement) in section [SELECT], e.g.:
[SELECT]
DEMO=SELECT FIRST,LAST,COUNTRY FROM demo
If this entry is missing for the selected table SqlDBU internally creates the following statement:
SELECT * FROM demo
In the sample above column COUNTRY represents the ISO Country Code. The appropriate caption of that country matching the mentioned code is contained in table country (Columns ENG and GER). Without any reference to that table this country code itself is not very useful.

Both tables, demo and country represent a typical SQL relationship which can be defined in sqldbu.ini like follows:
Table View
What we need here is the country's caption GER or ENG), which can be selected from table country based on the code stored as COUNTRY in table demo:
[DEMO.COUNTRY]
CAPTION=Land
BROWSEVIEW= \
<!---(SELECT ENG FROM country WHERE COUNTRY=-DEMO.COUNTRY-)--->
The caption of a column can be defined by entry "CAPTION=...". If this entry is missing, caption will be derived from the table structure. Table view column values can be customized by entry "BROWSEVIEW=...". In the sample above the value will be created by following SELECT:
SELECT ENG FROM country WHERE COUNTRY=-DEMO.COUNTRY-
SqlDBU must evaluate the statement at runtime in order to replace template
expression -DEMO.COUNTRY- by the appropriate country code. Therefore the statement is enclosed by WSML (WebSeller Markup Language) Eval Syntax:
<!---(<expression>)--->
Template Expression "-DEMO.COUNTRY-" follows the WSML-Syntax as well. In general every column name can be used as a template expression in order to be replaced by current table value at runtime:
-<column_name>-
Based on the definition above now the column looks like follows:

Form View
The form view is designed for data maintenance. SqlDBU creates data input forms in HTML Code. The code for each column based form entry can be customized by "FORMVIEW=...". The default HTML code for column [DEMO.COUNTRY] represents a single line input text value, which is not very helpful for country code. The sample shows how to define a list of all possible country captions instead in order to select the desired country's caption.
The sample uses additional WSML tags supported by SqlDBU like startlist, endlist, if(), else() and endif().
[DEMO.COUNTRY]
...
FORMVIEW=<!---DATABASE-country---> \
<select name="COUNTRY"> \
<!---startlist---> \
<!---if(-DEMO.COUNTRY-=-COUNTRY.COUNTRY-)---> \
<option selected value="-COUNTRY.COUNTRY-">-COUNTRY.ENG-</option> \
<!---else(-DEMO.COUNTRY-=-COUNTRY.COUNTRY-)---> \
<option value="-COUNTRY.COUNTRY-">-COUNTRY.ENG-</option> \
<!---endif(-DEMO.COUNTRY-=-COUNTRY.COUNTRY-)---> \
<!---endlist---> \
</select>
The following picture shows the effect of that setup entry:

The last but not least option to customize a column represents entry SEEKVIEW=.... Seek values are defined as HTML Form values as well, therefore the sample almost looks like the FORMVIEW definition. The only difference is the default value, which is empty in opposite to the FORMVIEW. (see chapter Locate and Filter for further information).
Back
|