version 6.0 (Modified)
OC Clone ODBC table (login_ID{; tableName}) Integer
| Parameter | Type | Description | |
| login_ID | Longint | Login ID | |
| tableName | String | Name of the 4D table | |
| Function result | Integer | 1= The operation is successful, | |
| 0 = The user clicks Cancel, | |||
| -1= An error occurs |
Description
The OC Clone ODBC table function creates a 4th Dimension table with field definitions equivalent to the ODBC table.
login_ID must be a valid login.
If you do not pass the second parameter, OC Clone ODBC table displays the Clone Table dialog box.
Passing the tableName as the second parameter will force the command to clone the table whose name has been passed instead of letting the user select it. The 4D table will bear the same name.
The new table has the name FileN, where N is the table number. The field names are the names of the columns on the ODBC data source.
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 |
Consult your specific ODBC driver documentation to see how the column is created on your data source.
OC Clone ODBC table returns 1 if the operation is successful, 0 if the user clicks Cancel in the dialog box, or -1 if an error occurs.
If the user clicks Cancel in the Clone ODBC Table dialog box, the OK system variable is set to 0.
Example
The following method clones locally all the tables found on the data source:
` OC CloneDB (CursorID)
` CursorID : Longint, from OC Create cursor.
C_LONGINT ($curs)
$curs := $1
ARRAY STRING(15;t1;0)
ARRAY STRING(15;t2;0)
ARRAY STRING(60;tab_name;0)
ARRAY STRING(15;tab_type;0)
ARRAY STRING(15;t5;0)
OC GET TABLE LIST ($curs;"t1";"t2";"tab_name";"tab_type";"t5")
For ($i;1;Size of array(tab_type))
If (tab_type{$i}="table")
MESSAGE("Clone table:"+tab_name{$i})
$r:=OC Clone ODBC table (l;tab_name{$i})
End if
End for