1 Ax.ext.db.schema

The package Ax.ext.db.schema groups the functionalities needed to audit, create and repair the database catalagued objects

Class Ax.ext.db.schema


Method Summary

Modifier and Type
Method
Description
object 
modelStatus(string type, config => {})
Verify if the logic model (cataloged in the dictionary) corresponds with the physical model (database) of each one of the objects (table, index, check, etc).
object 
modelCreate(string type, config => {})
Executes the statements of creation of structure (DDL) over one or several databases.
object 
modelUpgrade(string type, config => {})
Verify if the logic model (cataloged in the dictionary) corresponds with the physical model (database) of each one of the objects (table, index, check, etc).
object 
modelDrop(string type, config => {})
Remove one or several object physically from the database as cataloged in the dictionary.
object 
codeStatus(string type, config => {})
Remove one or several object physically from the database as cataloged in the dictionary.
object 
codeCompile(string type, config => {})
Remove one or several object physically from the database as cataloged in the dictionary.
object 
codeCompare(string table, string dict, config => {})
Compare (by date of last update) the objects (trig, xudf, xudp, table, alla) a dictionary database (origin), against other dictionary database (destiny).
object 
codeDrop(string type, config => {})
Remove one or several object physically from the database as cataloged in the dictionary.

Method Detail

Ax.ext.db.schema.modelStatus

object Ax.ext.db.schema.modelStatus(
	string type,
	config => {
		setDict(string);
		setPattern(string);
		setDebug(boolean);
	}
)
Info:
Verify if the logic model (cataloged in the dictionary) corresponds with the physical model (database) of each one of the objects (table, index, check, etc). It not only verifies but also gives an idea of what should be execute so that the logical model corresponds to the physical model.
Parameters:
type - all|TABLE|INDEX|FOREIGN|CHECK|TLOAD
dict - Dictionary where the object is found. This attribute is optional, if the object is reported it is taken from this dictionary. If it is not reported, the system search it in all the dictionarys of the application and it will execute the one that is defined in the wic_dbms_dicts befor
pattern - Filter pattern
debug - Debug
Returns:
object

Example
Copy
let rs = Ax.ext.db.schema.modelStatus('all', config => {
	config.setPattern("studio_%");
	config.setDict("wic_iges");
	config.setDebug(true);
});

Ax.ext.db.schema.modelCreate

object Ax.ext.db.schema.modelCreate(
	string type,
	config => {
		setDict(string);
		setTemp(string);
		setDebug(boolean);
	}
)
Info:

Executes the statements of creation of structure (DDL) over one or several databases. In the creation of the structure you can differentiate different objects to create.

  • Table: Just the creation of the table with its columns.
  • Index: Index, primary keys, foreign keys, etc.
  • Check: Checks.
  • Data upload: There are tables in which you want that when the table is created the system automatically loads records on this table.
Parameters:
type - all|TABLE|INDEX|FOREIGN|CHECK|TLOAD
dict - Selection condition of the SQL object
temp - Filter pattern
debug - Debug
Returns:
object

Example
Copy
let rs = Ax.ext.db.schema.modelCreate('index', config => {
	config.setPattern("studio_%");
	config.setDict("wic_iges");
	config.setDebug(true);
});

Ax.ext.db.schema.modelUpgrade

object Ax.ext.db.schema.modelUpgrade(
	string type,
	config => {
		setDict(string);
		setTemp(string);
		setDebug(boolean);
	}
)
Info:
Verify if the logic model (cataloged in the dictionary) corresponds with the physical model (database) of each one of the objects (table, index, check, etc). It not only verifies but also gives an idea of what should be execute so that the logical model corresponds to the physical model.
Parameters:
type - all|TABLE|INDEX|FOREIGN|CHECK|TLOAD
dict - Dictionary where the object is found. This attribute is optional, if the object is reported it is taken from this dictionary. If it is not reported, the system search it in all the dictionarys of the application and it will execute the one that is defined in the wic_dbms_dicts befor
temp - Filter pattern
debug - Debug
Returns:
object

Example
Copy
let rs = Ax.ext.db.schema.modelUpgrade('table', config => {
	config.setPattern("studio_%");
	config.setDict("wic_iges");
	config.setDebug(true);
});

Ax.ext.db.schema.modelDrop

