Copy the content of a table to another. You can indicate form condition to perform a selection of the registers to copy.
1 table.copy
<table.copy
src='[database_src:]table_src'
dst='[database_dst:]table_dst'
where='where'
order='order'
maxrows='maxrows'
/>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Asrc | string | Name of the origin table of which you can obtain the registers. You can indicate a different database for the source using "database_src_code:" before the table name. | |||
Adst | boolean | Name of the destination table in which the registers will be copied. You can indicate a different database for the destiny using "database_dst_code:" before the table name. | |||
Awhere | boolean | Filter condition to get data from source. | |||
Aorder | boolean | Order of data selection. It is useful when is accompanied of the "maxrows" attribute because is indicated a maximum number of registers to copy. They will be copied according to the selection order. | |||
Amaxrows | boolean | Maximum number of registers to copy. In the case that the selection will return more registers of the indicated, they will not be copied, only the indicated for the attribute. |
Returns | |
---|---|
Type | Description |
Integer | Returnes the number of copied registers. |
Exceptions
Required attribute [...]
A required attribute has not been informed.
Example
Copies a maximum of 3 registers from the table "cdiary" in the table "cdiary:copy" with the indicated condition and order.
Copy
<xsql-script name='sample_table_copy'> <body> <set name='nrows'> <table.copy src="cdiarios" dst="cdiarios_copy" where="nomdia LIKE '%empresa ACME%'" order="codigo desc" maxrows="3" /> </set> <println><nrows/> have been copied.</println> </body> </xsql-script>
Connect to another database
This script shows how to connect to a different source database to get data. The script is executed on the destiny database.
Copy
<xsql-script name='sample_table_copy'> <body> <set name='nrows'> <table.copy src="dbsource:cdiarios" dst="cdiarios_copy" where="nomdia LIKE '%empresa ACME%'" order="codigo desc" maxrows="3" /> </set> <println><nrows/> have been copied.</println> </body> </xsql-script>
Información
This function copies content of a table to another of the same database. Also, both tables should exist in the database.
To copy content between differents databases should be used the function connection.schema.copy