This translation is older than the original page and might be outdated.



Integration Connector with Files and Databases

The XOne Interface is one of the components of XOne Technology, its function is to transfer or convert data from one database to another , through a simple XML configuration file.

The conversion or transfer of data does not necessarily have to be destined to another Data Base, being able to have as destination text files, XML …

Although this product can be used independently of the other XOne technology systems, it is usually used when customers do not want to make any changes to their systems and want to mobilize their application, creating an independent database for the mobility project that interacts with your system through the XOne Interface.

Some examples of the Interface we have in production:


CLIENT´S SYSTEM DESTINATION SYSTEM
SAP ORACLE
ORACLE ORACLE
ORACLE MS SQL SERVER
MS SQL SERVER MYSQL
TEXT FILES DATABASES


In general, we can use any relational Database that can be connected through OLEDB or ODBC.

Necessary Files

File Name Description
itfxone.exe Executable Program
itfxone.ini XML with the path where the configuration file is placed in.
itfxone.xml XML with all the necessary configuration for the data transfer

“itfxml.ini” File


The file with the path where the configuration XML is, has a unique line where the path and the XML file name are put.

This file has to be in the same path where the program executable is placed in.

Structure of the itfxml.ini file

[XML]
 
Name=C:\Programas_Xone\CGInterClientXone\itfxone.xml
  • Both the [XML] node and the “Name” attribute are mandatories.
  • The XML configuration file here referenced, can be name as we want to, not necessarily itfxone.xml.

“itfxone.xml” File


In this XML file everything is configured.

  • Connection with the source database.
  • Connection with the destination database.
  • How often the process is executed.
  • What is done with the source fields in the destination.
  • Operations to made after passing the data from the source to the destination.
  • It allows the data transfer of text, integer, with decimals type, of date type, files…


This file has 3 main nodes:

Name node Explanation
<app> In this node we define the connection with the source and destination databases, as well as the name of some special fields and how often this process is going to be executed.
<transforms type=“client-to-source”> In this node we define the actions and data transformations from the client´s DB to the XOne´s .
<transforms type=“source-to-client”> In this node we define the actions and data transformation from the XOne database to the client´s.


Simplified structure of the itfxone.xml file

<?xml version="1.0" encoding="ISO-8859-1"?>
 
<xml>
 
	<interface>
 
		<app name="INTERFASE" logoper="true" sqlfieldname="CGSSQL"  slash="false" rowidfieldname="CGSROWID">
 
			<dsn>
 
			...
 
			</dsn>
 
			<schedule type="continue" interval="30"/>
 
		</app>
 
 
 
		<transforms type="client-to-source">
 
			<transform name="DELEGACION">
 
				<coll ..... >
 
				...
 
				</coll>
 
				...
 
			</transform>
 
			...
 
		</transforms>
 
 
 
		<transforms type="source-to-client">
 
			<transform name="pedidos">
 
				<coll ..... >
 
				...
 
				</coll>
 
				....
 
			</transform>
 
			...
 
		</transforms>	
 
	</interface>
 
</xml>
The nodes are executed in in order of appearance, if we want to execute first the <transforms type=“client-to-source”> node is so simple as it appears first in the XML file, and the same thing happens to the different transform there are inside, they are executed by appearing order in the file.

Detail of the ‹app› node