object Ax.ext.db.schema.modelDrop(
	string type,
	config => {
		setDict(string);
		setTemp(string);
		setDebug(boolean);
	}
)
Info:
Remove one or several object physically from the database as cataloged in the dictionary.
Parameters:
type - all|TABLE|INDEX|FOREIGN|CHECK|TLOAD
dict - Dictionary where the object is found. This attribute is optional, if the object is reported it is taken from this dictionary. If it is not reported, the system search it in all the dictionarys of the application and it will execute the one that is defined in the wic_dbms_dicts befor
temp - Filter pattern
debug - Debug
Returns:
object

Example
Copy
let rs = Ax.ext.db.schema.modelDrop('table', config => {
	config.setPattern("studio_%");
	config.setDict("wic_iges");
	config.setDebug(true);
});

Ax.ext.db.schema.codeStatus

object Ax.ext.db.schema.codeStatus(
	string type,
	config => {
		setDict(string);
		setTemp(string);
		setSoft(boolean);
		setDebug(boolean);
	}
)
Info:
Remove one or several object physically from the database as cataloged in the dictionary.
Parameters:
type - Type of object (trig|proc|func).
dict - Dictionary where the object is found. This attribute is optional, if the object is reported it is taken from this dictionary. If it is not reported, the system search it in all the dictionarys of the application and it will execute the one that is defined in the wic_dbms_dicts befor
temp -  Objects to lookup, a object code or a style pattern capuntes%, all that begins by capuntes. This attribute is optional, if the system is not informed, it will take all the objects of this type.
soft - If it is true, the physical existence is not verified.
debug - Debug
Returns:
object

Example
Copy
let rs = Ax.ext.db.schema.codeStatus('trig', config => {
	config.setPattern("wic_jdic_%");
	config.setDebug(true);
});

The resultset:

Copy
+-------+--------+---------------+-------+-------+-------+---------------------------+-----------------------+---------------------------+-------+-------+------------------------+-----------------------+
|<null> |<null>  |<null>         |<null> |<null> |<null> |<null>                     |<null>                 |<null>                     |<null> |<null> |<null>                  |<null>                 |
|seqno  |database|server         |schema |dict   |type   |code                       |table                  |name                       |group  |status |object_time             |compile_time           |
|integer|char(0) |char(0)        |char(0)|char(0)|char(0)|char(0)                    |char(0)                |char(0)                    |char(0)|char(0)|datetime                |datetime               |
+-------+--------+---------------+-------+-------+-------+---------------------------+-----------------------+---------------------------+-------+-------+------------------------+-----------------------+
|1      |wic_iges|dbsrv1-informix|       |wic    |TRIG   |wic_jdic_chkdata_upd       |wic_jdic_chkdata       |wic_jdic_chkdata_upd       |1/1    |VALID  |Mar 11, 2013 8:48:44 AM |Mar 20, 2018 2:23:47 PM|
|2      |wic_iges|dbsrv1-informix|       |wic    |TRIG   |wic_jdic_coldata_upd       |wic_jdic_coldata       |wic_jdic_coldata_upd       |1/1    |VALID  |Mar 11, 2013 12:27:14 PM|Mar 20, 2018 2:23:47 PM|
|3      |wic_iges|dbsrv1-informix|       |wic    |TRIG   |wic_jdic_include_del       |wic_jdic_include       |wic_jdic_include_del       |1/1    |VALID  |Apr 29, 2010 6:41:31 PM |Mar 20, 2018 2:23:47 PM|
|4      |wic_iges|dbsrv1-informix|       |wic    |TRIG   |wic_jdic_include_locale_del|wic_jdic_include_locale|wic_jdic_include_locale_del|1/1    |VALID  |Jan 4, 2012 4:01:56 PM  |Mar 20, 2018 2:23:47 PM|
|5      |wic_iges|dbsrv1-informix|       |wic    |TRIG   |wic_jdic_include_locale_ins|wic_jdic_include_locale|wic_jdic_include_locale_ins|1/1    |VALID  |Jun 11, 2008 1:50:01 PM |Mar 20, 2018 2:23:47 PM|
|6      |wic_iges|dbsrv1-informix|       |wic    |TRIG   |wic_jdic_include_locale_upd|wic_jdic_include_locale|wic_jdic_include_locale_upd|1/1    |VALID  |Mar 11, 2013 1:18:11 PM |Mar 20, 2018 2:23:47 PM|
|7      |wic_iges|dbsrv1-informix|       |wic    |TRIG   |wic_jdic_include_upd       |wic_jdic_include       |wic_jdic_include_upd       |1/1    |VALID  |Dec 24, 2010 10:41:04 AM|Mar 20, 2018 2:23:47 PM|
|8      |wic_iges|dbsrv1-informix|       |wic    |TRIG   |wic_jdic_jsfuncs_del       |wic_jdic_jsfuncs       |wic_jdic_jsfuncs_del       |1/1    |VALID  |Jan 2, 2012 4:51:25 PM  |Mar 20, 2018 2:23:47 PM|
|9      |wic_iges|dbsrv1-informix|       |wic    |TRIG   |wic_jdic_jsfuncs_upd       |wic_jdic_jsfuncs       |wic_jdic_jsfuncs_upd       |1/1    |VALID  |Jun 22, 2007 1:14:56 PM |Mar 20, 2018 2:23:47 PM|
|10     |wic_iges|dbsrv1-informix|       |wic    |TRIG   |wic_jdic_lbldata_upd       |wic_jdic_lbldata       |wic_jdic_lbldata_upd       |1/1    |VALID  |Mar 10, 2013 11:50:34 PM|Mar 20, 2018 2:23:47 PM|
|11     |wic_iges|dbsrv1-informix|       |wic    |TRIG   |wic_jdic_softref_help_upd  |wic_jdic_softref_help  |wic_jdic_softref_help_upd  |1/1    |VALID  |Feb 23, 2017 12:42:48 PM|Mar 20, 2018 2:23:47 PM|
|12     |wic_iges|dbsrv1-informix|       |wic    |TRIG   |wic_jdic_tabdata_upd       |wic_jdic_tabdata       |wic_jdic_tabdata_upd       |1/1    |VALID  |Mar 11, 2013 12:33:21 PM|Mar 20, 2018 2:23:47 PM|
+-------+--------+---------------+-------+-------+-------+---------------------------+-----------------------+---------------------------+-------+-------+------------------------+-----------------------+

Ax.ext.db.schema.codeCompile

object Ax.ext.db.schema.codeCompile(
	string type,
	config => {
		setDict(string);
		setTemp(string);
		setDebug(boolean);
	}
)
Info:
Remove one or several object physically from the database as cataloged in the dictionary.
Parameters:
type -  Type of object (xudf|xudp|proc|trig|all). If it is 'all' it will be processed in this order.
dict - Dictionary where the object is found. This attribute is optional, if the object is reported it is taken from this dictionary. If it is not reported, the system search it in all the dictionarys of the application and it will execute the one that is defined in the wic_dbms_dicts befor
temp - Objects to create, a object code or a style pattern capuntes%, all that begins by capuntes. This attribute is optional, if the system is not informed, it will take all the objects of this type.
debug - Debug
Returns:
object

Example
Copy
let rs = Ax.ext.db.schema.codeStatus('all', config => {
	config.setPattern("capuntes_%");
    config.setDict("wic_icon")
	config.setDebug(true);
});

The result is

Copy
+-------+-----------+---------------+-------+--------+-------+------------------------------+--------+------------------------------+-------+-------+------------------------+------------------------+
|<null> |<null>     |<null>         |<null> |<null>  |<null> |<null>                        |<null>  |<null>                        |<null> |<null> |<null>                  |<null>                  |
|seqno  |database   |server         |schema |dict    |type   |code                          |table   |name                          |group  |status |object_time             |compile_time            |
|integer|char(0)    |char(0)        |char(0)|char(0) |char(0)|char(0)                       |char(0) |char(0)                       |char(0)|char(0)|datetime                |datetime                |
+-------+-----------+---------------+-------+--------+-------+------------------------------+--------+------------------------------+-------+-------+------------------------+------------------------+
|1      |demo_sports|dbsrv2-informix|       |wic_icon|XUDP   |capuntes_cpar_ins             |        |capuntes_cpar_ins             |1/1    |VALID  |Dec 23, 2014 4:33:29 PM |May 15, 2019 11:39:59 AM|
|2      |demo_sports|dbsrv2-informix|       |wic_icon|XUDP   |capuntes_ctax_move_head       |        |capuntes_ctax_move_head       |1/1    |VALID  |Feb 24, 2020 4:34:53 PM |Mar 5, 2020 5:21:49 PM  |
|3      |demo_sports|dbsrv2-informix|       |wic_icon|XUDP   |capuntes_ctax_move_line_delete|        |capuntes_ctax_move_line_delete|1/1    |VALID  |Feb 25, 2020 3:14:59 PM |Mar 5, 2020 5:50:10 PM  |
|4      |demo_sports|dbsrv2-informix|       |wic_icon|XUDP   |capuntes_not_negative         |        |capuntes_not_negative         |1/1    |VALID  |Oct 21, 2019 10:29:16 AM|Nov 13, 2019 1:21:42 PM |
|5      |demo_sports|dbsrv2-informix|       |wic_icon|XUDP   |capuntes_reorder              |        |capuntes_reorder              |1/1    |VALID  |Jun 17, 2020 12:07:58 PM|Jun 18, 2020 1:28:35 AM |
|6      |demo_sports|dbsrv2-informix|       |wic_icon|XUDP   |capuntes_salagr               |        |capuntes_salagr               |1/1    |VALID  |Mar 28, 2019 10:56:21 AM|May 15, 2019 11:39:59 AM|
|7      |demo_sports|dbsrv2-informix|       |wic_icon|XUDP   |capuntes_taptcuen             |        |capuntes_taptcuen             |1/1    |VALID  |May 8, 2012 6:07:12 PM  |May 15, 2019 11:39:59 AM|
|8      |demo_sports|dbsrv2-informix|       |wic_icon|XUDP   |capuntes_saldos               |        |capuntes_saldos               |1/1    |VALID  |Mar 28, 2019 10:52:58 AM|May 15, 2019 11:40:04 AM|
|9      |demo_sports|dbsrv2-informix|       |wic_icon|TRIG   |capuntes_del                  |capuntes|capuntes_del                  |1/1    |VALID  |Jan 29, 2020 2:34:08 PM |Mar 10, 2020 1:50:49 AM |
|10     |demo_sports|dbsrv2-informix|       |wic_icon|TRIG   |capuntes_ins                  |capuntes|capuntes_ins                  |1/1    |VALID  |Apr 15, 2019 11:39:46 AM|May 15, 2019 11:40:36 AM|
|11     |demo_sports|dbsrv2-informix|       |wic_icon|TRIG   |capuntes_upd                  |capuntes|capuntes_upd                  |1/1    |VALID  |Jan 29, 2020 2:43:43 PM |Mar 10, 2020 1:51:07 AM |
+-------+-----------+---------------+-------+--------+-------+------------------------------+--------+------------------------------+-------+-------+------------------------+------------------------+

