version 2004
SQL IMPORT (sourceTable{; project{; *}})
Parameter | Type | Description | |
sourceTable | String | Name of table in ODBC data source | |
project | BLOB | Contents of import project | |
New contents of import project (if * is passed) | |||
* | * | Display of import dialog box and project update |
Description
The SQL IMPORT command is used to import data from the sourceTable table of an external ODBC source. The connection parameters (source name, user and password) are included in the project BLOB.
Notes:
The project contains all the import parameters, in particular the data source and target tables and fields. You set these parameters in the ODBC import dialog box, then you can save them in a file on disk if necessary. For more information, refer to the Design Reference manual.
The projects generated in the ODBC import dialog box are not compatible with the commands or the standard import dialog box of 4D.
This command cannot be used in the case of connections with the internal SQL kernel of 4D.
If you do not pass the optional project parameter, SQL IMPORT displays a dialog box for selecting the ODBC data source:
Windows
Mac OS
Once you have selected the source, the 4D ODBC import dialog box appears, allowing the user to configure the operation. If the user clicks Cancel in either of the two dialog boxes, execution is stopped and the system variable OK is set to 0.
If you pass a BLOB containing a valid ODBC import project in the project parameter, the import will be carried out directly, without any user intervention. To do this, you simply need to load a project that has been saved on disk beforehand into the field or the BLOB variable that you pass in the project parameter, using the DOCUMENT TO BLOB command.
You can also use the SQL IMPORT command with an empty project parameter and the optional * parameter, then store the project parameter in a BLOB field (see below). On the one hand, this solution lets you store the project with the data file and, on the other, to avoid the phase of loading it from the disk into a BLOB.
Note: Refer to the EXPORT DATA command for an example concerning the definition of an empty project.
The optional * parameter, if it is set, displays the ODBC data import dialog box with the settings defined in project (if any). This allows you to use a predefined project while still being able to modify one or more parameters. Moreover, in this case, the project parameter contains the parameters of the "new" project after the dialog box is closed. You can then store it in a BLOB field, in a file on disk, etc.
See Also
System Variables or Sets
If the user clicks Cancel in either of the two dialog boxes (for selecting the data source or the import settings), the system variable OK is set to 0. If the import is carried out correctly, the system variable OK is set to 1.