1 Introduction

To define the business logic, the system has different tools that differ depending on the compilation and execution environment:

  • Database logic: procedures compiled and executed on the Database server.
    • Functions(XSQL-XUDF)
    • Procedures (XSQL-XUDP)
    • Triggers (Triggers)
  • Server logic: programs interpreted at runtime by the Axional Studio application server:

2 Catalog XSQL - XUDF

The XUDFs are user functions written in XML grammar so that they can be transformed to native code for each database agent.

These functions are cataloged in the application dictionaries and are subsequently loaded into the database using an XSQL-Script, either using the web application from this dictionary database, or from the system configuration database, or through the command line.

To catalog the different functions of the system, access to form XSQL-XUDF. The code must be written in Axional Studio XML grammar, since this way the system will be able to translate the function into the language that corresponds to our database.

XSQL- XUDF
Menu Screen

In the object itself where the procedures catalog is made, there is a list of databases for which the wic is a dictionary and the status of the function in the database.

This list is usually a soft-status, probable status of the procedure in the database.

2.1 Hard - Status

To get a current state, there is a tab in the object itself [Hard-status]. After pressing the tab, statements are executed on the database to obtain a list of the states.

Hard-Status
Tab Screen

3 Catalog XSQL - XUDP

The XUDP procedures are user procedures written in XML grammar so that they can be transformed to native code for each database agent.

These procedures are cataloged in the application dictionaries and are subsequently loaded into the database using an XSQL-Script , either using the web application from this dictionary database, or from the System configuration database, or through the command line, as detailed below.

To catalog the different system procedures, the XSQL-XUDP form will be accessed. The code must be written in Axial Studio XML grammar for stored procedures.

XSQL- XUDF
Menu Screen

In the object itself, where the procedures catalog is made, there is a list with the set of databases which to the wic is a dictionary and the status of the procedure in the database.

This list is usually a soft-status, probable status of the procedure in the database.

3.1 Hard - Status

To get a current state, there is a tab in the object itself [Hard status]. After pressing the tab, statements are executed on the database to obtain a list of the states.

Hard-Status
Tab Screen

4 Catalog Triggers

Triggers are a part of code that is executed before or after an event (INSERT, UPDATE, DELETE) that occurs on a table to ensure data integrity. Triggers can also call Functions (XSQL-XUDF) or Procedures (XSQL-XUDP). To catalog the different Triggers of the system, the maintenance Triggers form will be accessed.

XSQL- XUDP
Menu Screen

In the object itself, where the triggers catalog is made, there is a list of database set which to the wic is a dictionary and the trigger status in the database.

4.1 Hard - Status

To get a current state, there is a tab in the object itself [Hard status]. After pressing the tab, statements are executed on the database to obtain a status list.

Hard-Status
Tab Screen

5 Compilation

The deploy (compilation) procedure is for the following objects and is performed on the BD server (compiled and executed):

  • XUDP
  • XUDF
  • Triggers

XSQL-SCRIPTS programs are interpreted (not compiled) and executed by the application server Axional Studio .

5.1 Execution via WEB from the dictionary database

To compile the procedures and functions cataloged by users, the option Compile code (spl) that can be found on the Deployment menu must be accessed, in the dictionary database (wic) in which they are located.

5.1.1 Parameter definition

Once accessed, the following parameters must be defined.

  • Database. A drop-down menu will appear, where will be displayed all the target databases that have as dictionary the wic in which they are working. Debe seleccionarse la base de datos en la que se desee compilar los procedimientos o funciones.
  • Action. A drop-down menu will appear with the following actions:
    • Compile: select if you want to compile one or more procedures/functions in the database.
    • Drop: select if you want to remove one or more procedures/functions from the database.
    • Status: select if you want to see the status of one or more procedures/functions.
  • Type: A drop-down menu will appear where you must select in which type of objects the action defined above will be applied.
    • All: apply the action to all code, it is, XUDFs, XUDPs, native code procedures and triggers.
    • XUDFunction: apply the action only to XUD Functions.
    • XUDProcedure: apply the action only to XUD Procedures.
    • Procedure: apply the action only to procedures in native code.
    • Trigger: apply the action only to triggers.
  • Pattern: pattern to select the code objects that you want to compile. For example, icon_% will select all objects (among those of the selected type) with name starting with the characters "icon_". For not to applying any restrictions by name, the symbol '%' must be entered.

For example, the following parameters could be specified for the insert trigger compilation of the table gvenpedl:

Once the compilation parameters have been defined, it must be initiated using the execute button. The system will ask for confirmation.

Once the process is finished, a results list of the operations that have been executed against the database will be displayed.

