4D v13.4SQL LOGIN |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v13.4
SQL LOGIN
SQL LOGIN
The SQL LOGIN command allows you to connect to an SQL data source specified in the dataEntry parameter. It designates the target of the SQL queries executed subsequently in the current process:
The SQL data source can either be:
In dataEntry, you can pass one of the following values: an IP address, a 4D database publication name, an ODBC data source name, an empty string or the SQL_INTERNAL constant.
Warning: The prefixes used in the dataEntry parameter (IP, ODBC, 4D) must be written in uppercase. userName contains the name of the user authorized to connect to the external data source. For example, with Oracle®, the user name can be “Scott”. password contains the password of the user authorized to connect to the external data source. For example, with Oracle®, the password can be “tiger”. Note: In the case of a direct connection, if you pass empty strings in the userName and password parameters, the connection will only be accepted if 4D passwords are not activated in the target database. Otherwise, the connection will be refused. The optional * parameter can be used to change the target of the SQL code executed within the Begin SQL/End SQL tags. If you do not pass this parameter, the code placed within the Begin SQL/End SQL tags will still be sent to the internal SQL engine of 4D, without taking the configuration specified by the SQL LOGIN command into account. If you do pass this parameter, the SQL code executed within the Begin SQL/End SQL tags will be sent to the source specified in the dataEntry parameter. To close the current connection and free the memory, simply execute the SQL LOGOUT command. All the SQL queries are then sent to the internal 4D SQL database. Note: In the case where an external connection attempt via SQL LOGIN fails, the internal 4D database automatically becomes the current data source. These parameters are optional; if no parameters are passed, the command will bring up the ODBC Login dialog box that allows you to select the external data source. The scope of this command is per process; in other words, if you want to execute two distinct connections, you must create two processes and execute each connection in each process. This statement will bring up the ODBC Manager dialog box: SQL LOGIN Opening of a connection via the ODBC protocol with the "MyOracle" external data source. SQL queries executed via the SQL EXECUTE command and queries included within the Begin SQL/End SQL tags will be redirected to this connection: SQL LOGIN("ODBC:MyOracle";"Scott";"tiger";*) Open a connection with the 4D internal SQL kernel: SQL LOGIN(SQL_INTERNAL;$user;$password) Opening of a direct connection with the 4D Server application executed on the machine having the IP address 192.168.45.34 and replying on the default TCP port. The SQL queries executed via the SQL EXECUTE command will be redirected to this con-nection; the queries included within the Begin SQL/End SQL tags will not be redirected SQL LOGIN("IP:192.168.45.34";"John";"azerty") Opening of a direct connection with the 4D Server application executed on the machine having the IP address 192.168.45.34 and replying on TCP port 20150. The SQL queries executed via the SQL EXECUTE command and the queries included within the Begin SQL/End SQL tags will be redirected to this connection. SQL LOGIN("IP:192.168.45.34:20150";"John";"azerty";*) Opening of a direct connection in SSL with the 4D Server application running on the machine with the IP address 192.168.45.34 and responding on the default TCP port. You must have enabled SSL for the SQL server on the 4D Server application:
SQL LOGIN("IP:192.168.45.34:ssl";"Admin";"sd156") // Note the ":ssl" at the end of the IP address Opening of a direct connection with the 4D Server application which publishes, on the local network, a database whose publication name is "Accounts_DB." The TCP port used for the SQL server of both databases (set on the SQL page of the Database Settings) must be the same (19812 by default). The SQL queries executed via the SQL EXECUTE command will be redirected to this connection; the queries included within the Begin SQL/End SQL tags will not be redirected. SQL LOGIN("4D:Accounts_DB";"John";"azerty") This example illustrates the connection possibilities provided by the SQL LOGIN command: ARRAY TEXT(aNames;0) If the connection is successful, the system variable OK is set to 1; otherwise, it is set to |
PROPERTIES
Product: 4D
INDEX HISTORY
Modified: 4D v11 SQL Release 3 SEE ALSO |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||