Ax.ext.db.schema.codeCompare

object Ax.ext.db.schema.codeCompare(
	string table,
	string dict,
	config => {
		setTemp(string);
		setDebug(boolean);
	}
)
Info:
Compare (by date of last update) the objects (trig, xudf, xudp, table, alla) a dictionary database (origin), against other dictionary database (destiny).
Parameters:
table - Dictionary table from which you want to compare content.Possible values can be wic_jrep_object, wic_trig_object, wic_xudf_object, wic_xudp_object, wic_xsql_script, wic_proc_object, wic_table_object, wic_jdic_tabdata, wic_jdic_colattr, wic_jdic_collist, wic_jdic_include, wic_change_log
dict - Dictionary where the object is found. This attribute is optional, if the object is reported it is taken from this dictionary. If it is not reported, the system search it in all the dictionarys of the application and it will execute the one that is defined in the wic_dbms_dicts befor
temp - Objects to create, a object code or a style pattern capuntes%, all that begins by capuntes. This attribute is optional, if the system is not informed, it will take all the objects of this type.
debug - Debug
Returns:
object

Example

Compares the triggers of a dictionary (of the connection of the script) and the destiny.

Copy
let rs = Ax.ext.db.schema.codeCompile('wic_jrep_object', 'wic_copy_a', config => {
	config.setPattern("studio_%");
	config.setDebug(true);
});

To execute it from the console write the following: bin\ws-dbscript -dbms wic_test_a -file test_compare.xml -user mlg

The xsql-script prints the following result:

