version 11
USE EXTERNAL DATABASE (sourceName{; user; password})
| Parameter | Type | Description | |
| sourceName | String | Name of ODBC data source to connect to | |
| user | String | User name | |
| password | String | User password |
Description
The USE EXTERNAL DATABASE command establishes a connection between the 4D application and the data source designated by the sourceName parameter. You can get a list of data sources available on the machine using the GET DATA SOURCE LIST command.
Once the connection is established, all SQL statements executed within Begin SQL/End SQL structures from then on will be sent to this source (SQL pass-through) in the current process, until the USE INTERNAL DATABASE command or another USE EXTERNAL DATABASE statement is executed.
Note: The EXECUTE IMMEDIATE SQL statement cannot be used within a connection to an external data source.
Pass any ID information required by the data source in the user and password parameters.
Example
C_TEXT(sourceNamesArr;sourceDriversArr;0)
GET DATA SOURCE LIST(1;sourceNamesArr;sourceDriversArr) `User data sources
If (Find in array(sourceNamesArr;"emp")#-1) `If the source emp does exist
USE EXTERNAL DATABASE("emp";"tiger";"scott")
Begin SQL
... `SQL statements
End SQL
End if
See Also
Get current data source, GET DATA SOURCE LIST, USE INTERNAL DATABASE.
System Variables or Sets
If the command is executed correctly, the OK system variable is set to 1. Otherwise, it is set to 0 and an error is generated.