<app name="INTERFACE" logoper="true" sqlfieldname="CGSSQL"  slash="false" rowidfieldname="CGSROWID">
 
	<!-- 
 
	logoper="true": todo lo que hace la interface, queda registrado en el visor de sucesos de windows.
 
		IMPORTANTE!!! en herramientas administrativas, hay que marcar en las propiedades del visor, 
 
		"sobreescribir cuando sea necesario" para evitar errores con un log muy extenso.		
 
	sqlfieldname="CGSSQL": en lugar de utilizar el campo "SQL" de la tabla master_replica_queue, 
 
		utiliza el que le especifiquemos aqui, puesto que hay algunos DBMS en los que "SQL" 
 
		es una palabra reservada (MYSQL 5.X). 
 
	slash="false": POR DEFECTO, cuando nos encontramos un caracter "\", lo duplicamos, ya que algunos sistemas
 
		de base de datos (MYSQL) lo eliminan, por lo que nosotros añadimos otro para que no haya errores. 
 
		Para aquellos sistemas que no eliminen el caracter "\" poner a false.
 
	rowidfieldname="CGSROWID": En la tecnología XONE todas las tablas deben contener un campo "ROWID",
 
 		que resulta ser una palabra reservada en ORACLE, podemos utilizar este parámetro para indicar
 
 		cómo hemos llamado a dicho campo en este DBMS.
 
	-->
 
 
 
	<dsn>
 
		<client type="system" name="DSN_BD_ORIGINAL_CLIENTE" user="ROOT" pwd="cgs"/>	
 
		<!-- 
 
		type="system"		: El DSN es de sistema.
 
		name="xxxxx" 		: Nombre del DSN de sistema que apunta a la BD origen del cliente.
 
		user="xxx" y pwd="xxx"	: Hemos de especificar el usuario y la contraseña de la BD.
 
		--> 
 
		<source type="system" name="DSN_BD_MOVILIDAD" user="sa" pwd=""/>
 
		<!-- 
 
		type="system"		: El DSN es de sistema.
 
		name="xxxxx" 		: Nombre del DSN de sistema que apunta a la BD destino XONE.
 
		user="xxx" y pwd="xxx"	: Hemos de especificar el usuario y la contraseña de la BD.
 
		--> 
 
		<optional type="system" name="DSN_BD_OPTIONAL_CLIENTE" user="root"/>
 
		<!-- DSN opcional a la BD de origen, para multiconexión. -->	
 
	</dsn>
 
	<schedule type="continue" interval="30"/>
 
	<!-- 
 
	type="continue"      : Para que se ejecute cada cierto tiempo, especificado por interval.
 
	     "one-execution" : Sólo se ejecuta una vez, al terminar se cierra el programa.
 
	interval="xxx"        : Intervalo en segundos para la siguiente ejecución si type="continue".
 
	-->
 
</app>


Detail of the transforms node

<transforms type="client-to-source">
 
<!-- 
 
type="client-to-source" : Seleccionamos datos de la BD del cliente para transformarlos y pasarlos a la BD Xone.
 
type="source-to-client" : Seleccionamos datos de la BD XOne para transformarlos y pasarlos a la BD del cliente.
 
-->
 
	<transform name="Nombre_de_la_transformacion">
 
	<!-- 
 
	Tendremos un nodo transform por cada tabla que vayamos a rellenar en la BD Destino.
 
	-->
 
	<coll dest-table="nombre_tabla" source-table="Select ..." tbl-queue="false">
 
	<!-- PRIMERO SE COGE LA TABLA DESTINO. DESPUES SE SELECCIONA EL SQL DE LA TABLA ORIGEN, SELECCIONANDO LOS CAMPOS
 
     QUE QUEREMOS PASAR DEL CLIENTE AL DESTINO 
 
     SERÍA CONVENIENTE LIMITAR LA CANTIDAD DE REGISTROS PARA NO TRANSFORMAR CADA VEZ MUCHOS REGISTROS, YA QUE PUEDE LLEVAR A 
 
     ERRORES CON EL ODBC DEL ORIGEN O DEL DESTINO. NO ES LO MISMO TRANSFORMAR 100 REGISTRO QUE 100.000 REGISTROS.-->
 
 
 
		<data-condition>
 
			<client type="##ALL##"/>
 
		</data-condition>
 
		<prop source-name="nombre_campo" dest-name="nombre_campo" key="true" saved-source="true">
 
			<oper type="copy"/>
 
		</prop>
 
		<prop 
 
		...
 
		</prop>
 
		...
 
		<after-action>
 
			<action name="...">
 
				<param name="source" value="...>
 
			</action>
 
		</after-action>	
 
	</coll>
 
</transform>
 
....
 
</transforms>

XML Files Nodes


Node that is placed in the upper part of the file. It is useful so that it can be used the ISO-8859-1 codification, and admits the accents, among other things.

OPTIONAL

Main node, it is the father of all the nodes, and every file must have this node in which everything else will go.

MANDATORY

Child node of the xml node, within this one the rest of options will go.

MANDATORY



Node in which the origin and destination databases are defined to be able to perform the Interface.

MANDATORY. This node has several attributes, such as:

NAME=“INTERFASE” name of the application.
TIMEACCESS=“false” attribute of system, it is mandatory.
LOGOPER=“true” to enable the LOG, by showing everything the CGInterclientXone does, in the Windows Events Display.
SQLFIELDNAME the application when transfers the data from a database toward another one, also, it writes at the replica queue.


