dbsetopt

Description

Set a server or DB-Library option.

Syntax

RETCODE dbsetopt(dbproc, option, char_param, 
               int_param)
 
DBPROCESS     *dbproc;
int               option;
char          *char_param;
int               int_param;

Parameters

dbproc

A pointer to the DBPROCESS structure that provides the connection for a particular front-end/server process. It contains all the information that DB-Library uses to manage communications and data between the front end and server. If dbproc is NULL, the option will be set for all active DBPROCESS structures.

option

The option that is to be turned on. See Options for the list of options.

char_param

Certain options take parameters. For example, the DBOFFSET option takes as its parameter the construct for which offsets are to be returned:

dbsetopt(dbproc, DBOFFSET, "compute", -1)

The DBBUFFER option takes as its parameter the number of rows to be buffered:

dbsetopt(dbproc, DBBUFFER, "500", -1)

char_param must always be a character string enclosed in quotes, even in the case of a numeric value, as in the DBBUFFER example. If an invalid parameter is specified for one of the server options, this will be discovered the next time a command buffer is sent to the server. The dbsqlexec or dbsqlsend call will fail, and DB-Library will invoke the user-installed message handler. If an invalid parameter is specified for one of the DB-Library options (DBBUFFER or DBTEXTLIMIT), the dbsetopt call itself will fail.

If the option takes no parameters, char_param must be NULL.

int_param

Some options require an additional parameter, int_param, which is the length of the character string passed as char_param. Currently, only DBPRCOLSEP, DBPRLINESEP, and DBPRPAD require this parameter.

If int_param is not required, pass it as -1.

Returns

SUCCEED or FAIL.

dbsetopt will fail if char_param is invalid for one of the DB-Library options. However, an invalid char_param for a server option will not cause dbsetopt to fail, because such a parameter does not get validated until the command buffer is sent to the server.

Usage

See also

dbclropt, dbisopt, Options