You can have references to external database metadata from a central studio server. Those references may include application objects, table logical definition, and business logic procedures, triggers and scripts.

1 External objects definition

External objects are defined with <external-object> tag. It has the attributes below:

  • dict: dictionary where the external object belongs to.
  • code: external object reference code.
  • type: type of object.
  • mode: configures the way data is shown. By default is xml mode.

There are different mode values, depending on object type:

  • Type object:
    • xml: XML statement definition.
    • sql: SQL statement according to database engine.
    • repinfo: object information.
    • docinfo: columns description about object main table.
    • tecinfo: extended columns information of the main table (basic and metadata information as SQL type and size).
    • image: image documented in the object.
    • menupath: Get paths.
    • butinfo: But info.
    • all: Does menupath, repinfo, image, docinfo, butinfo and table model with deep 1 at the same time.
  • Type table, procedure, function and trigger:
    • xml: statement definition.
    • sql: SQL statement obtained from XML code transformation according to database engine.

The following table shows the different modes that each type of external object accepts:

External Object Attributes
type code database dict lang mode
object         xml, sql, repinfo, docinfo, image
object         tecinfo
object         all
table         xml, sql
procedure         xml, sql
function         xml, sql
trigger         xml, sql
script         -

  Required   Optional   N/A

1.1 Object

The following example shows a tabbed panel for either XML, SQL, Repinfo, Docinfo, Tecinfo and Image Object definition, taken from the database dictionary wic.

Copy
<tabs>
    <tab active="yes" title="XML">
        <external-object code="wic_image_object" dict="wic" type="object" mode="xml" />
    </tab>
    <tab title="SQL">
        <external-object code="wic_image_object" dict="wic" type="object" mode="sql" />
    </tab>
    <tab title="Repinfo">
        <external-object code="wic_image_object" dict="wic" type="object" mode="repinfo" />
    </tab>
    <tab title="Docinfo">
        <external-object code="wic_image_object" dict="wic" type="object" mode="docinfo" />
    </tab>
    <tab title="Tecinfo">
        <external-object code="wic_image_object" dict="wic" type="object" mode="tecinfo" />
    </tab>
    <tab title="Image">
        <external-object code="wic_image_object" dict="wic" type="object" mode="image" />
    </tab>
</tabs>
Example
<select>
    <columns>
        <rowid table='wic_image_object' />, wic_image_object.*
    </columns>
    <from table='wic_image_object' />
</select>
SELECT 
        wic_image_object.rowid, wic_image_object.*
    
  FROM wic_image_object

Este es el repositorio de imágenes que ilustra el diccionario (incluidos los menús) y los objetos SQL.

Estas imágenes se pueden obtener por medio de un archivo o de iconos empaquetados en una fuente. Los iconos parecen imágenes, pero se pueden manejar como fuentes.

Debido a las propiedades de color y escalabilidad de las fuentes, se debe priorizar el uso de iconos en lugar de imágenes.

wic_image_object
Label Description
Name Image name

  • Default: name(img_data)
Description Image description
Source Image source

  • Default: 0
  • Values:
    • 0: File.
    • 1: Font "Awesome".
    • 2: Font "Material".
Glyph

Glyph (hieroglyphic): when the source is a font, enter here icon code from the website.

Color Color: when the source is a font, select here desired color for the icon.

If no color is selected, the system will display the icon in black or white depending on the darkness/lightness of the background.



Type Image type

  • Default: type(img_data)
Size Image size

  • Default: size(img_data)
Image width

  • Default: width(img_data)
Image height

  • Default: height(img_data)
Image Choose file: when you select this options, standard opening dialog box appears and an image file can be selected. After unloading image, the fields Size, Type, Width and Height will be automatically filled in.
Created by

  • Default: USER
Date created

  • Default: CURRENT
Modified by

  • Default: USER
Date updated

  • Default: CURRENT
wic_image_object
Column Type Size Not null Label Description
img_name Name Image name

  • Default: name(img_data)
img_memo Description Image description
img_source Source Image source

  • Default: 0
  • Values:
    • 0: File.
    • 1: Font "Awesome".
    • 2: Font "Material".
img_font_code Glyph

Glyph (hieroglyphic): when the source is a font, enter here icon code from the website.

img_font_color Color Color: when the source is a font, select here desired color for the icon.

If no color is selected, the system will display the icon in black or white depending on the darkness/lightness of the background.



img_type Type Image type

  • Default: type(img_data)
img_size Size Image size

  • Default: size(img_data)
img_width Image width

  • Default: width(img_data)
img_height Image height

  • Default: height(img_data)
img_data Image Choose file: when you select this options, standard opening dialog box appears and an image file can be selected. After unloading image, the fields Size, Type, Width and Height will be automatically filled in.
user_created Created by

  • Default: USER
date_created Date created

  • Default: CURRENT
user_updated Modified by

  • Default: USER
date_updated Date updated

  • Default: CURRENT

1.2 Table

The following example shows a tabbed panel for both XML and SQL Table definition, taken from the database dictionary wic.

Copy
<tabs>
    <tab active="yes" title="XML">
         <external-object code="wic_jrep_form_hide" dict="wic" type="table"/>
    </tab>
    <tab title="SQL">
        <external-object code="wic_jrep_form_hide" dict="wic" mode="sql" type="table"/>
    </tab>
</tabs>
Example
<table name='wic_jrep_form_hide'>

   <!-- COLUMNS -->
   <column name='rep_code'     type='char' size='48' required='y' />
   <column name='hide_colname' type='char' required='y' size='30' />
   <column name='hide_colprev' type='char' required='y' size='30' />

   <!-- INDEXES -->
   <primary name='p_wic_jrep_form_hide' columns='rep_code, hide_colname' />

   <!-- FOREIGN KEYS -->
   <foreign name='f_wic_jrep_form_hide1' columns='rep_code, hide_colname' references='wic_jrep_colout' refcols='rep_code,col_name' ondeletecascade='y' />
</table>
-- **************************************************************************
-- DEISTER WebStudio XSQL-SCHEMA Tue Mar 21 04:51:48 CET 2023 Engine: informix
-- wic_jrep_form_hide
-- **************************************************************************
CREATE TABLE wic_jrep_form_hide (
	rep_code  char (48)   not null ,
	hide_colname  char (30)   not null ,
	hide_colprev  char (30)   not null 
);
ALTER TABLE wic_jrep_form_hide LOCK MODE (ROW);

-- Index to avoid automatic named by database (named with pk name).
CREATE UNIQUE INDEX p_wic_jrep_form_hide ON wic_jrep_form_hide(rep_code, hide_colname);
ALTER TABLE wic_jrep_form_hide
 ADD CONSTRAINT 
 PRIMARY KEY (rep_code, hide_colname)  
 CONSTRAINT p_wic_jrep_form_hide

;

-- Omitido indice f_wic_jrep_form_hide1 dado que ya existe un indice sobre las columnas 
ALTER TABLE wic_jrep_form_hide
 ADD CONSTRAINT 

 	FOREIGN KEY (rep_code, hide_colname)
REFERENCES wic_jrep_colout  (rep_code,col_name)
ON DELETE CASCADE


 CONSTRAINT f_wic_jrep_form_hide1

;

1.3 Function

The following example shows a tabbed panel for both XML and SQL Function definition, taken from the database dictionary wic.

Copy
<tabs>
    <tab active="yes" title="XML">
         <external-object code="sdm_set_value" dict="wic" type="function"/>
    </tab>
    <tab title="SQL">
        <external-object code="sdm_set_value" dict="wic" mode="sql" type="function"/>
    </tab>
</tabs>
Example
<!-- =============================================================================  -->
<!--                                                                                -->
<!--    sdm_set_value(p_string)                                                     -->
<!--                                                                                -->
<!--    Asignar una constante (valor fijo) a una columna en un trigger no es        -->
<!--    facil, hay que hacerlo via un SPL.                                          -->
<!--                                                                                -->
<!--    Se utiliza en un grupo de disparadores de wic_icon y d wic_iges.            -->
<!--       WIC_ICON: cpar_projecl, cpar_projseg                                     -->
<!--                                                                                --> 
<!-- =============================================================================  -->
<function name='sdm_set_value'>
    <test>
        <unit id='1'>
            select sdm_set_value(<char>'1'</char>) from cdataemp;
        </unit>
    </test>
    <args>
        <arg name='p_string' type='char' size='255' />
    </args>
    <returns type='char' size='255' />

    <body>
        <return>p_string</return>
    </body>
</function>
-- **************************************************************************
-- sdm_set_value
-- DEISTER WebStudio XSQL-UDFUNC  -  Engine: informix
-- **************************************************************************

-- ============================================================================
-- XSQL Tests
-- ============================================================================
-- Unit 1
--              select sdm_set_value('1') from cdataemp;         