This table has an SQL field, which is used to enter the SQL of the replica. Well, that name of that field is reserved word in some database system, like MYSQL 5.0.

Then what you have to do is create the replica queue, and change the SQL name to any other name, and then put this name in that attribute, so that the program knows what change there is.

SLASH attribute to which we can say not to duplicate the “\” character. The program duplicates it automatically, but there are some database systems that it is not necessary to duplicate it, by putting this attribute to false.


Duplicating is because there are systems, that attribute is a reserved word, and to tell you that we do not want you to do anything, because we duplicate it, and then the system removes the duplicate.


Node in which there are all the calls to the databases with the CGIntercliente acts with. It is made up of children nodes, with the calls to the databases.

<client type="system" name="DSN_BD_Origen" user="usuario" pwd="contraseña"/>
 
<source type="system" name="DSN_BD_Destino" user="usuario" pwd="contraseña"/>

The first node, CLIENT, is the node that has the call to the source database, to the client's database. The second node, SOURCE, is the call to the destination database, the mobility database, of XOne. These nodes have the following attributes:

Attributes
TYPE= it is necessary to put system, since only are allowed DSN of system, that are safer than another type of DSN, such as the file ones.
NAME= name of the DSN of the system we have created.
USER= database user.
PWD= password if it, if it had it, if it hadn´t, it remains empty or even this attribute is not put.

There is a third node, that can be put for the multi connection.

<optional type="system" name="DSN_BD_OPTIONAL_CLIENTE" user="root"/>
As we can see, it is made up the same than the rest of nodes, but its name is “optional”.


Node in which is indicated how often the interface is executed.

It has two attributes:

Attributes
TYPE it gets continue, to indicate that it has to continue the time that is told in the following attribute.
INTERVAL here gets the waiting time to execute again. If it gets value 0, it is continue and never stops. If we want to execute each 10 minutes, we will have to put 600.



Node with which it is decided in which order the data is passed, whether from the database declared in the CLIENT node to the SOURCE or vice versa. The type is put in the TYPE attribute, putting “client-to-source” or “source-to-client”, depending on the order.

Once we have decided in which order the data are transfered, we begin to define each one of the transform nodes. Each of these nodes is made, for each of the tables that are passed from one side to another.


This node has an attribute, NAME, which value is the name given to the transform node, and it must be unique in the whole XML file.



Node in which the source table and the destination of the data are taken.

Its attributes are:

Attributes
DEST-TABLE Attribute that has the name of the the destination table.
SOURCE-TABLE Attribute that takes the name of the table that has the data. In this attribute an SQL can be put, everything complex that admits the database manager system we are using.
ROWS-LIMIT DEPRECATED. If we want to limit the number of record processed, it would have to support in the DBMS functions we are using (TOP, LIMIT, ROWNUM, etc).
LIMIT-END DEPRECATED, similar than the previous one, but for the deletes. If we want to limit the number of records processed it would have to support in the DBMS functions we are using (TOP, LIMIT, ROWNUM, etc).
TBL-QUEUE By default is worth is TRUE. If we put it to false, we tell to the interface DO NOT fill the TBL field of the master_replica_queue table.
FILE Attribute to tell to the program that we are going to make the data transfer from a file. If it is not put, it is false. It is useful so that when performing the transfer of the numeric fields with its decimals, it is done in a correct way.
ALWAYS This attribute is useful to tell the program that the interface is to transfer data from a database toward a text file. And in each transfer of the interface, only it is transfered a document that meets the condition. This is done because there are some clients that read the whole file and it is assumed that it only has a document inside it.
DATA-SOURCE Attribute part of the multi connection. If it does not exist, it takes as source the DSN there is in the “client”node of the DSN node. If it exists, it takes as DSN the “optional” node, that are going to have as DSN name the one it was put here, and vice versa.
ALWAYS-INSERT Attribute that if we are going to make an update by a change in the data transfered, really in the replica queue, master_replica_queue, it is put like an insert.


<data-condition>  
 
<client type="##ALL##"/>    
 
</data-condition>
Mandatory node to be able to work.



From this moment on, we start to put the different nodes, “prop”, that take the different fields, saying of each field, the type of transfer that is made of it, whether it is primary key or not, or the type of field that is.

