version 11
4D v11 allows you to connect to any external ODBC data source directly from the language and execute SQL queries on that external connected database.
Here are the 4D commands that allow you to manage a connection with an external data source:
GET DATA SOURCE LIST can be used to get the list of the data sources installed on the machine.
SQL LOGIN allows you to connect to an external database via a data source installed on the machine.
SQL LOGOUT can be used to close any external connection and to reconnect to the local 4D database.
Get current data source tells you the current data source of the application.
The example below shows how to connect to an external data source (ORACLE), how to get data from the ORACLE database, and then how to disconnect from the ORACLE database and return to the local database.
Suppose that there is a valid data source named "Test_ORACLE_10g" installed in the system.
To test the above example, in the main window of the "4D SQL Code Samples" database, press the Connect to ORACLE button.