CREATE FUNCTION sdm_set_value(
    p_string char(255)
)
    RETURNING  char(255);


    -- =========================================================
    -- Debug
    -- To activate debug mesages, call sdm_set_debug(1) or level
    -- =========================================================
    DEFINE GLOBAL gl_debug   SMALLINT DEFAULT 0;    -- DEBUG FLAG
    IF gl_debug > 1 THEN
        TRACE ON;
    END IF

    -- =================================
    -- Function body
    -- =================================
    RETURN p_string;
END FUNCTION;

1.4 Procedure

The following example shows a tabbed panel for both XML and SQL Procedure definition, taken from the database dictionary wic.

Copy
<tabs>
    <tab active="yes" title="XML">
          <external-object code="wic_raise_msg" dict="wic" type="procedure"/>
    </tab>
    <tab title="SQL">
        <external-object code="wic_raise_msg" dict="wic" mode="sql" type="procedure"/>
    </tab>
</tabs>
Example
<procedure name='wic_raise_msg'>
    <args>
        <arg name='p_isam'   type='integer'        />
        <arg name='p_strmsg' type='char' size='80' />
    </args>

    <body>

        <exception>p_strmsg</exception>
    </body>
</procedure>
-- **************************************************************************
-- wic_raise_msg
-- DEISTER WebStudio XSQL-UDFUNC  -  Engine: informix
-- **************************************************************************
CREATE PROCEDURE wic_raise_msg(
    p_isam integer,
    p_strmsg char(80)
)


    -- =========================================================
    -- Debug
    -- To activate debug mesages, call sdm_set_debug(1) or level
    -- =========================================================
    DEFINE GLOBAL gl_debug   SMALLINT DEFAULT 0;    -- DEBUG FLAG
    IF gl_debug > 1 THEN
        TRACE ON;
    END IF

    -- =================================
    -- Function body
    -- =================================
    RAISE EXCEPTION -746, 0, p_strmsg;

END PROCEDURE;

1.5 Trigger

The following example shows a tabbed panel for both XML and SQL Trigger definition, taken from the database dictionary wic.

Copy
<tabs>
    <tab active="yes" title="XML">
         <external-object code="wic_change_log_del" dict="wic" type="trigger"/>
    </tab>
    <tab title="SQL">
        <external-object code="wic_change_log_del" dict="wic" mode="sql" type="trigger"/>
    </tab>
</tabs>
Example
<xsql-trigger name="wic_change_log_del" table="wic_change_log" event="delete">
  <foreach-row>
    <execute-procedure name="wic_raise_msg">
        <in>
            <param>0</param>
            <param>'No esta permitido borrar registros en esta tabla'</param>
        </in>
    </execute-procedure>
  </foreach-row>
</xsql-trigger>
-- **************************************************************************
-- wic_change_log_del
-- DEISTER WebStudio XSQL-TRIGGER Tue Mar 21 04:51:49 CET 2023 Engine: informix
-- **************************************************************************
CREATE TRIGGER wic_change_log_del
DELETE  ON wic_change_log
REFERENCING OLD AS prv
  FOR EACH ROW
   (
   EXECUTE PROCEDURE wic_raise_msg(0, 'No esta permitido borrar registros en esta tabla')
   )


;

1.6 Script

The following example shows an XML Script definition, taken from the database dictionary wic.

Copy
<external-object code="wic_jrep_object_buffer_create" dict="wic" type="script"/>
Example
<xsql-script name='wic_jrep_object_buffer_create'>

    <args>
        <arg name='p_rep_code'     type='string'  />
        <arg name='p_user_updated' type='string'  />
    </args>

    <body>
        <!-- Un usuari pot començar una edicio del buffer sempre i quan no estigui ja sent editat. -->
        <update table='wic_jrep_object'>
            <column name='rep_stmt_buffer' text='true'>rep_stmt</column>
            <column name='user_updated'><p_user_updated /></column>
            <column name='date_updated'><date.current /></column>
            <where>
                    rep_code = <p_rep_code />
                AND rep_stmt_buffer IS NULL
            </where>    
        </update>
    </body>
</xsql-script>

2 External table graph

The following example shows a tabbed panel for either external reference to table with deep="0" and deep="1" from cvenfach table. This function needs an enterprise database to obtain the physical metadata and table relations. You can specify a different level of deep for the table relations (the exported keys).

External table graph attributes
name database deep
     

  Required   Optional   N/A

Copy
<tabs>
<tab active="yes" title="Graph deep 0">
     <external-table-model deep="0" database="demo_erp" name="cvenfach"/>
</tab>
<tab title="Graph deep 1">
    <external-table-model deep="1" database="demo_erp" name="cvenfach"/>
</tab>
</tabs>
Example

3 wic_conf wic_database