Attributes of the “prop” node:

Attributes of the PROP NODE
SOURCE-NAME: Name of the source field.
DEST-NAME Name of the destination field.
TYPE Attribute to tell the type of data of the field that is going to be transfered. There are several options: T:Text type field.D:Date type field. Nx: Numeric field. X:To transfer data that are going to be keys.
KEY To tell it that the field is primary key or it is not in the destination table. By this field are made the queries about if it exist the record in the destination table. The key, of course, may be multiple, so it can exist more than a field that is the primary key of the record. This field is mandatory that at least one of the “prop” that the “coll” has, must have this attribute to true.
SAVED-SOURCE Attribute that will save in a macro the value that the ““source name”” field has, to later performing operations over the fields that meet the conditions that saves the macro. The macro is ##SOURCEKEYVALUES##.
SAVED-DEST Attribute that saves the values that has the “dest -name” field in a macro, to later operating with the records that meet the condition. The macro ##DESTKEYVALUES##.
FILLFIELD Attribute to add to the destination field the value this attribute has. It is accompanied by the two attributes that are below.
LENGTH Number of characters that the “fillfield” attribute adds to the destination field.
ALIGNAlignment of the characters added to the destination field. If nothing is put it is left. To make a right alignment we need to put “rigth”.
ALWAYS-UPDATEIt inserts a modification of that field in the master_replica_queue always, although its value is not modified.
NOT-REPLICATEAttribute to indicate that if the operation of this field is inserted into the operations of the master_replica_queue. If it is true this value is not inserted, if it does not exist or it is false, it will be inserted in the replica operations.


Types of operations than can be made with the fields we want transfer from a table into another one, in the “prop” node:

Types of operations
SETVAL With this operation we put a given value in the destination field. For that, the “prop” node, only has the type of the field, “type”, and the name of the destination field “dest-name”.


At the example, we are putting in the IDFATHER field of the destination table that is numeric type, N, the value 1.

        <prop dest-name="IDPADRE" type="N">
 
	        <oper type="setval" value="1"/>
 
        </prop>


In this example we put the “xone” value in the destination field NAME, that is text type.

        <prop dest-name="NOMBRE" type="T">
 
	        <oper type="setval" value="xone"/>
 
        </prop>


COPY Operation to transfer the value of a source field to a destination field. This is the most use operation. This node has an attribute to tell the source field , “source-name”, another to tell the destination attribute, “dest-name” which are mandatories. The rest of fields are not mandatories, such as the type, since if it is not put, it takes that is a text type, although it is advisable to put the type of the field always to be sure about what we are doing.


Now, we are going to put different examples that made this operation:

EXAMPLE 1
Node which transfers the value of the “delegación” field to the “ETIQUETA” field. This field is text type. Also is a primary key so to look if this field exists in the destination, we look with the “where” by this field. Besides, it is being told that saves the value of the source in the macro ##SOURCEKEYVALUES##, and to save the value of the destination in the macro ##DESTKEYVALUES##.

                <prop source-name="delegación" dest-name="ETIQUETA" key="true" type="T" saved-source="true" saved-dest="true">
 
		        <oper type="copy"/>
 
                </prop>


EXAMPLE 2
Node which transfers the value of the “PASSWORD_E” field to the PWD field. As we can see it has the X type, so it is being told that is a password field, and its value is saved encrypted.


           <prop source-name="PASSWORD_E" dest-name="PWD" type="X">
 
                    <oper type="copy"/>
 
           </prop>


EXAMPLE 3
Node which transfers the value of the “DESCPTE” field to the “INCIDENCIA” field. It is text type. Also, we can see that it has the “always-update” attribute, so we are forced it to insert at the “master_replica_queue” replica queue an update although its value does not change.


        <prop source-name="DESCPTE" dest-name="INCIDENCIA" key="false" type="T" always-update="true">
 
	          <oper type="copy"/>
 
        </prop>


EXAMPLE 4
Node which transfers the value of the “FECCARGA” field to the “FECHA” field. The field is date type. Also, we can see a new node, FORMAT, node used within the “prop” nodes, it is useful to format the value in the destination with the features indicated in the value attribute.
At the example, when putting it, we are telling that in the destination the date must be inserted in this way: day-month-year.


         <prop source-name="FECCARGA" dest-name="FECHA" type="D">				
 
                  <oper type="copy"/>
 
                  <format name="dest-name" value="dd/mm/yyyy"/>
 
         </prop>