Copy
+-----+--------+------+------+--------+----------+----+-------------------------------+---------------------+--------+---------+
|seqno|database|server|schema|dict_src|dict_dst  |type|code                           |date_src             |date_dst|status   |
+-----+--------+------+------+--------+----------+----+-------------------------------+---------------------+--------+---------+
|    1|wic_misc|dbsrv1|      |wic_misc|wic_copy_a|trig|cenllote_del                   |2007-08-24 13:42:53.0|        |NOT FOUND|
|    2|wic_misc|dbsrv1|      |wic_misc|wic_copy_a|trig|facturah_del                   |2008-03-26 20:16:46.0|        |NOT FOUND|
|    3|wic_misc|dbsrv1|      |wic_misc|wic_copy_a|trig|capuntes_del                   |2008-04-09 16:49:43.0|        |NOT FOUND|
|    4|wic_misc|dbsrv1|      |wic_misc|wic_copy_a|trig|repalbl_del                    |2008-01-25 13:20:05.0|        |NOT FOUND|
|    5|wic_misc|dbsrv1|      |wic_misc|wic_copy_a|trig|repairl_upd                    |2008-01-25 12:55:21.0|        |NOT FOUND|
|    6|wic_misc|dbsrv1|      |wic_misc|wic_copy_a|trig|cterceor_ins                   |2007-11-09 17:44:28.0|        |NOT FOUND|
|    7|wic_misc|dbsrv1|      |wic_misc|wic_copy_a|trig|taptcuen_del                   |2008-02-15 17:26:25.0|        |NOT FOUND|
|    8|wic_misc|dbsrv1|      |wic_misc|wic_copy_a|trig|ws_cvenfacl_del                |2008-03-12 12:09:02.0|        |NOT FOUND|
|    9|wic_misc|dbsrv1|      |wic_misc|wic_copy_a|trig|ws_cvenfacl_upd                |2008-03-12 12:06:04.0|        |NOT FOUND|
+-----+--------+------+------+--------+----------+----+-------------------------------+---------------------+--------+---------+
Copy
+-----+--------+------+------+--------+----------+-----+----------------------------+---------------------+--------+---------+
|seqno|database|server|schema|dict_src|dict_dst  |type |code                        |date_src             |date_dst|status   |
+-----+--------+------+------+--------+----------+-----+----------------------------+---------------------+--------+---------+
|    1|wic_misc|dbsrv1|      |wic_misc|wic_copy_a|table|resultats_tem               |2008-04-04 12:44:34.0|        |NOT FOUND|
|    2|wic_misc|dbsrv1|      |wic_misc|wic_copy_a|table|repaird                     |2008-01-24 16:50:44.0|        |NOT FOUND|
+-----+--------+------+------+--------+----------+-----+----------------------------+---------------------+--------+---------+
Copy
seqno: Identification number of the object.
database: Database.
server: Server where exist the database.
schema: Name of the schema.
dict_src: Origin dictionary (of the connection of execution of the xsql-script).
dict_dst: Destiny dictionary, the one that is placed in the attribute dict.
type: Type of object, if it is executed with all, here it will appear the type of object (trig, xudf, xudp, etc).
code: Code of the object.
date_src: Date of the last modification in the origin dictionary.
date_dst: Date of the last modification in the destiny dictionary.
status: Result of the comparation:
   OLD: This means that the object is old (that the update date in the origin is higher than the destiny).
   NEW: This means that  the update date in the destiny is higher than the origin.
   EQUAL: This means that the update date is equal in the origin than in destiny.
   NOT FOUND: This means that the object was not found in the destiny dictionary.

Ax.ext.db.schema.codeDrop

object Ax.ext.db.schema.codeDrop(
	string type,
	config => {
		setDict(string);
		setTemp(string);
		setDrop-all(boolean);
		setDebug(boolean);
	}
)
Info:
Remove one or several object physically from the database as cataloged in the dictionary.
Parameters:
type -  Type of object (xudf|xudp|proc|trig|all). If it is 'all' it will be processed in this order.
dict - Dictionary where the object is found. This attribute is optional, if the object is reported it is taken from this dictionary. If it is not reported, the system search it in all the dictionarys of the application and it will execute the one that is defined in the wic_dbms_dicts befor
temp - Objects to create, a object code or a style pattern capuntes%, all that begins by capuntes. This attribute is optional, if the system is not informed, it will take all the objects of this type.
drop-all - Debug
debug - Debug
Returns:
object

Example
Copy
let rs = Ax.ext.db.schema.codeStatus('trig', config => {
	config.setPattern("capuntes_%");
    config.setDict("wic_misc")
	config.setDebug(true);
	config.setDropAll(true)
});
Copy
+--------------+------+--------+-------+------------+-----+------+-----------------------------+-------+
|dbms          |schema|dict    |type   |code        |group|error |message                      |warning|
+--------------+------+--------+-------+------------+-----+------+-----------------------------+-------+
|demo_formacion|      |wic_misc|trigger|capuntes_del|     |false |TRIGGER capuntes_del dropped.|       |
|demo_formacion|      |wic_misc|trigger|capuntes_ins|     |false |TRIGGER capuntes_ins dropped.|       |
+--------------+------+--------+-------+------------+-----+------+-----------------------------+-------+