The following fields will be displayed, among others:

  • Database: the database where the compilation was executed.
  • Server: Server Name.
  • Dict: Dictionary Name.
  • Type: Type (Procedure, Function or Trigger).
  • Code: Name of the Procedure, Function or Trigger that has been created.
  • Table: n the case of compiling a trigger, name of the table on which the trigger acts
  • Status: Indicates if the creation was completed successfully(VALID) or not (ERROR).
  • Message: Message launched by the BBDD engine.
  • Source: The SQL code that was executed against the database.

For each of the code objects to be compiled or deleted, if the operation was completed successfully, the VALID text on a green background will appear in the status column.

Otherwise, operations that end with a problem will contain the text ERROR (on a red background) in the status column. In this case, the problem must be analyzed using the message given by the database engine and the code that was attempted to execute.

Compile code
Menu Screen

5.2 Execution via WIC CONF

Through this option it is possible to compile all the code (triggers, functions and procedures defined by the users, procedures in native code) cataloged in each one of the dictionaries of a certain database.

To do this it is necessary to enter the WIC_CONF (Administrator permissions required) and access the menu option Databases, in the Databases panel .

A filter screen will open, where you must select the database for which you want to compile code.

In this screen you can access the database configuration form. The Code button is available at the lower left, which is marked in red in the following image (left).

Compile code wic_conf
Menu Screen

Clicking on the button will open a screen very similar to the one in the previous section, where the appropriate parameters for the code compilation in the database being treated should be defined .

The options presented are analogous to those described in the previous section, with the difference that now the target database is already selected and it is understood that the code defined in each and every one of the dictionaries assigned to the database will be compiled data.

Thus, for example, to compile the entire code of a database after its physical creation and subsequent creation of tables, indexes, etc., the following parameters must be entered:

Action: Compile

Type: All

Pattern: %

The results visualization will be similar to that of the previous section, appearing, for each object processed, the message VALID on a green background if the operation has been completed successfully, or the message ERROR on a red background if there has been an error. In this case the dict column lets you know to which dictionary the object belongs.

5.3 Execution via command console

5.3.1 Introduction

There is a method to compile or delete from any database the code objects cataloged in dictionaries, consisting of using the command line to manually execute the code compilation script.

More specifically, it is the XSQL-Script with the name schema_model, already cataloged in the wic dictionary of the application. For its execution, the ws-dbscript program is used, which can be found in the folder bin, located in the root folder of the Axional Studio server (usually with the name jas ).

For further details on XSQL-Scripts and its execution, consult the XSQL Introduction section of this documentation.

Ejecución

To execute it from the console, connect to the Axional Studio machine and within the directory where Axional Studio is installed, execute.

Copy
bin\ws-dbscript -syscode schema_code -dbms erptest -user ped -args p_action=compile,p_type=all,p_dict=,p_pattern=%
  • syscode schema_code: The name of the xsql-script.
  • dbms erptest: Database where objects will be loaded.
  • user ped: User
  • arg: Script Arguments.
    • p_action: type of action, in this case compile, drop, status
    • p_type: type of object to create, delete or view status; possible values xudp, xudf, trig, al.
    • p_dict: dictionary where you want to take the object; if left blank, it takes all dictionaries of the application.
    • p_pattern: pattern to select the objects. For example, reval% will select all those that begin by reval; only % if you want all objects.

5.3.2 Debug

When it is executed by console, as the process moves forward, it shows a log of the operations it is carrying out and its result.

Copy
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION icon_r_avgcam created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   37/60] E[   0] FUNCTION icon_r_avgcam created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION icon_r_ccuenta created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   38/60] E[   0] FUNCTION icon_r_ccuenta created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION icon_r_get_feceje created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   39/60] E[   0] FUNCTION icon_r_get_feceje created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION icon_r_get_fecper created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   40/60] E[   0] FUNCTION icon_r_get_fecper created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION ites_chk_concil created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   41/60] E[   0] FUNCTION ites_chk_concil created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION ites_get_bascom created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   42/60] E[   0] FUNCTION ites_get_bascom created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION ites_get_flufin created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   43/60] E[   0] FUNCTION ites_get_flufin created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION cpar_projech_decalaje created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   44/60] E[   0] FUNCTION cpar_projech_decalaje created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION icon_chk_costes created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   45/60] E[   0] FUNCTION icon_chk_costes created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION icon_get_iban created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   46/60] E[   0] FUNCTION icon_get_iban created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION icon_n2str_mil_ca created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   47/60] E[   0] FUNCTION icon_n2str_mil_ca created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION icon_n2str_mil_en created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   48/60] E[   0] FUNCTION icon_n2str_mil_en created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION icon_n2str_mil_es created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   49/60] E[   0] FUNCTION icon_n2str_mil_es created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION ites_get_nofestivo created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   50/60] E[   0] FUNCTION ites_get_nofestivo created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION icon_get_calppa created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   51/60] E[   0] FUNCTION icon_get_calppa created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION icon_n2str_ca created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   52/60] E[   0] FUNCTION icon_n2str_ca created.
12-06 10:40:41 DBSPLInstructionUnit: FUNCTION icon_n2str_en created.
12-06 10:40:41 DBSPLCompiler: erp wic_icon xudf  [   53/60] E[   0] FUNCTION icon_n2str_en created.