EXAMPLE 6
Node which transfers the data of the “CODAVISO” field to the “TIPOPARTE” field, and we see that is text type. Besides, we can see there is the “format” node. Here we can see it has a new attribute, “trim”.
This attribute deletes or not blank spaces that come from the source in the destination. If the attribute is not defined it is to “true”, that is, it deletes the blank spaces. In order it works, it is necessary to put in the “value” attribute, the “NULL” value.


        <prop source-name="CODAVISO" dest-name="TIPOPARTE" type="T">
 
	     <oper type="copy"/>
 
	     <format value="NULL" trim="false"/>
 
        </prop>


EXAMPLE 7
Node which transfers the data of the “PRETAR” field to the “PRECIO” field. It is numeric type, and specifically with 5 decimals. In order the copy becomes well, it is being put the “format” node, by putting exactly the number of decimals that is going to be put.


        <prop source-name="PRETAR" dest-name="PRECIO" type="N5">
 
	     <oper type="copy"/>
 
	     <format name="dest-name" value="0.00000"/>
 
        </prop>


EXAMPLE 8
Node which transfers the value of the “delegacion” to the “NOMBRE2” field. It is text type. Also we can see that it has the “fillfield” attribute, with which we are telling it that in the destination we have to add 0.
With the “length” attribute we tell it that the destination field must have 10 characters as total value, so the program takes the length of the source field, and the amount of characters having less than 10, is the number of 0 that has to insert in the destination field.
The 0 will be added by the right part, this is indicated with the “align” attribute.


        <prop source-name="delegación" dest-name="NOMBRE2" key="true" fillfield="0" length="10" align="rigth" type="T" saved-source="true" saved-dest="true">
 
	        <oper type="copy"/>					
 
        </prop>



SOURCE-COPY Operation to copy the value of the source field into the destination field. We must take into consideration that both the source field and the destination one, are from the same table, the table that there is in dest-table attribute.


The example saves the value that there is in IDUSUARIO into IDUSUARIO2. This is useful for the selectivity, to save the value in a second field, and this field is also a field which decides the selectivity of this table.

        <prop source-name=" IDUSUARIO " dest-name=" IDUSUARIO2"  type="N">
 
	         <oper type="source-copy"/>
 
        </prop>
SUM Operation to sum the value taken from the source field into the destination field. Only is valid for numeric fields.


The example sums the value there is in the source field of the source-name, AMOUNT, to the value there is in the destination of dest-name, AMOUNT.

        <prop source-name="CANTIDAD" dest-name="CANTIDAD"  type="N2">
 
	        <oper type="sum"/>
 
	        <format name="dest-name" value="0.00"/>
 
        </prop>


MAPVAL Operation to transfer data from fields related to values there are into another tables. What it would be in our mappings the fields of IDEMPRESA or IDUSUARIO fields. For this, what is done is take the source field value, and look for it in a table, when it finds the value, puts the value of a field that we say of that table in the beginning destination field.


EXAMPLE
At the example we can see, we take the value of the “delegación” field and it is compared to the “ETIQUETA” field puts in the “mapfld” attribute that exists in the “Gen_Empresa” table, defined in the “source” attribute.
If it exists a record having that value, that there only has to be one, since the field by which the search is made in the “Gen_Empresa” table, has to be the primary key of it, taking the value of the field defined in the “targetfld” attribute, ID, and puts it in the “dest-name” field, “IDEMPRESA”.


        <prop source-name="delegación" dest-name="IDEMPRESA" type=”N”>
 
	        <oper type="mapval" source="Gen_Empresa" targetfld="ID">
 
	        <prop mapfld="ETIQUETA" mapvalue="##SELF##"/>
 
	        </oper>
 
        </prop>


AGGREGATE Operation that concatenates values that there are in several records, to put them only in one of destination.


