version 11
GET DATA SOURCE LIST (sourceType; sourceNamesArr; driversArr)
Parameter | Type | Description | |
sourceType | Longint | Source type: user or system | |
sourceNamesArr | Text array | Array of data source names | |
driversArr | Text array | Array of drivers for sources |
Description
The GET DATA SOURCE LIST command returns; in the sourceNamesArr and driversArr arrays, the names and drivers of the sourceType type data sources defined in the ODBC manager of the operating system.
4D allows you to connect to an external ODBC data source directly via the language and execute SQL queries within a Begin SQL/End SQL tag structure. This works as follows: the GET DATA SOURCE LIST command can be used to get a list of data sources present on the machine. The SQL LOGIN command can then be used to designate the source to be used. You can then execute SQL queries using a Begin SQL/End SQL tag structure in the "current" source. To carry out queries using the 4D internal engine again, simply pass the SQL LOGOUT command. For more information about SQL commands in the Method editor, please refer to the 4D SQL Reference manual.
In sourceType, pass the type of data source that you want to retrieve. You can use one of the following constants, found in the "SQL" theme:
Constant | Type | Value |
User Data Source | Longint | 1 |
System Data Source | Longint | 2 |
Note: This command does not take file type data sources into account.
The command fills and sizes the sourceNamesArr and driversArr arrays with the corresponding values.
Note: If you want to connect to an external 4D data source via ODBC, you will need to have installed the 4D ODBC Driver on your machine. For more information, please refer to the 4D ODBC Driver Installation manual.
Example
Example using a user data source:
ARRAY TEXT(arrDSN;0) ARRAY TEXT(arrDSNDrivers;0) GET DATA SOURCE LIST(User Data Source;arrDSN;arrDSNDrivers)
See Also
Get current data source, SQL LOGIN, SQL LOGOUT.
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.