It displays object by object the operation it performs, in this case the creation of functions.

5.3.3 Result

Further than debug, at the end of the process it shows a table with the processed objects and the result.

Copy
+-----+--------+------+------+--------+--------+-----------------------+-----------------------+-----+-------+-----------------------------------------+-------+-------------------------------------+
|seqno|database|server|schema|dict    |type    |code                   |name                   |group|status |message                                  |warning|source                               |
+-----+--------+------+------+--------+--------+-----------------------+-----------------------+-----+-------+-----------------------------------------+-------+-------------------------------------+
|    1|erp     |dbsrv3|      |wic_icon|function|ccalendah_festivo      |ccalendah_festivo      |1/1  |DROPPED|FUNCTION ccalendah_festivo dropped.      |       |DROP FUNCTION ccalendah_festivo      |
|    2|erp     |dbsrv3|      |wic_icon|function|ccalendah_get_days     |ccalendah_get_days     |1/1  |DROPPED|FUNCTION ccalendah_get_days dropped.     |       |DROP FUNCTION ccalendah_get_days     |
|    3|erp     |dbsrv3|      |wic_icon|function|ccalendah_get_labor    |ccalendah_get_labor    |1/1  |DROPPED|FUNCTION ccalendah_get_labor dropped.    |       |DROP FUNCTION ccalendah_get_labor    |
|    4|erp     |dbsrv3|      |wic_icon|function|cimpcont_capuntes      |cimpcont_capuntes      |1/1  |DROPPED|FUNCTION cimpcont_capuntes dropped.      |       |DROP FUNCTION cimpcont_capuntes      |
|    5|erp     |dbsrv3|      |wic_icon|function|cpar_projech_decalaje  |cpar_projech_decalaje  |1/1  |DROPPED|FUNCTION cpar_projech_decalaje dropped.  |       |DROP FUNCTION cpar_projech_decalaje  |
|    6|erp     |dbsrv3|      |wic_icon|function|cper_emppunttot        |cper_emppunttot        |1/1  |DROPPED|FUNCTION cper_emppunttot dropped.        |       |DROP FUNCTION cper_emppunttot        |
|    7|erp     |dbsrv3|      |wic_icon|function|cterbanc_get_max_priori|cterbanc_get_max_priori|1/1  |DROPPED|FUNCTION cterbanc_get_max_priori dropped.|       |DROP FUNCTION cterbanc_get_max_priori|
|    8|erp     |dbsrv3|      |wic_icon|function|cval_cotizac_get       |cval_cotizac_get       |1/1  |DROPPED|FUNCTION cval_cotizac_get dropped.       |       |DROP FUNCTION cval_cotizac_get       |
|    9|erp     |dbsrv3|      |wic_icon|function|cwkfacci_userauth      |cwkfacci_userauth      |1/1  |DROPPED|FUNCTION cwkfacci_userauth dropped.      |       |DROP FUNCTION cwkfacci_userauth      |
|   10|erp     |dbsrv3|      |wic_icon|function|icon_chk_costes        |icon_chk_costes        |1/1  |DROPPED|FUNCTION icon_chk_costes dropped.        |       |DROP FUNCTION icon_chk_costes        |
|   11|erp     |dbsrv3|      |wic_icon|function|icon_chk_empcode       |icon_chk_empcode       |1/1  |DROPPED|FUNCTION icon_chk_empcode dropped.       |       |DROP FUNCTION icon_chk_empcode       |
|   12|erp     |dbsrv3|      |wic_icon|function|icon_get_calppa        |icon_get_calppa        |1/1  |DROPPED|FUNCTION icon_get_calppa dropped.        |       |DROP FUNCTION icon_get_calppa        |
|   13|erp     |dbsrv3|      |wic_icon|function|icon_get_cambio        |icon_get_cambio        |1/1  |DROPPED|FUNCTION icon_get_cambio dropped.        |       |DROP FUNCTION icon_get_cambio        |
|   14|erp     |dbsrv3|      |wic_icon|function|icon_get_ctafin        |icon_get_ctafin        |1/1  |DROPPED|FUNCTION icon_get_ctafin dropped.        |       |DROP FUNCTION icon_get_ctafin        |
|   15|erp     |dbsrv3|      |wic_icon|function|icon_get_ctanem        |icon_get_ctanem        |1/1  |DROPPED|FUNCTION icon_get_ctanem dropped.        |       |DROP FUNCTION icon_get_ctanem        |
|   16|erp     |dbsrv3|      |wic_icon|function|icon_get_divred        |icon_get_divred        |1/1  |DROPPED|FUNCTION icon_get_divred dropped.        |       |DROP FUNCTION icon_get_divred        |
|   17|erp     |dbsrv3|      |wic_icon|function|icon_get_docnum        |icon_get_docnum        |1/1  |DROPPED|FUNCTION icon_get_docnum dropped.        |       |DROP FUNCTION icon_get_docnum        |
|   18|erp     |dbsrv3|      |wic_icon|function|icon_get_docser        |icon_get_docser        |1/1  |DROPPED|FUNCTION icon_get_docser dropped.        |       |DROP FUNCTION icon_get_docser        |
+-----+--------+------+------+--------+--------+-----------------------+-----------------------+-----+-------+-----------------------------------------+-------+-------------------------------------+