EXAMPLE
Example that takes the value there is in “COD_EMP”, that has to exist as “prop” in the current “coll” and it looks for it in the “sql”, with or without where.
Then it concatenates the different values which meet the condition, by putting the value in OBSERVACIONES, separated by the value there is in the “separator” attribute. Also, there is the possibility to put the table option, that looks in the whole table, without condition or anything.
The example has the 3 possibilities of records search that the fields to concatenate have, but only one option is put.

 
<oper type="aggregate" function="CONCAT(##FLD_COD_EMP##)" separator="-">
 
        <param name="sql" value="select * from gen_usuarios"/> 
 
	<param name="sql" value="select * from gen_usuarios where COD_EMP=##FLD_COD_EMP##"/>
 
	<param name="table" table="gen_usuarios"/>
 
</oper>


This option concatenates as many times the “A” value separated by the value there is in the “separate” attribute, as many times the condition of the SQL value is met. It is like make a count with the select sent in the table that is set to perform the search.

        <oper type="aggregate" function="CONCAT(A)" separator="-">
 
	        <param name="sql" value="select * from gen_usuarios"/> 
 
	        <param name="sql" value="select * from gen_usuarios where COD_EMP=##FLD_COD_EMP##"/>
 
	        <param name="table" table="gen_usuarios"/>
 
        </oper>


Option that concatenates the first value defined in the gen_usuarios table, separated by the “separator” attribute, in the OBSERVACIONES field.

        <oper type="aggregate" function="CONCAT" separator="-">
 
        	<param name="sql" value="select * from gen_usuarios"/> 
 
        	<param name="sql" value="select * from gen_usuarios where COD_EMP=##FLD_COD_EMP##"/>
 
        	<param name="table" table="gen_usuarios"/>
 
        </oper>


Node that is executed when we finish performing the data transfer from one table to another. Within it, 5 different operations can be performed, which are:


DELETE-TABLE:


Operation that deletes the destination table, or the source table.

In the example we see that in the attribute “name” is put “dest”, to indicate that we want to delete the destination table, if we put any other value, it deletes the source table.

     <action name="delete-table">
 
         <param name="dest"/>					
 
     </action>

EXECUTE-QUERY:

It executes the SQL that is given to it to execute. This is quite useful to put a field in the source table with a value, to indicate that this value has already been passed to the destination table.

In the given example, we see that it has two “param” nodes, in what it is told that SQL will be executed, in the “value” attribute. Also in what database, the “name” attribute, is given “dest”, which is the destination database, and “source”, which is the source database.

You can also see that it uses the ## SOURCEKEYVALUES ## and ## DESTKEYVALUES ## macros, which have been filled in while transferring the data from one database to another.

<action name="execute-query">
 
<param name="source" value="Update Gen_DetDocumento SET ACTUALIZADO=1 WHERE ##SOURCEKEYVALUES##"/>				
 
<param name="dest" value="UPDATE Gen_Documentos  SET ACTUALIZADO=1  WHERE ID IN (SELECT IDDOCUMENTO FROM GEN_DETDOCUMENTO WHERE ##DESTKEYVALUES##)"/>
 
</action>

CREATE-FILE:


Operation that creates a file, in the place and name that is told, and also inserting the text that is put to it.

The example creates a file in the path “D:\Proyectos_Xone\Proyecto1\Interfase\2-pedidos”, the file is going to be named “OK.txt”, and at the same time the “OK” text is inserted.

<action name="create-fichero" path="D:\Proyectos_Xone\Proyecto1\Interfase\2-pedidos\OK.txt" texto="OK"/>

DELETE-FILE:


Operation that deletes a file. You put the place where it is and the name.

Example that deletes the “ESSPDA.TXT” file that there is in the path “C:\Archivos de programa\ CGSoft\ CGInterclient\ Captura\ Ficheros”.

<action name="delete-fichero" path="C:\Archivos de programa\ CGSoft\ CGInterclient\ Captura\ Ficheros\ ESPPDA.TXT"/>


Node to create a table in the destination, which will normally be the one that will take the destination data. It can be a table of a database or a text file. It is normal to use it to create the data destination file, when data from a database is transfered to text files.

<create name="dest-table" value="CREATE TABLE pedidos.txt (IDENTIFICADOR Char(11),PEDIDO char(15),CLIENTE char(11),ANYO char(4),MES char(2),DIA char(2),ARTICULO char(15),VENDEDOR char(11),CANTIDAD Char(9),PRECIO Char(15),ALMACEN Char(50))"/>
 
                                                                                                                                                    .


Node that is executed before starting the data transfer. You can use all the operations that exist in the “after-action” node, in addition to the one documented here.

