4D v16.3

GET DATA SOURCE LIST

Home

 
4D v16.3
SQL
GET DATA SOURCE LIST

GET DATA SOURCE LIST 


 

GET DATA SOURCE LIST ( sourceType ; sourceNamesArr ; driversArr ) 
Parameter Type   Description
sourceType  Longint in Source type: user or system
sourceNamesArr  Text array in Array of data source names
driversArr  Text array in Array of drivers for sources

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
System data source Longint 2
User data source Longint 1

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)

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.



See also 

Get current data source
SQL LOGIN
SQL LOGOUT

 
PROPERTIES 

Product: 4D
Theme: SQL
Number: 989

The OK variable is changed by the command

 
HISTORY 

Created: 4D v11 SQL

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)