In this case a deletion of functions. The system shows:

  • Database
  • Sever
  • Scheme
  • Object Dictionary
  • Object type
  • Object code
  • Name
  • Operation status
  • Message
  • Notices
  • Executed statement, in this case a deletion (drop).

5.3.4 Examples

Create XUDP and XUDF

To create procedures and functions, the action compile is used and with 'type' informs the system if you want to create xudp procedures or xudf functions .

Creation of all XUDFs in the wic_icon dictionary

All functions cataloged in the wic_icon dictionary are created.

Copy
bin\ws-dbscript -syscode schema_code -dbms erptest -user ped -args p_action=compile,p_type=xudf,p_dict=wic_icon,p_pattern=%

Creation of all XUDP in the wic_icon dictionary

The procedures cataloged in the wic_icon are created.

Copy
bin\ws-dbscript -syscode schema_code -dbms erptest -user ped -args p_action=compile,p_type=xudp,p_dict=wic_icon,p_pattern=%

Creation of all XUDP of all application dictionaries

The cataloged procedures are created in all dictionaries of the application.

Copy
bin\ws-dbscript -syscode schema_code -dbms erptest -user ped -args p_action=compile,p_type=xudp,p_dict=,p_pattern=%

Nota

As seen in this example, by leaving the dictionary blank, the system compiles the procedures of all dictionaries.

Creation of all XUDPs that start with cpar of all dictionaries.

With this option, the XUDPs that start with cpar of cataloged dictionaries are created.

Copy
bin\ws-dbscript -syscode schema_code -dbms erptest -user ped -args p_action=compile,p_type=xudp,p_dict=,p_pattern=cpar%

Eliminate XUDF y XUDP

To eliminate procedures and functions, the action 'drop' is used and the type will inform the system if you want to eliminate xudp procedures or xudf functions.

Remove all XUDFs from the wic_icon dictionary: all functions cataloged in the wic_icon dictionary are deleted.

Copy
bin\ws-dbscript -syscode schema_code -dbms erptest -user mlg -args p_action=drop,p_type=xudf,p_dict=wic_icon,p_pattern=%

Remove all XUDPs from the wic_icon dictionary: All procedures cataloged in the wic_icon are removed.

Copy
bin\ws-dbscript -syscode schema_code -dbms erptest -user mlg -args p_action=drop,p_type=xudp,p_dict=wic_icon,p_pattern=%

Remove all XUDPs from all application dictionaries. All procedures cataloged in all application dictionaries are deleted.

Copy
bin\ws-dbscript -syscode schema_code -dbms erptest -user mlg -args p_action=drop,p_type=xudp,p_dict=,p_pattern=%

Nota

As seen in this example, by leaving the dictionary blank, the system eliminates the procedures of all dictionaries.

Remove all XUDPs that begin with 'cpar' from all dictionaries. With this option, the XUDPs that begin with cpar from the dictionaries cataloged for the database are eliminated.

Copy
bin\ws-dbscript -syscode schema_code -dbms erptest -user mlg -args p_action=drop,p_type=xudp,p_dict=,p_pattern=cpar%

5.4 Compilation via DBStudio

You can also create procedures and functions manually through DBStudio.

Compile code

Access the DBStudio tool, select server and database.

Right button to select compile code.

Data entry for compilation.

Message, with valid execution.

Detail of the compilation message, 0 errors

Message, with execution failed.

Detail of the compilation message, 1 error.