EXIST-FILE:


This operation has been carried out exclusively to carry out the transfer of data from a database to files. What it does is find the file that is put in the path attribute. Search for that file and if it finds it, it does not go on and it stops until that file does not exist.

What the example does is to see if the PATH1 file exists, if the same exists, and PATH2 does not exist, create the one of PATH2 with the text that is put there. If the PATH1 file does not exist, the program will be stopped.

<action name="exist-fichero" path1="c:\Proyectos_Xone\Proyecto1\Interfase\2-pedidos\copy\pedidos.txt"
 
path2="c:\Proyectos_Xone\Proyecto1\Interfase\2-pedidos\copy\ok.txt" texto="OK"/>

Node to perform an erasure of the data that is told. You can erase both the origin and the destination.
There are several types of “delete” operations that can be performed, which are:

DELETE-CONDITIONAL:

This is to perform the deletion of the data that matches the data that are searched at the origin, from the field or fields that match the primary key that we have defined.

In the examples that we see below, we only see the node “delete”, but we must bear in mind that we have to make a “coll” node as if we were going to transfer data from one table to another, so it has to have as minimum one “prop” node that has the attribute “key” equal to “true”.


In the example, the deletion is made in the “gen_sat” table, of the destination database, by using the “delete-dest-table” attribute, of those data that match the ##DESTKEYVALUES## macro.

<delete>
 
<action name="delete-conditional" delete-dest-table="gen_sat" use-saved-dest="true"/>
 
</delete>

With this example, the deletion is made in the source database as in the destination database. To indicate a source table the attribute “delete-source-table” is used, with this attribute the macro ## SOURCEKEYVALUES ## is used.

<delete>
 
<action name="delete-conditional" delete-dest-table="gen_usuarios" use-saved-dest="true"/>
 
<action name="delete-conditional" delete-source-table="EVUSUA" use-saved-source="true"/>
 
</delete>

DELETE-SQL:


This operation is used to perform the deletion in both the client and in the XOne database, so that in addition to deleting from the normal table, it inserts the deletion in the replication queue.

WHERE It is the erase condition. The ##SOURCEKEYVALUES## and ##DESTKEYVALUES## macros can be used.
DELETE-DEST-TABLE Attribute to indicate in which table we want to make the erasure. If this attribute is not put, it is taken the value there is in the attribute of the “coll” node, “dest”. It makes the erasure of the records that have the ROWID that meet the condition put in the “where” attribute.
SELECT-DEST-TABLE Attribute to make the search of the records we want to delete. It can be any table, but we have keep in mind that the values search is made in this table, by taking the ROWID of the records that meet the “where” attribute, and from that ROWID the deletion is made. If nothing is put, the value there is in the attribute of the “coll” node, “dest” will be taken.
ALIAS-DEST-TABLE Alias of the table which the search is made from, and then the deletion.
SOURCE-TABLE To indicate from which source table we want to make the deletion.
DELETE-SOURCE If this attribute is declared, and besides is declared the “source-table” attribute, the deletion is made in the source table, also, with the condition that is put in the “where” attribute.


The example shown below performs the following things:

1. The search in the destination database is made, in the “gen_colla”(select-dest-table) table of the ROWIDs that meet the condition of the “where”(where), with the alias “c”(alias-dest-table).

SELECT c.ROWID FROM Gen_Colla WHERE ESTADO=1

2. If there are values with this condition, it deletes from the “gen_colla”( delete-dest-table) table.

3. If any records was found with the point 1, it exists the delete-source=”true” attribute, the “source-table” attribute with a table name and there is a condition, the deletion in the “Gen_USUARIOS”( source-table) table is made, with the condition there is in the “where” attribute.

<delete>
 
<action name="delete-sql" source-table="Gen_USUARIOS" delete-source="true" where="ESTADO=1" delete-dest-table="Gen_Colla" select-dest-table="Gen_Colla" alias-dest-table="c"/>
 
</delete>
 
                                                                                                                                    .

DELETE-FILE:


Operation useful to make the deletion of a file.

Performs the deletion of the file that exists in the “PATH” attribute, with place and name of it.

<action name="delete-fichero" path="C:\Archivos de programa\CGSoft\CGInterclient\Captura\Ficheros\ESPPDA.TXT"/>