db_start_engine Function

Starts the database server if it is not running.

Syntax

unsigned int db_start_engine( SQLCA * sqlca, char * parms );

Parameters

Returns

Non-zero if successful; 0 otherwise.

Remarks

If the database server was already running or was successfully started, the return value is TRUE (non-zero) and SQLCODE is set to 0. Error information is returned in the SQLCA.

The following call to db_start_engine starts the database server, loads the specified database, and names the server demo.

db_start_engine( &sqlca, "DBF=demo.db;START=iqsrv16" );

Unless the ForceStart (FORCE) connection parameter is used and set to YES, the db_start_engine function attempts to connect to a server before starting one, to avoid attempting to start a server that is already running.

When the ForceStart connection is set to YES, there is no attempt to connect to a server before trying to start one. This enables the following pair of commands to work as expected:

  1. Start a database server named server_1:

    iqsrv16 -n server_1 demo.db
  2. Force a new server to start and connect to it:

    db_start_engine( &sqlda, 
      "START=iqsrv16 -n server_2 mydb.db;ForceStart=YES" )

If ForceStart (FORCE) is not used and the ServerName (Server) parameter is not used, then the second command would have attempted to connect to server_1. The db_start_engine function does not pick up the server name from the -n option of the StartLine (START) parameter.