Starting a Session
The
sqllogin()
function initiates communication with ESQL-LIB and optionally passes any startup parameters you (or the application user) specify to Progress, including any database connection parameters. It can also specify an optional application name used to generate filenames for SQL r-code files compiled during execution.You can call
sqllogin()
only once. Thesqllogin()
function returns 0 if it successfully logs in to ESQL-LIB and connects any specified databases. If it fails for any reason (including failure to connect databases),sqllogin()
returns -1 and ends your ESQL session. The only ESQL-LIB function you can call aftersqllogin()
fails issqlgetmsg()
. Oncesqllogin()
fails, you can make no other calls to ESQL-LIB (includingsqllogin()
) without exiting to the operating system and restarting your application.NOTE: Becausesqllogin()
ends your ESQL session if it fails, your application cannot recover ifsqllogin()
fails to connect a specified database. To maintain your ESQL session after such a failure, connect to databases using thesqlconn()
function, and pass to it only client startup parameters that have no effect on database connection and run-time behavior. For more information onsqlconn()
and database connection, see the "Connecting and Disconnecting Databases" section. For more information on client startup parameters, see the Progress Startup Command and Parameter Reference.Specifying Progress Startup Parameters
The startup parameters that you can specify to
sqllogin()
for the small client model are different than for the large client model. Following are the parameters you can specify for the small client model:
- The Open Interface Driver (-SV) startup parameter and its list of connection parameters. For more information, see Building and Running ESQL Applications."
- The common ESQL startup parameters. For more information, see Building and Running ESQL Applications."
- Database connection parameters. For more information, see the "Connecting and Disconnecting Databases" section.
Following are the parameters you can specify for the large client model:
- The common ESQL startup parameters. For more information, see Building and Running ESQL Applications."
- Database connection parameters. For more information, see the "Connecting and Disconnecting Databases" section.
NOTE: For the small client model, these parameters are specified when starting the Open Interface Broker or Driver. For more information, see Building and Running ESQL Applications."- Progress session-wide client startup parameters, which are any Progress client startup parameters that are not database connection parameters. For more information, see the Progress Startup Command and Parameter Reference.
You can specify Progress startup parameters to
sqllogin()
using three techniques:
- Pass the parameters directly in a character string.
For example, if you log in connecting to a database named
wildlife
with the user name Jon and the password noj, your call tosqllogin()
might look like this:
- Pass the parameters in a parameter file that you specify in a character string.
Use the -pf startup parameter to pass the name of a parameter file to Progress. If the name of your file is
my_options.pf
, your call tosqllogin()
might look like this:
- Pass the parameters from command line arguments.
In a C program, the argv argument specified for the
main()
function points to an array of pointers to the command line arguments that are passed to your application. The argc argument is the number of command line arguments. With most C compilers, the first element (element 0) points to the name of the executable image. Omit the first element to only pass arguments that are meaningful to Progress. If you use this technique, your call tosqllogin()
might look like this:NOTE: If you use argv to specify your startup parameters from the command line, strip any application-defined parameters before passing the argument list to
sqllogin()
.You can also use these techniques together, as shown in the following example:
Here, you pass
sqllogin()
both startup parameters from the command line and startup parameters in a character string. ESQL-LIB passes all these startup parameters to Progress with the command line parameters last. Any parameter settings that the application user specifies at startup replace any equivalent settings in the command string. Thus, you can specify default parameter settings that the user can override.Specifying an Application Name
When you log in with
sqllogin()
, you can specify an application name. ESQL uses the first two characters of this name plus a random hexadecimal number to generate the filename for each SQL r-code file compiled during execution.To associate run-time compiled r-code files with the sections of your application in which they are compiled, specify a different application name at the start of each section using the
sqlapplname()
ESQL-LIB function.If you use a null string as an application name (shown as the fourth
sqllogin()
argument in the previous code fragments), ESQL generates the entire filename for each r-code file that it compiles using a random hexadecimal number string.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |