version 6.0 (Modified)
OC Clone 4D table (connection_ID{; 4DTableNbr{; options}}) Integer
| Parameter | Type | Description | |
| connection_ID | Longint | Login_ID | |
| 4DTableNbr | Integer | 4D table number | |
| options | Longint | Options | |
| Function result | Integer | 1 = the operation is successful, | |
| 0 = the user clicks Cancel | |||
| -1 = an error occurs |
Description
The OC Clone 4D table command creates a table on your data source with column definitions equivalent to a 4th Dimension table.
connection_ID must be a valid login or cursor ID. If you use a valid login ID, 4D ODBC will automatically open and close a cursor for use with this function. If you pass a valid cursor ID, this function will use the specified cursor.
4DTableNumber is the number of the 4th Dimension table whose structure is duplicated.
options is a combination of options. Several options can be chosen by adding their values. The options are the following:
| Replace=1 | OC Clone 4D table generates a DROP TABLE statement before creating the |
| new table. | |
| WithoutSubtab=2 | OC Clone 4D table ignores subtables. The cloning of subtables is not currently |
| supported. This option must be requested for any table containing a subtable. | |
| WithoutText=4 | OC Clone 4D table ignores fields of the Text type. |
| WithoutPicture=8 | OC Clone 4D table ignores fields of the Picture type. |
| kWithout=16 | OC Clone 4D Table ignores fields of the BLOB type. |
If 4DTableNbr is not specified, OC Clone 4D table displays the Clone 4D Table dialog box.
The pop-up menu allows you to choose the 4th Dimension table to be cloned and the check boxes list the available options.
The new table has the name of the 4th Dimension table and its columns have the names of the fields in the 4th Dimension table. If a field name contains spaces, the spaces are replaced by underscores.
Types are converted according to the following rules:
| 4th Dimension | ODBC |
| Alpha (length) | SQL_CHAR |
| Text | SQL_LONGVARCHAR |
| Real | SQL_DECIMAL |
| Integer | SQL_INTEGER |
| Longint | SQL_BIGINT |
| Date | SQL_DATE |
| Hour | SQL_TIME |
| Boolean | SQL_BIT |
| Picture | SQL_BINARY |
| BLOB | SQL_BINARY |
Consult your specific ODBC driver to see how the column is created on your data source.
If a 4th Dimension field has the Mandatory attribute, the corresponding column is created with the NOT NULL option.
An index is created for each indexed field. Its name is a concatenation of the 4th Dimension tablename, the "$" sign and the field name, prefixed by "I_" and a sequence number for the table. For example, an index for the Sal field of the EMP table is named "I_EMP$SAL".
If a 4D field has the Unique attribute, the index is created with the UNIQUE option.
OC Clone 4D table returns 1 if the operation is successful, 0 if the user clicks Cancel in the dialog box, and -1 if an error occurs.
Example
The following method copies the files in the 4D database to the ODBC server. If a table already exists on the server, it is automatically replaced.
Login_ID:=OC Login dialog If(Login_ID>0) For($i;1;Count tables) rc:=OC Clone 4D table(Login_ID;$i;1) End for End if
See Also
System Variables and Sets
If the user clicks OK, the OK system variable is set to 1. If the user clicks Cancel, the OK system variable is set to 0.