FreeTDS API

Macros | Functions
Primary functions
The db-lib API

Core functions needed by most db-lib programs. More...

Collaboration diagram for Primary functions:

## Macros
#define | DBCMDROW(x) dbcmdrow((x))
| Sybase macro mapping to the Microsoft (lower-case) function. More...
#define | DBCOUNT(x) dbcount((x))
| Sybase macro mapping to the Microsoft (lower-case) function. More...
#define | DBCURCMD(x) dbcurcmd((x))
| Sybase macro mapping to the Microsoft (lower-case) function. More...
#define | DBCURROW(x) dbcurrow((x))
| Sybase macro mapping to the Microsoft (lower-case) function. More...
#define | DBDEAD(x) dbdead((x))
| Sybase macro mapping to the Microsoft (lower-case) function. More...
#define | DBFIRSTROW(x) dbfirstrow((x))
| Sybase macro mapping to the Microsoft (lower-case) function. More...
#define | DBIORDESC(x) dbiordesc((x))
| Sybase macro, maps to the internal (lower-case) function. More...
#define | DBIOWDESC(x) dbiowdesc((x))
| Sybase macro, maps to the internal (lower-case) function. More...
#define | DBISAVAIL(x) dbisavail((x))
| Sybase macro mapping to the Microsoft (lower-case) function. More...
#define | DBLASTROW(x) dblastrow((x))
| Sybase macro mapping to the Microsoft (lower-case) function. More...
#define | DBMORECMDS(x) dbmorecmds((x))
| Sybase macro mapping to the Microsoft (lower-case) function. More...
#define | DBROWS(x) dbrows((x))
| Sybase macro mapping to the Microsoft (lower-case) function. More...
#define | DBROWTYPE(x) dbrowtype((x))
| Sybase macro mapping to the Microsoft (lower-case) function. More...
#define | DBSETLCHARSET(x, y) dbsetlname((x), (y), DBSETCHARSET)
| Set the client character set in the login packet. More...
#define | DBSETLENCRYPT(x, y) dbsetlbool((x), (y), DBSETENCRYPT)
| Enable (or not) network password encryption for Sybase servers version 10.0 or above. More...
#define | DBSETLNATLANG(x, y) dbsetlname((x), (y), DBSETNATLANG)
| Set the language the server should use for messages. More...
#define | dbsetlnatlang(x, y) dbsetlname((x), (y), DBSETNATLANG)
| Set the language the server should use for messages. More...
#define | DBSETLPACKET(x, y) dbsetllong((x), (y), DBSETPACKET)
| Set the packet size in the login packet for new connections. More...
#define | dbsetlpacket(x, y) dbsetllong((x), (y), DBSETPACKET)
| Set the packet size in the login packet for new connections. More...
#define | DBTDS(a) dbtds(a)
| Sybase macro, maps to the internal (lower-case) function. More...

## Functions
static RETCODE | _dbresults (DBPROCESS *dbproc)
BYTE * | dbadata (DBPROCESS *dbproc, int computeid, int column)
| Get address of compute column data. More...
DBINT | dbadlen (DBPROCESS *dbproc, int computeid, int column)
| Get size of data in a compute column. More...
RETCODE | dbaltbind (DBPROCESS *dbproc, int computeid, int column, int vartype, DBINT varlen, BYTE *varaddr)
| Bind a compute column to a program variable. More...
int | dbaltcolid (DBPROCESS *dbproc, int computeid, int column)
| Get column ID of a compute column. More...
DBINT | dbaltlen (DBPROCESS *dbproc, int computeid, int column)
| Get size of data in compute column. More...
int | dbaltop (DBPROCESS *dbproc, int computeid, int column)
| Get aggregation operator for a compute column. More...
int | dbalttype (DBPROCESS *dbproc, int computeid, int column)
| Get datatype for a compute column. More...
DBINT | dbaltutype (DBPROCESS *dbproc, int computeid, int column)
| Get user-defined datatype of a compute column. More...
RETCODE | dbanullbind (DBPROCESS *dbproc, int computeid, int column, DBINT *indicator)
| Tie a null-indicator to a compute result column. More...
RETCODE | dbanydatecrack (DBPROCESS *dbproc, DBDATEREC2 *di, int type, const void *data)
| Break any kind of date or time value into useful pieces. More...
RETCODE | dbbind (DBPROCESS *dbproc, int column, int vartype, DBINT varlen, BYTE *varaddr)
| Tie a host variable to a resultset column. More...
BYTE * | dbbylist (DBPROCESS *dbproc, int computeid, int *size)
| Get `bylist` for a compute row. More...
RETCODE | dbcancel (DBPROCESS *dbproc)
| Cancel the current command batch. More...
RETCODE | dbcanquery (DBPROCESS *dbproc)
| Cancel the query currently being retrieved, discarding all pending rows. More...
char * | dbchange (DBPROCESS *dbproc)
| See if a command caused the current database to change. More...
void | dbclose (DBPROCESS *dbproc)
| Close a connection to the server and free associated resources. More...
void | dbclrbuf (DBPROCESS *dbproc, DBINT n)
| Clear n rows from the row buffer. More...
RETCODE | dbclropt (DBPROCESS *dbproc, int option, const char param[])
| Reset an option. More...
RETCODE | dbcmd (DBPROCESS *dbproc, const char cmdstring[])
| `Append` SQL to the command buffer. More...
DBINT | dbcollen (DBPROCESS *dbproc, int column)
| Get size of a regular result column. More...
char * | dbcolname (DBPROCESS *dbproc, int column)
| Return name of a regular result column. More...
char * | dbcolsource (DBPROCESS *dbproc, int column)
| Get base database column name for a result set column. More...
int | dbcoltype (DBPROCESS *dbproc, int column)
| Get the datatype of a regular result set column. More...
DBTYPEINFO * | dbcoltypeinfo (DBPROCESS *dbproc, int column)
| Get precision and scale information for a regular result column. More...
int | dbcolutype (DBPROCESS *dbproc, int column)
| Get user-defined datatype of a regular result column. More...
DBINT | dbconvert (DBPROCESS *dbproc, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen)
| cf. More...
DBINT | dbconvert_ps (DBPROCESS *dbproc, int db_srctype, const BYTE *src, DBINT srclen, int db_desttype, BYTE *dest, DBINT destlen, DBTYPEINFO *typeinfo)
| Convert one datatype to another. More...
DBINT | dbcount (DBPROCESS *dbproc)
| Get count of rows processed. More...
BYTE * | dbdata (DBPROCESS *dbproc, int column)
| Get address of data in a regular result column. More...
RETCODE | dbdatecrack (DBPROCESS *dbproc, DBDATEREC *di, DBDATETIME *datetime)
| Break a DBDATETIME value into useful pieces. More...
DBINT | dbdatlen (DBPROCESS *dbproc, int column)
| Get size of current row's data in a regular result column. More...
EHANDLEFUNC | dberrhandle (EHANDLEFUNC handler)
| Set an error handler, for messages from db-lib. More...
void | dbexit ()
| Close server connections and free all related structures. More...
RETCODE | dbfcmd (DBPROCESS *dbproc, const char *fmt,...)
| `printf-like` way to form SQL to send to the server. More...
void | dbfreebuf (DBPROCESS *dbproc)
| Erase the command buffer, in case `DBNOAUTOFREE` was set with dbsetopt(). More...
char * | dbgetchar (DBPROCESS *dbproc, int pos)
| Get address of a position in the command buffer. More...
int | dbgetmaxprocs (void)
| get maximum simultaneous connections db-lib will open to the server. More...
int | dbgetpacket (DBPROCESS *dbproc)
| Get TDS packet size for the connection. More...
RETCODE | dbgetrow (DBPROCESS *dbproc, DBINT row)
| Read a row from the row buffer. More...
int | dbgettime (void)
| Get maximum seconds db-lib waits for a server response to query. More...
BYTE * | dbgetuserdata (DBPROCESS *dbproc)
| Get address of user-allocated data from a `DBPROCESS`. More...
RETCODE | dbinit (void)
| Initialize db-lib. More...
BOOL | dbiscount (DBPROCESS *dbproc)
| Indicates whether or not the count returned by dbcount is real (Microsoft-compatibility feature). More...
DBBOOL | dbisopt (DBPROCESS *dbproc, int option, const char param[])
| Get value of an option. More...
LOGINREC * | dblogin (void)
| Allocate a `LOGINREC` structure. More...
void | dbloginfree (LOGINREC *login)
| free the `LOGINREC` More...
RETCODE | dbmorecmds (DBPROCESS *dbproc)
| See if more commands are to be processed. More...
RETCODE | dbmoretext (DBPROCESS *dbproc, DBINT size, const BYTE text[])
| Send chunk of a text/image value to the server. More...
MHANDLEFUNC | dbmsghandle (MHANDLEFUNC handler)
| Set a message handler, for messages from the server. More...
char * | dbname (DBPROCESS *dbproc)
| Get name of current database. More...
RETCODE | dbnullbind (DBPROCESS *dbproc, int column, DBINT *indicator)
| Tie a null-indicator to a regular result column. More...
int | dbnumalts (DBPROCESS *dbproc, int computeid)
| Get count of columns in a compute row. More...
int | dbnumcols (DBPROCESS *dbproc)
| Return number of regular columns in a result set. More...
int | dbnumcompute (DBPROCESS *dbproc)
| Get count of `COMPUTE` clauses for a result set. More...
DBINT | dbprcollen (DBPROCESS *dbproc, int column)
| Get size of a result column needed to print column. More...
void | dbprhead (DBPROCESS *dbproc)
| Print result set headings to stdout. More...
RETCODE | dbprrow (DBPROCESS *dbproc)
| Print a result set to stdout. More...
const char * | dbprtype (int token)
| Print a token value's name to a buffer. More...
STATUS | dbreadtext (DBPROCESS *dbproc, void *buf, DBINT bufsize)
| Fetch part of a text or image value from the server. More...
void | dbrecftos (const char filename[])
| Record to a file all SQL commands sent to the server. More...
RETCODE | dbresults (DBPROCESS *dbproc)
| Set up query results. More...
RETCODE | dbsafestr (DBPROCESS *dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype)
| safely quotes character values in SQL text. More...
char * | dbservcharset (DBPROCESS *dbproc)
| Get `syscharset` name of the server character set. More...
void | dbsetifile (char *filename)
| set name and location of the `interfaces` file FreeTDS should use to look up a servername. More...
void | dbsetinterrupt (DBPROCESS *dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr)
| Set interrupt handler for db-lib to use while blocked against a read from the server. More...
RETCODE | dbsetlogintime (int seconds)
| Set maximum seconds db-lib waits for a server response to a login attempt. More...
RETCODE | dbsetlversion (LOGINREC *login, BYTE version)
| Set TDS version for future connections. More...
RETCODE | dbsetmaxprocs (int maxprocs)
| Set maximum simultaneous connections db-lib will open to the server. More...
RETCODE | dbsetnull (DBPROCESS *dbproc, int bindtype, int bindlen, BYTE *bindval)
| Define substitution values to be used when binding null values. More...
RETCODE | dbsetopt (DBPROCESS *dbproc, int option, const char *char_param, int int_param)
| Set db-lib or server option. More...
STATUS | dbsetrow (DBPROCESS *dbproc, DBINT row)
| Make a buffered row "current" without fetching it into bound variables. More...
RETCODE | dbsettime (int seconds)
| Set maximum seconds db-lib waits for a server response to query. More...
void | dbsetuserdata (DBPROCESS *dbproc, BYTE *ptr)
| Associate client-allocated (and defined) data with a `DBPROCESS`. More...
RETCODE | dbsetversion (DBINT version)
| Specify a db-lib version level. More...
int | dbspid (DBPROCESS *dbproc)
| Get server process ID for a `DBPROCESS`. More...
RETCODE | dbspr1row (DBPROCESS *dbproc, char *buffer, DBINT buf_len)
| Print a regular result row to a buffer. More...
DBINT | dbspr1rowlen (DBPROCESS *dbproc)
| Determine size buffer required to hold the results returned by dbsprhead(), dbsprline(), and dbspr1row(). More...
RETCODE | dbsprhead (DBPROCESS *dbproc, char *buffer, DBINT buf_len)
| Print result set headings to a buffer. More...
RETCODE | dbsprline (DBPROCESS *dbproc, char *buffer, DBINT buf_len, DBCHAR line_char)
| Get formatted string for underlining dbsprhead() column names. More...
RETCODE | dbsqlexec (DBPROCESS *dbproc)
| send the SQL command to the server and wait for an answer. More...
RETCODE | dbsqlok (DBPROCESS *dbproc)
| Wait for results of a query from the server. More...
RETCODE | dbsqlsend (DBPROCESS *dbproc)
| Transmit the command buffer to the server. More...
RETCODE | dbstrbuild (DBPROCESS *dbproc, char *charbuf, int bufsize, char *text, char *formats,...)
| Build a printable string from text containing placeholders for variables. More...
RETCODE | dbstrcpy (DBPROCESS *dbproc, int start, int numbytes, char *dest)
| Get a copy of a chunk of the command buffer. More...
int | dbstrlen (DBPROCESS *dbproc)
| Get size of the command buffer, in bytes. More...
RETCODE | dbtablecolinfo (DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol)
| describe table column attributes with a single call (Freetds-only API function modelled on dbcolinfo) More...
DBBINARY * | dbtxptr (DBPROCESS *dbproc, int column)
| Get text pointer for a column in the current row. More...
DBBINARY * | dbtxtimestamp (DBPROCESS *dbproc, int column)
| Get text timestamp for a column in the current row. More...
RETCODE | dbuse (DBPROCESS *dbproc, const char *name)
| Change current database. More...
DBINT | dbvarylen (DBPROCESS *dbproc, int column)
| Determine whether a column can vary in size. More...
const char * | dbversion ()
| See which version of db-lib is in use. More...
DBBOOL | dbwillconvert (int srctype, int desttype)
| Test whether or not a datatype can be converted to another datatype. More...
RETCODE | dbwritetext (DBPROCESS *dbproc, char *objname, DBBINARY *textptr, DBTINYINT textptrlen, DBBINARY *timestamp, DBBOOL log, DBINT size, BYTE *text)
| Send text or image data to the server. More...

## Detailed Description

Core functions needed by most db-lib programs.

## Macro Definition Documentation

## § DBCMDROW

DBCMDROW | ( |  | x | ) | dbcmdrow((x))

Sybase macro mapping to the Microsoft (lower-case) function.

See also
  dbcmdrow()

## § DBCOUNT

DBCOUNT | ( |  | x | ) | dbcount((x))

Sybase macro mapping to the Microsoft (lower-case) function.

See also
  dbcount()

## § DBCURCMD

DBCURCMD | ( |  | x | ) | dbcurcmd((x))

Sybase macro mapping to the Microsoft (lower-case) function.

See also
  dbcurcmd()

## § DBCURROW

DBCURROW | ( |  | x | ) | dbcurrow((x))

Sybase macro mapping to the Microsoft (lower-case) function.

See also
  dbcurrow()

## § DBDEAD

DBDEAD | ( |  | x | ) | dbdead((x))

Sybase macro mapping to the Microsoft (lower-case) function.

See also
  dbdead()

## § DBFIRSTROW

DBFIRSTROW | ( |  | x | ) | dbfirstrow((x))

Sybase macro mapping to the Microsoft (lower-case) function.

See also
  dbfirstrow()

## § DBIORDESC

DBIORDESC | ( |  | x | ) | dbiordesc((x))

Sybase macro, maps to the internal (lower-case) function.

See also
  dbiordesc()

## § DBIOWDESC

DBIOWDESC | ( |  | x | ) | dbiowdesc((x))

Sybase macro, maps to the internal (lower-case) function.

See also
  dbiowdesc()

## § DBISAVAIL

DBISAVAIL | ( |  | x | ) | dbisavail((x))

Sybase macro mapping to the Microsoft (lower-case) function.

See also
  dbisavail()

## § DBLASTROW

DBLASTROW | ( |  | x | ) | dblastrow((x))

Sybase macro mapping to the Microsoft (lower-case) function.

See also
  dblastrow(), DBFIRSTROW()

## § DBMORECMDS

DBMORECMDS | ( |  | x | ) | dbmorecmds((x))

Sybase macro mapping to the Microsoft (lower-case) function.

See also
  dbmorecmds()

## § DBROWS

DBROWS | ( |  | x | ) | dbrows((x))

Sybase macro mapping to the Microsoft (lower-case) function.

See also
  dbrows()

## § DBROWTYPE

DBROWTYPE | ( |  | x | ) | dbrowtype((x))

Sybase macro mapping to the Microsoft (lower-case) function.

See also
  dbrowtype()

## § DBSETLCHARSET

DBSETLCHARSET | ( |  | x,
|  |  | y
| ) |  | dbsetlname((x), (y), DBSETCHARSET)

Set the client character set in the login packet.

Remarks
  Has no effect on TDS 7.0+ connections.

## § DBSETLENCRYPT

DBSETLENCRYPT | ( |  | x,
|  |  | y
| ) |  | dbsetlbool((x), (y), DBSETENCRYPT)

Enable (or not) network password encryption for Sybase servers version 10.0 or above.

Todo:
  Unimplemented.

See also
  dbsetlencrypt()

## § DBSETLNATLANG

DBSETLNATLANG | ( |  | x,
|  |  | y
| ) |  | dbsetlname((x), (y), DBSETNATLANG)

Set the language the server should use for messages.

See also
  dbsetlnatlang(), dbsetlname()

## § dbsetlnatlang

dbsetlnatlang | ( |  | x,
|  |  | y
| ) |  | dbsetlname((x), (y), DBSETNATLANG)

Set the language the server should use for messages.

See also
  DBSETLNATLANG(), dbsetlname()

## § DBSETLPACKET

DBSETLPACKET | ( |  | x,
|  |  | y
| ) |  | dbsetllong((x), (y), DBSETPACKET)

Set the packet size in the login packet for new connections.

See also
  dbsetlpacket(), dbsetllong()

## § dbsetlpacket

dbsetlpacket | ( |  | x,
|  |  | y
| ) |  | dbsetllong((x), (y), DBSETPACKET)

Set the packet size in the login packet for new connections.

See also
  DBSETLPACKET(), dbsetllong()

## § DBTDS

DBTDS | ( |  | a | ) | dbtds(a)

Sybase macro, maps to the internal (lower-case) function.

See also
  dbtds()

## Function Documentation

## § _dbresults()

static RETCODE _dbresults | ( | DBPROCESS * | dbproc | ) |
| static

Remarks
  Either SYBDBLIB or MSDBLIB (not both) must be defined. This affects how certain application-addressable strucures are defined.

Here is the caller graph for this function:

## § dbadata()

BYTE* dbadata | ( | DBPROCESS * | dbproc,
|  | int | computeid,
|  | int | column
| ) |  |

Get address of compute column data.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  computeid | of `COMPUTE` clause to which we're referring.
  column | Nth column in computeid, starting from 1.

Returns
  pointer to columns's data buffer.

Return values

  NULL | no such computeid or column.

See also
  dbadlen(), dbaltbind(), dbaltlen(), dbalttype(), dbgetrow(), dbnextrow(), dbnumalts().

Here is the call graph for this function:

## § dbadlen()

DBINT dbadlen | ( | DBPROCESS * | dbproc,
|  | int | computeid,
|  | int | column
| ) |  |

Get size of data in a compute column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  computeid | of `COMPUTE` clause to which we're referring.
  column | Nth column in computeid, starting from 1.

Returns
  size of the data, in bytes.

Return values

  -1 | no such column or computeid.
  0 | data are NULL.

See also
  dbadata(), dbaltlen(), dbalttype(), dbgetrow(), dbnextrow(), dbnumalts().

Here is the call graph for this function:

## § dbaltbind()

RETCODE dbaltbind | ( | DBPROCESS * | dbproc,
|  | int | computeid,
|  | int | column,
|  | int | vartype,
|  | DBINT | varlen,
|  | BYTE * | varaddr
| ) |  |

Bind a compute column to a program variable.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  computeid | of `COMPUTE` clause to which we're referring.
  column | Nth column in computeid, starting from 1.
  vartype | datatype of the host variable that will receive the data
  varlen | size of host variable pointed to varaddr
  varaddr | address of host variable

Return values

  SUCCEED | everything worked.
  FAIL | no such computeid or column, or no such conversion possible, or target buffer too small.

See also
  dbadata(), dbaltbind_ps(), dbanullbind(), dbbind(), dbbind_ps(), dbconvert(), dbconvert_ps(), dbnullbind(), dbsetnull(), dbsetversion(), dbwillconvert().

Here is the call graph for this function:

## § dbaltcolid()

int dbaltcolid | ( | DBPROCESS * | dbproc,
|  | int | computeid,
|  | int | column
| ) |  |

Get column ID of a compute column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  computeid | of `COMPUTE` clause to which we're referring.
  column | Nth column in computeid, starting from 1.

Returns
  Nth column in the base result set, on which column was computed.

See also
  dbadata(), dbadlen(), dbaltlen(), dbgetrow(), dbnextrow(), dbnumalts(), dbprtype().

Here is the call graph for this function:

## § dbaltlen()

DBINT dbaltlen | ( | DBPROCESS * | dbproc,
|  | int | computeid,
|  | int | column
| ) |  |

Get size of data in compute column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  computeid | of `COMPUTE` clause to which we're referring.
  column | Nth column in computeid, starting from 1.

See also
  dbadata(), dbadlen(), dbalttype(), dbgetrow(), dbnextrow(), dbnumalts().

Here is the call graph for this function:

## § dbaltop()

int dbaltop | ( | DBPROCESS * | dbproc,
|  | int | computeid,
|  | int | column
| ) |  |

Get aggregation operator for a compute column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  computeid | of `COMPUTE` clause to which we're referring.
  column | Nth column in computeid, starting from 1.

Returns
  token value for the type of the compute column's aggregation operator.

Return values

  -1 | no such computeid or column.

See also
  dbadata(), dbadlen(), dbaltlen(), dbnextrow(), dbnumalts(), dbprtype().

Here is the call graph for this function:

## § dbalttype()

int dbalttype | ( | DBPROCESS * | dbproc,
|  | int | computeid,
|  | int | column
| ) |  |

Get datatype for a compute column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  computeid | of `COMPUTE` clause to which we're referring.
  column | Nth column in computeid, starting from 1.

Returns
  `SYB*` dataype token.

Return values

  -1 | no such column or computeid.

See also
  dbadata(), dbadlen(), dbaltlen(), dbnextrow(), dbnumalts(), dbprtype().

Here is the call graph for this function:

## § dbaltutype()

DBINT dbaltutype | ( | DBPROCESS * | dbproc,
|  | int | computeid,
|  | int | column
| ) |  |

Get user-defined datatype of a compute column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  computeid | of `COMPUTE` clause to which we're referring.
  column | Nth column in computeid, starting from 1.

Returns
  user-defined datatype of compute column, else -1.

See also
  dbalttype(), dbcolutype().

Here is the call graph for this function:

## § dbanullbind()

RETCODE dbanullbind | ( | DBPROCESS * | dbproc,
|  | int | computeid,
|  | int | column,
|  | DBINT * | indicator
| ) |  |

Tie a null-indicator to a compute result column.

When a row is fetched, the indicator variable tells the state of the column's data.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  computeid | identifies which one of potientially many compute rows is meant. The first compute clause has computeid == 1.
  column | Nth column in the result set, starting with 1.
  indicator | address of host variable.

Return values

  SUCCEED | variable accepted.
  FAIL | indicator is NULL or column is out of range.

Remarks
  Contents of indicator are set with `dbnextrow()`. Possible values are:
  - 0 column bound successfully
  - -1 column is NULL.
  - >0 true length of data, had column not been truncated due to insufficient space in the columns bound host variable .

See also
  dbadata(), dbadlen(), dbaltbind(), dbnextrow(), dbnullbind().

Todo:
  Never fails, but only because failure conditions aren't checked.

Here is the call graph for this function:

## § dbanydatecrack()

RETCODE dbanydatecrack | ( | DBPROCESS * | dbproc,
|  | DBDATEREC2 * | di,
|  | int | type,
|  | const void * | data
| ) |  |

Break any kind of date or time value into useful pieces.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  di | output: structure to contain the exploded parts of datetime.
  type | input: `type` of date/time value returned by dbcoltype().
  data | input: `date/time` value to be converted.

Return values

  SUCCEED | always.

Remarks
  The members of di have different names, depending on whether `–with-msdblib` was configured.

This is an extension to dbdatecrack(), see it for more information.

See also
  dbdatecrack(), dbconvert(), dbdata(), dbdatechar(), dbdatename(), dbdatepart(), tdsdbopen().

## § dbbind()

RETCODE dbbind | ( | DBPROCESS * | dbproc,
|  | int | column,
|  | int | vartype,
|  | DBINT | varlen,
|  | BYTE * | varaddr
| ) |  |

Tie a host variable to a resultset column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  column | Nth column, starting at 1.
  vartype | datatype of the host variable that will receive the data
  varlen | size of host variable pointed to varaddr
  varaddr | address of host variable

Return values

  SUCCEED | everything worked.
  FAIL | no such column or no such conversion possible, or target buffer too small.

See also

Here is the call graph for this function:

## § dbbylist()

BYTE* dbbylist | ( | DBPROCESS * | dbproc,
|  | int | computeid,
|  | int * | size
| ) |  |

Get `bylist` for a compute row.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  computeid | of `COMPUTE` clause to which we're referring.
  size | output: size of `bylist` buffer whose address is returned, possibly zero.

Returns
  address of `bylist` for computeid.

Return values

  NULL | no such computeid.

Remarks
  Do not free returned pointer.

See also
  dbadata(), dbadlen(), dbaltlen(), dbalttype(), dbcolname(), dbgetrow(), dbnextrow().

Here is the call graph for this function:

## § dbcancel()

RETCODE dbcancel | ( | DBPROCESS * | dbproc | ) |

Cancel the current command batch.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Return values

  SUCCEED | always.

See also
  dbcanquery(), dbnextrow(), dbresults(), dbsetinterrupt(), dbsqlexec(), dbsqlok(), dbsqlsend().

Todo:
  Check for failure and return accordingly.

Here is the call graph for this function:

## § dbcanquery()

RETCODE dbcanquery | ( | DBPROCESS * | dbproc | ) |

Cancel the query currently being retrieved, discarding all pending rows.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

See also

Here is the call graph for this function:

## § dbchange()

char* dbchange | ( | DBPROCESS * | dbproc | ) |

See if a command caused the current database to change.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Returns
  name of new database, if changed, as a null-terminated ASCII string, else `NULL`.

See also
  dbname(), dbresults(), dbsqlexec(), dbsqlsend(), dbuse().

Here is the call graph for this function:

## § dbclose()

void dbclose | ( | DBPROCESS * | dbproc | ) |

Close a connection to the server and free associated resources.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

See also
  dbexit(), dbopen().

Here is the call graph for this function:

## § dbclrbuf()

void dbclrbuf | ( | DBPROCESS * | dbproc,
|  | DBINT | n
| ) |  |

Clear n rows from the row buffer.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  n | number of rows to remove, >= 0.

See also
  dbgetrow(), dbnextrow(), dbsetopt().

Here is the call graph for this function:

## § dbclropt()

RETCODE dbclropt | ( | DBPROCESS * | dbproc,
|  | int | option,
|  | const char | param[]
| ) |  |

Reset an option.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  option | to be turned off.
  param | clearing some options requires a parameter, believe it or not.

Return values

  SUCCEED | option and parameter seem sane.
  FAIL | no such option.

Remarks
  Only the following options are recognized:
  - DBARITHABORT
  - DBARITHIGNORE
  - DBCHAINXACTS
  - DBFIPSFLAG
  - DBISOLATION
  - DBNOCOUNT
  - DBNOEXEC
  - DBPARSEONLY
  - DBSHOWPLAN
  - DBSTORPROCID
  - DBQUOTEDIDENT
  - DBSETTIME

See also
  dbisopt(), dbsetopt().

Here is the call graph for this function:

## § dbcmd()

RETCODE dbcmd | ( | DBPROCESS * | dbproc,
|  | const char | cmdstring[]
| ) |  |

`Append` SQL to the command buffer.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  cmdstring | SQL to append to the command buffer.

Return values

  SUCCEED | success.
  FAIL | insufficient memory.

Remarks
  set command state to `DBCMDPEND` unless the command state is DBCMDSENT, in which case it frees the command buffer. This latter may or may not be the Right Thing to do.

See also
  dbfcmd(), dbfreebuf(), dbgetchar(), dbopen(), dbstrcpy(), dbstrlen().

Here is the call graph for this function:

## § dbcollen()

DBINT dbcollen | ( | DBPROCESS * | dbproc,
|  | int | column
| ) |  |

Get size of a regular result column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  column | Nth in the result set, starting from 1.

Returns
  size of the column (not of data in any particular row). On error, -1.

See also
  dbcolname(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols().

Here is the call graph for this function:

## § dbcolname()

char* dbcolname | ( | DBPROCESS * | dbproc,
|  | int | column
| ) |  |

Return name of a regular result column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  column | Nth in the result set, starting with 1.

Returns
  pointer to ASCII null-terminated string, the name of the column.

Return values

  NULL | column is not in range.

See also
  dbcollen(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols().

Bug:
  Relies on ASCII column names, post iconv conversion. Will not work as described for UTF-8 or UCS-2 clients. But maybe it shouldn't.

Here is the call graph for this function:

## § dbcolsource()

char* dbcolsource | ( | DBPROCESS * | dbproc,
|  | int | column
| ) |  |

Get base database column name for a result set column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  column | Nth in the result set, starting from 1.

Returns
  pointer to ASCII null-terminated string, the name of the column. On error, NULL.

See also
  dbcolbrowse(), dbqual(), dbtabbrowse(), dbtabcount(), dbtabname(), dbtabsource(), dbtsnewlen(), dbtsnewval(), dbtsput().

Here is the call graph for this function:

## § dbcoltype()

int dbcoltype | ( | DBPROCESS * | dbproc,
|  | int | column
| ) |  |

Get the datatype of a regular result set column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  column | Nth in the result set, starting from 1.

Returns
  `SYB*` datetype token value, or zero if column out of range

See also
  dbcollen(), dbcolname(), dbdata(), dbdatlen(), dbnumcols(), dbprtype(), dbvarylen().

Here is the call graph for this function:

## § dbcoltypeinfo()

DBTYPEINFO* dbcoltypeinfo | ( | DBPROCESS * | dbproc,
|  | int | column
| ) |  |

Get precision and scale information for a regular result column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  column | Nth in the result set, starting from 1.

Returns
  Pointer to a DBTYPEINFO structure . NULL column is out of range.

See also
  dbcollen(), dbcolname(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols(), dbprtype(), dbvarylen().

Here is the call graph for this function:

## § dbcolutype()

int dbcolutype | ( | DBPROCESS * | dbproc,
|  | int | column
| ) |  |

Get user-defined datatype of a regular result column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  column | Nth in the result set, starting from 1.

Returns
  `SYB*` datetype token value, or -1 if column out of range

See also
  dbaltutype(), dbcoltype().

Here is the call graph for this function:

## § dbconvert()

DBINT dbconvert | ( | DBPROCESS * | dbproc,
|  | int | srctype,
|  | const BYTE * | src,
|  | DBINT | srclen,
|  | int | desttype,
|  | BYTE * | dest,
|  | DBINT | destlen
| ) |  |

cf.

dbconvert_ps(), above

Sybase: Convert numeric types.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  srctype | datatype of the data to convert.
  src | buffer to convert
  srclen | length of src
  desttype | target datatype
  dest | output buffer
  destlen | size of dest
  typeinfo | address of a `DBTYPEINFO` structure that governs the precision & scale of the output, may be `NULL`.

See also
  dbaltbind(), dbaltbind_ps(), dbbind(), dbbind_ps(), dbconvert_ps(), dberrhandle(), dbsetnull(), dbsetversion(), dbwillconvert().

Here is the call graph for this function:

## § dbconvert_ps()

DBINT dbconvert_ps | ( | DBPROCESS * | dbproc,
|  | int | db_srctype,
|  | const BYTE * | src,
|  | DBINT | srclen,
|  | int | db_desttype,
|  | BYTE * | dest,
|  | DBINT | destlen,
|  | DBTYPEINFO * | typeinfo
| ) |  |

Convert one datatype to another.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  srctype | datatype of the data to convert.
  src | buffer to convert
  srclen | length of src
  desttype | target datatype
  dest | output buffer
  destlen | size of dest

Returns
  On success, the count of output bytes in dest, else -1. On failure, it will call any user-supplied error handler.

Remarks
  Causes of failure:
  - No such conversion unavailable.
  - Character data output was truncated, or numerical data overflowed or lost precision.
  - In converting character data to one of the numeric types, the string could not be interpreted as a number.

Conversion functions are handled in the TDS layer.

The main reason for this is that `ct-lib` and `ODBC` (and presumably `DBI`) need to be able to do conversions between datatypes. This is possible because the format of complex data (dates, money, numeric, decimal) is defined by its representation on the wire; thus what we call `DBMONEY` is exactly its format on the wire. CLIs that need a different representation (ODBC?) need to convert from this format anyway, so the code would already be in place.

Each datatype is also defined by its Server-type so all CLIs should be able to map native types to server types as well.

tds_convert() copies from src to dest and returns the output data length, period. All padding and termination is the responsibility of the API library and is done post-conversion. The peculiar rule in dbconvert() is that a destlen of -1 and a desttype of `SYBCHAR` means the output buffer should be null-terminated.

See also
  dbaltbind(), dbaltbind_ps(), dbbind(), dbbind_ps(), dbconvert_ps(), dberrhandle(), dbsetnull(), dbsetversion(), dbwillconvert().

Todo:

  What happens if client does not reset values?

  Microsoft and Sybase define this function differently.

Here is the call graph for this function:

## § dbcount()

DBINT dbcount | ( | DBPROCESS * | dbproc | ) |

Get count of rows processed.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Returns
  - for insert/update/delete, count of rows affected.
  - for select, count of rows returned, after all rows have been fetched.

See also
  DBCOUNT(), dbnextrow(), dbresults().

Here is the call graph for this function:

## § dbdata()

BYTE* dbdata | ( | DBPROCESS * | dbproc,
|  | int | column
| ) |  |

Get address of data in a regular result column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  column | Nth in the result set, starting from 1.

Returns
  pointer the data, or NULL if data are NULL, or if column is out of range.

See also
  dbbind(), dbcollen(), dbcolname(), dbcoltype(), dbdatlen(), dbnumcols().

Here is the call graph for this function:

## § dbdatecrack()

RETCODE dbdatecrack | ( | DBPROCESS * | dbproc,
|  | DBDATEREC * | di,
|  | DBDATETIME * | datetime
| ) |  |

Break a DBDATETIME value into useful pieces.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  di | output: structure to contain the exploded parts of datetime.
  datetime | input: `DBDATETIME` to be converted.

Return values

  SUCCEED | always.

Remarks
  The members of di have different names, depending on whether `–with-msdblib` was configured.

If DBPROCESS is NULL, dbdatecrack() uses the compiled in default value of MSDBLIB as of when libsybdb was compiled, irrespective of its value when the application is compiled. This can lead to incorrect results because Sybase and Microsoft use different ranges – [0,11] vs. [1,12] – for the month.

See also
  dbconvert(), dbdata(), dbdatechar(), dbdatename(), dbdatepart(), tdsdbopen().

## § dbdatlen()

DBINT dbdatlen | ( | DBPROCESS * | dbproc,
|  | int | column
| ) |  |

Get size of current row's data in a regular result column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  column | Nth in the result set, starting from 1.

Returns
  size of the data, in bytes.

See also
  dbcollen(), dbcolname(), dbcoltype(), dbdata(), dbnumcols().

Here is the call graph for this function:

## § dberrhandle()

EHANDLEFUNC dberrhandle | ( | EHANDLEFUNC | handler | ) |

Set an error handler, for messages from db-lib.

Parameters

  handler | pointer to callback function that will handle errors. Pass NULL to restore the default handler.

Returns
  address of prior handler, or NULL if none was previously installed.

See also
  DBDEAD(), dbmsghandle().

## § dbexit()

void dbexit | ( | void |  | ) |

Close server connections and free all related structures.

See also
  dbclose(), dbinit(), dbopen().

Todo:
  breaks if ctlib/dblib used in same process.

Here is the call graph for this function:

## § dbfcmd()

RETCODE dbfcmd | ( | DBPROCESS * | dbproc,
|  | const char * | fmt,
|  |  | ...
| ) |  |

`printf-like` way to form SQL to send to the server.

Forms a command string and writes to the command buffer with dbcmd().

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  fmt | `man vasprintf` for details.

Return values

  SUCCEED | success.
  FAIL | insufficient memory, or dbcmd() failed.

See also
  dbcmd(), dbfreebuf(), dbgetchar(), dbopen(), dbstrcpy(), dbstrlen().

Here is the call graph for this function:

## § dbfreebuf()

void dbfreebuf | ( | DBPROCESS * | dbproc | ) |

Erase the command buffer, in case `DBNOAUTOFREE` was set with dbsetopt().

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

See also
  dbcmd(), dbfcmd(), dbgetchar(), dbsqlexec(), dbsqlsend(), dbsetopt(), dbstrcpy(), dbstrlen().

Here is the call graph for this function:

## § dbgetchar()

char* dbgetchar | ( | DBPROCESS * | dbproc,
|  | int | pos
| ) |  |

Get address of a position in the command buffer.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  pos | offset within the command buffer, starting at 0.

Remarks
  A bit overspecialized, this one.

See also
  dbcmd(), dbfcmd(), dbfreebuf(), dbstrcpy(), dbstrlen(),

Here is the call graph for this function:

## § dbgetmaxprocs()

int dbgetmaxprocs | ( | void |  | ) |

get maximum simultaneous connections db-lib will open to the server.

Returns
  Current maximum.

See also
  dbsetmaxprocs(), dbopen()

Here is the call graph for this function:

## § dbgetpacket()

int dbgetpacket | ( | DBPROCESS * | dbproc | ) |

Get TDS packet size for the connection.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Returns
  TDS packet size, in bytes.

See also
  DBSETLPACKET()

Here is the call graph for this function:

## § dbgetrow()

RETCODE dbgetrow | ( | DBPROCESS * | dbproc,
|  | DBINT | row
| ) |  |

Read a row from the row buffer.

When row buffering is enabled (DBBUFFER option is on), the client can use dbgetrow() to re-read a row previously fetched with dbnextrow(). The effect is to move the row pointer – analogous to fseek() – back to row. Calls to dbnextrow() read from row + 1 until the buffer is exhausted, at which point it resumes its normal behavior, except that as each row is fetched from the server, it is added to the row buffer (in addition to being returned to the client). When the buffer is filled, dbnextrow() returns `FAIL` until the buffer is at least partially emptied with dbclrbuf().

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  row | Nth row to read, starting with 1.

Return values

  REG_ROW | returned row is a regular row.

Returns
  computeid when returned row is a compute row.

Return values

  NO_MORE_ROWS | no such row in the row buffer. Current row is unchanged.
  FAIL | unsuccessful; row buffer may be full.

See also
  dbaltbind(), dbbind(), dbclrbuf(), DBCURROW(), DBFIRSTROW(), DBLASTROW(), dbnextrow(), dbsetrow().

## § dbgettime()

int dbgettime | ( | void |  | ) |

Get maximum seconds db-lib waits for a server response to query.

Return values

  query | timeout limit, in seconds

See also
  dberrhandle(), DBSETTIME(), dbsetlogintime(), dbsqlexec(), dbsqlok(), dbsqlsend().

Here is the call graph for this function:

## § dbgetuserdata()

BYTE* dbgetuserdata | ( | DBPROCESS * | dbproc | ) |

Get address of user-allocated data from a `DBPROCESS`.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Returns
  address of user-defined data that `db-lib` associated with dbproc when the client called dbsetuserdata().

Return values

  undefined | (probably `NULL`) dbsetuserdata() was not previously called.

See also
  dbsetuserdata().

Here is the call graph for this function:

## § dbinit()

RETCODE dbinit | ( | void |  | ) |

Initialize db-lib.

Remarks
  Call this function before trying to use db-lib in any way. Allocates various internal structures and reads `locales.conf` (if any) to determine the default date format.

Return values

  SUCCEED | normal.
  FAIL | cannot allocate an array of `TDS_MAX_CONN` `TDSSOCKET` pointers.

## § dbiscount()

BOOL dbiscount | ( | DBPROCESS * | dbproc | ) |

Indicates whether or not the count returned by dbcount is real (Microsoft-compatibility feature).

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Returns
  TRUE if the count returned by dbcount is real or FALSE if the count returned by dbcount is not real.

See also
  DBCOUNT(), dbcount().

Here is the call graph for this function:

## § dbisopt()

DBBOOL dbisopt | ( | DBPROCESS * | dbproc,
|  | int | option,
|  | const char | param[]
| ) |  |

Get value of an option.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  option | the option
  param | a parameter to option.

See also
  dbclropt(), dbsetopt().

Here is the call graph for this function:

## § dblogin()

LOGINREC* dblogin | ( | void |  | ) |

Allocate a `LOGINREC` structure.

Remarks
  A `LOGINREC` structure is passed to `dbopen()` to create a connection to the database. Does not communicate to the server; interacts strictly with library.

Return values

  NULL | the `LOGINREC` cannot be allocated.
  LOGINREC* | to valid memory, otherwise.

Here is the call graph for this function:

## § dbloginfree()

void dbloginfree | ( | LOGINREC * | login | ) |

free the `LOGINREC`

Here is the call graph for this function:

## § dbmorecmds()

RETCODE dbmorecmds | ( | DBPROCESS * | dbproc | ) |

See if more commands are to be processed.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

See also
  DBMORECMDS(). DBCMDROW(), dbresults(), DBROWS(), DBROWTYPE().

Here is the call graph for this function:

## § dbmoretext()

RETCODE dbmoretext | ( | DBPROCESS * | dbproc,
|  | DBINT | size,
|  | const BYTE | text[]
| ) |  |

Send chunk of a text/image value to the server.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  size | count of bytes to send.
  text | textpointer, obtained from dbtxptr.

Return values

  SUCCEED | always.

See also
  dbtxptr(), dbtxtimestamp(), dbwritetext().

Todo:
  Check return value of called functions and return `FAIL` if appropriate.

Here is the call graph for this function:

## § dbmsghandle()

MHANDLEFUNC dbmsghandle | ( | MHANDLEFUNC | handler | ) |

Set a message handler, for messages from the server.

Parameters

  handler | address of the function that will process the messages.

See also
  DBDEAD(), dberrhandle().

## § dbname()

char* dbname | ( | DBPROCESS * | dbproc | ) |

Get name of current database.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Returns
  current database name, as null-terminated ASCII string.

See also
  dbchange(), dbuse().

Here is the call graph for this function:

## § dbnullbind()

RETCODE dbnullbind | ( | DBPROCESS * | dbproc,
|  | int | column,
|  | DBINT * | indicator
| ) |  |

Tie a null-indicator to a regular result column.

When a row is fetched, the indicator variable tells the state of the column's data.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  column | Nth column in the result set, starting with 1.
  indicator | address of host variable.

Return values

  SUCCEED | variable accepted.
  FAIL | indicator is NULL or column is out of range.

Remarks
  Contents of indicator are set with `dbnextrow()`. Possible values are:
  - 0 column bound successfully
  - -1 column is NULL.
  - >0 true length of data, had column not been truncated due to insufficient space in the columns bound host variable .

See also
  dbanullbind(), dbbind(), dbdata(), dbdatlen(), dbnextrow().

Here is the call graph for this function:

## § dbnumalts()

int dbnumalts | ( | DBPROCESS * | dbproc,
|  | int | computeid
| ) |  |

Get count of columns in a compute row.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  computeid | of `COMPUTE` clause to which we're referring.

Returns
  number of columns, else -1 if no such computeid.

See also
  dbadata(), dbadlen(), dbaltlen(), dbalttype(), dbgetrow(), dbnextrow(), dbnumcols().

Here is the call graph for this function:

## § dbnumcols()

int dbnumcols | ( | DBPROCESS * | dbproc | ) |

Return number of regular columns in a result set.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

See also
  dbcollen(), dbcolname(), dbnumalts().

Here is the call graph for this function:

## § dbnumcompute()

int dbnumcompute | ( | DBPROCESS * | dbproc | ) |

Get count of `COMPUTE` clauses for a result set.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Returns
  number of compute clauses for the current query, possibly zero.

See also
  dbnumalts(), dbresults().

Here is the call graph for this function:

## § dbprcollen()

DBINT dbprcollen | ( | DBPROCESS * | dbproc,
|  | int | column
| ) |  |

Get size of a result column needed to print column.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  column | Nth in the result set, starting from 1.

Returns
  size of the column in characters (not of data in any particular row). On error, -1.

See also
  dbcolname(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols().

Here is the call graph for this function:

## § dbprhead()

void dbprhead | ( | DBPROCESS * | dbproc | ) |

Print result set headings to stdout.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

See also

Here is the call graph for this function:

## § dbprrow()

RETCODE dbprrow | ( | DBPROCESS * | dbproc | ) |

Print a result set to stdout.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

See also
  dbbind(), dbnextrow(), dbprhead(), dbresults(), dbspr1row(), dbsprhead(), dbsprline().

Here is the call graph for this function:

## § dbprtype()

const char* dbprtype | ( | int | token | ) |

Print a token value's name to a buffer.

Parameters

  token | server SYB* value, e.g. SYBINT.

Returns
  ASCII null-terminated string.

See also
  dbaltop(), dbalttype(), dbcoltype(), dbrettype().

Here is the call graph for this function:

## § dbreadtext()

STATUS dbreadtext | ( | DBPROCESS * | dbproc,
|  | void * | buf,
|  | DBINT | bufsize
| ) |  |

Fetch part of a text or image value from the server.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  buf | output: buffer into which text will be placed.
  bufsize | size of buf, in bytes.

Returns
  - `>0` count of bytes placed in buf.
  - `0` end of row.
  - `-1` error, no result set ready for dbproc.
  - `NO_MORE_ROWS` all rows read, no further data.

See also
  dbmoretext(), dbnextrow(), dbwritetext().

Here is the call graph for this function:

## § dbrecftos()

void dbrecftos | ( | const char | filename[] | ) |

Record to a file all SQL commands sent to the server.

Parameters

  filename | name of file to write to.

Remarks
  Files are named filename.n, where n is an integer, starting with 0, and incremented with each callto dbopen().

See also
  dbopen(), TDSDUMP environment variable().

Here is the call graph for this function:

## § dbresults()

RETCODE dbresults | ( | DBPROCESS * | dbproc | ) |

Set up query results.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Return values

  SUCCEED | Some results are available.
  FAIL | query was not processed successfully by the server
  NO_MORE_RESULTS | query produced no results.

Remarks
  Call dbresults() after calling dbsqlexec() or dbsqlok(), or dbrpcsend() returns SUCCEED. Unless one of them fails, dbresults will return either SUCCEED or NO_MORE_RESULTS.

The meaning of results is very specific and not very intuitive. Results are created by either

- a SELECT statement

  - a stored procedure

  When dbresults returns SUCCEED, therefore, it indicates the server processed the query successfully and that one or more of these is present:

- metadata – dbnumcols() returns 1 or more
- data – dbnextrow() returns SUCCEED
- return status – dbhasretstat() returns TRUE
- output parameters – dbnumrets() returns 1 or more

If none of the above are present, dbresults() returns NO_MORE_RESULTS.

SUCCEED does not imply that DBROWS() will return TRUE or even that dbnumcols() will return nonzero. A general algorithm for reading results will call dbresults() until it return NO_MORE_RESULTS (or FAIL). An application should check for all the above kinds of results within the dbresults() loop.

See also
  dbsqlexec(), dbsqlok(), dbrpcsend(), dbcancel(), DBROWS(), dbnextrow(), dbnumcols(), dbhasretstat(), dbretstatus(), dbnumrets()

Here is the call graph for this function:

## § dbsafestr()

RETCODE dbsafestr | ( | DBPROCESS * | dbproc,
|  | const char * | src,
|  | DBINT | srclen,
|  | char * | dest,
|  | DBINT | destlen,
|  | int | quotetype
| ) |  |

safely quotes character values in SQL text.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  src | input string.
  srclen | length of src in bytes, or -1 to indicate it's null-terminated.
  dest | output: client-provided output buffer.
  destlen | size of dest in bytes, or -1 to indicate it's "big enough" and the data should be null-terminated.
  quotetype | `DBSINGLE` Doubles all single quotes ('). `DBDOUBLE` Doubles all double quotes ("). `DBBOTH` Doubles all single and double quotes.

Return values

  SUCCEED | everything worked.
  FAIL | no such quotetype, or insufficient room in dest.

See also
  dbcmd(), dbfcmd().

## § dbservcharset()

char* dbservcharset | ( | DBPROCESS * | dbproc | ) |

Get `syscharset` name of the server character set.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Returns
  name of server's charset, as null-terminated ASCII string.

See also
  dbcharsetconv(), dbgetcharset(), DBSETLCHARSET().

Here is the call graph for this function:

## § dbsetifile()

void dbsetifile | ( | char * | filename | ) |

set name and location of the `interfaces` file FreeTDS should use to look up a servername.

Does not affect lookups or location of `freetds.conf`.

Parameters

  filename | name of `interfaces`

See also
  dbopen()

Here is the call graph for this function:

## § dbsetinterrupt()

void dbsetinterrupt | ( | DBPROCESS * | dbproc,
|  | DB_DBCHKINTR_FUNC | chkintr,
|  | DB_DBHNDLINTR_FUNC | hndlintr
| ) |  |

Set interrupt handler for db-lib to use while blocked against a read from the server.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  chkintr |
  hndlintr |

See also
  dbcancel(), dbgetuserdata(), dbsetuserdata(), dbsetbusy(), dbsetidle().

## § dbsetlogintime()

RETCODE dbsetlogintime | ( | int | seconds | ) |

Set maximum seconds db-lib waits for a server response to a login attempt.

Parameters

  seconds | New limit for application.

Return values

  SUCCEED | Always.

See also
  dberrhandle(), dbsettime()

Here is the call graph for this function:

## § dbsetlversion()

RETCODE dbsetlversion | ( | LOGINREC * | login,
|  | BYTE | version
| ) |  |

Set TDS version for future connections.

Here is the call graph for this function:

## § dbsetmaxprocs()

RETCODE dbsetmaxprocs | ( | int | maxprocs | ) |

Set maximum simultaneous connections db-lib will open to the server.

Parameters

  maxprocs | Limit for process.

Return values

  SUCCEED | Always.

See also
  dbgetmaxprocs(), dbopen()

Here is the call graph for this function:

## § dbsetnull()

RETCODE dbsetnull | ( | DBPROCESS * | dbproc,
|  | int | bindtype,
|  | int | bindlen,
|  | BYTE * | bindval
| ) |  |

Define substitution values to be used when binding null values.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  bindtype | type of binding to which the substitute value will apply.
  bindlen | size of the substitute value you are supplying, in bytes. Ignored except for CHARBIND and BINARYBIND.
  bindval | pointer to a buffer containing the substitute value.

Return values

  SUCCEED | query was processed without errors.
  FAIL | query was not processed

See also
  dbaltbind(), dbbind(), dbconvert(), dbnullbind().

Here is the call graph for this function:

## § dbsetopt()

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

Set db-lib or server option.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  option | option to set.
  char_param | value to set option to, if it wants a null-teminated ASCII string.
  int_param | value to set option to, if it wants an integer value.

Return values

  SUCCEED | everything worked.
  FAIL | no such option, or insufficient memory, or unimplemented.

Remarks
  Many are unimplemented.

See also
  dbclropt(), dbisopt().

Todo:
  Implement more options.

Here is the call graph for this function:

## § dbsetrow()

STATUS dbsetrow | ( | DBPROCESS * | dbproc,
|  | DBINT | row
| ) |  |

Make a buffered row "current" without fetching it into bound variables.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Return values

  MORE_ROWS | row found
  NO_MORE_ROWS | row not found
  FAIL | dbproc is dead or not enabled

See also
  dbaltbind(), dbbind(), dbcanquery(), dbclrbuf(), dbgetrow(), dbnextrow(), dbprrow().

Here is the call graph for this function:

## § dbsettime()

RETCODE dbsettime | ( | int | seconds | ) |

Set maximum seconds db-lib waits for a server response to query.

Parameters

  seconds | New limit for application.

Return values

  SUCCEED | Always.

See also
  dberrhandle(), DBGETTIME(), dbsetlogintime(), dbsqlexec(), dbsqlok(), dbsqlsend().

Here is the call graph for this function:

## § dbsetuserdata()

void dbsetuserdata | ( | DBPROCESS * | dbproc,
|  | BYTE * | ptr
| ) |  |

Associate client-allocated (and defined) data with a `DBPROCESS`.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  ptr | address of client-defined data.

Remarks
  ptr is the location of user data that `db-lib` will associate with dbproc. The client allocates the buffer addressed by ptr. `db-lib` never examines or uses the information; it just stashes the pointer for later retrieval by the application with `dbgetuserdata()`.

See also
  dbgetuserdata().

Here is the call graph for this function:

## § dbsetversion()

RETCODE dbsetversion | ( | DBINT | version | ) |

Specify a db-lib version level.

Parameters

  version | anything, really.

Return values

  SUCCEED | Always.

Remarks
  No effect on behavior of `db-lib` in `FreeTDS`.

See also

Here is the call graph for this function:

## § dbspid()

int dbspid | ( | DBPROCESS * | dbproc | ) |

Get server process ID for a `DBPROCESS`.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Returns
  "spid", the server's process ID.

See also
  dbopen().

Here is the call graph for this function:

## § dbspr1row()

RETCODE dbspr1row | ( | DBPROCESS * | dbproc,
|  | char * | buffer,
|  | DBINT | buf_len
| ) |  |

Print a regular result row to a buffer.

Fills a buffer with one data row, represented as a null-terminated ASCII string. Helpful for debugging.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  buffer | output: Address of a buffer to hold ASCII null-terminated string.
  buf_len | size of buffer, in bytes.

Return values

  SUCCEED | on success.
  FAIL | trouble encountered.

See also
  dbclropt(), dbisopt(), dbprhead(), dbprrow(), dbspr1rowlen(), dbsprhead(), dbsprline().

Here is the call graph for this function:

## § dbspr1rowlen()

DBINT dbspr1rowlen | ( | DBPROCESS * | dbproc | ) |

Determine size buffer required to hold the results returned by dbsprhead(), dbsprline(), and dbspr1row().

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Returns
  size of buffer requirement, in bytes.

Remarks
  An esoteric function.

See also
  dbprhead(), dbprrow(), dbspr1row(), dbsprhead(), dbsprline().

Here is the call graph for this function:

## § dbsprhead()

RETCODE dbsprhead | ( | DBPROCESS * | dbproc,
|  | char * | buffer,
|  | DBINT | buf_len
| ) |  |

Print result set headings to a buffer.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  buffer | output buffer
  buf_len | size of buffer

Return values

  SUCCEED | buffer filled.
  FAIL | insufficient spaace in buffer, usually.

See also
  dbprhead(), dbprrow(), dbsetopt(), dbspr1row(), dbspr1rowlen(), dbsprline().

Here is the call graph for this function:

## § dbsprline()

RETCODE dbsprline | ( | DBPROCESS * | dbproc,
|  | char * | buffer,
|  | DBINT | buf_len,
|  | DBCHAR | line_char
| ) |  |

Get formatted string for underlining dbsprhead() column names.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  buffer | output buffer
  buf_len | size of buffer
  line_char | character to use to represent underlining.

Return values

  SUCCEED | buffer filled.
  FAIL | insufficient space in buffer, usually.

See also
  dbprhead(), dbprrow(), dbspr1row(), dbspr1rowlen(), dbsprhead().

Here is the call graph for this function:

## § dbsqlexec()

RETCODE dbsqlexec | ( | DBPROCESS * | dbproc | ) |

send the SQL command to the server and wait for an answer.

Please be patient. This function waits for the server to respond. `dbsqlexec` is equivalent to dbsqlsend() followed by dbsqlok().

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Return values

  SUCCEED | query was processed without errors.
  FAIL | was returned by dbsqlsend() or dbsqlok().

See also
  dbcmd(), dbfcmd(), dbnextrow(), dbresults(), dbretstatus(), dbsettime(), dbsqlok(), dbsqlsend()

## § dbsqlok()

RETCODE dbsqlok | ( | DBPROCESS * | dbproc | ) |

Wait for results of a query from the server.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Return values

  SUCCEED | everything worked, fetch results with `dbnextresults()`.
  FAIL | SQL syntax error, typically.

See also
  dbcmd(), dbfcmd(), DBIORDESC(), DBIOWDESC(), dbmoretext(), dbnextrow(), dbpoll(), DBRBUF(), dbresults(), dbretstatus(), dbrpcsend(), dbsettime(), dbsqlexec(), dbsqlsend(), dbwritetext().

## § dbsqlsend()

RETCODE dbsqlsend | ( | DBPROCESS * | dbproc | ) |

Transmit the command buffer to the server.

Non-blocking, does not wait for a response.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

Return values

  SUCCEED | SQL sent.
  FAIL | protocol problem, unless dbsqlsend() when it's not supposed to be (in which case a db-lib error message will be emitted).

See also
  dbcmd(), dbfcmd(), DBIORDESC(), DBIOWDESC(), dbnextrow(), dbpoll(), dbresults(), dbsettime(), dbsqlexec(), dbsqlok().

Here is the call graph for this function:

## § dbstrbuild()

RETCODE dbstrbuild | ( | DBPROCESS * | dbproc,
|  | char * | charbuf,
|  | int | bufsize,
|  | char * | text,
|  | char * | formats,
|  |  | ...
| ) |  |

Build a printable string from text containing placeholders for variables.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  charbuf | output: buffer that will contain the ASCII null-terminated string built by `dbstrbuild()`.
  bufsize | size of charbuf, in bytes.
  text | null-terminated ASCII string, with placeholders for variables. A Placeholder is a three-byte string, made up of: '' a percent sign 0-9 an integer (designates the argument number to use, starting with 1.) '!' an exclamation point
  formats | null-terminated ASCII sprintf-style string. Has one format specifier for each placeholder in text.

Remarks
  Following formats are the arguments, the values to substitute for the placeholders.

See also
  dbconvert(), dbdatename(), dbdatepart().

Here is the call graph for this function:

## § dbstrcpy()

RETCODE dbstrcpy | ( | DBPROCESS * | dbproc,
|  | int | start,
|  | int | numbytes,
|  | char * | dest
| ) |  |

Get a copy of a chunk of the command buffer.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  start | position in the command buffer to start copying from, starting from 0. If start is past the end of the command buffer, dbstrcpy() inserts a null terminator at dest[0].
  numbytes | number of bytes to copy. If -1, dbstrcpy() copies the whole command buffer. If 0 dbstrcpy() writes a `NULL` to dest[0]. If the command buffer contains fewer than numbytes (taking start into account) dbstrcpy() copies the rest of it.
  dest | output: the buffer to write to. Make sure it's big enough.

Return values

  SUCCEED | the inputs were valid and dest was affected.
  FAIL | start < 0 or numbytes < -1.

See also
  dbcmd(), dbfcmd(), dbfreebuf(), dbgetchar(), dbstrlen().

Here is the call graph for this function:

## § dbstrlen()

int dbstrlen | ( | DBPROCESS * | dbproc | ) |

Get size of the command buffer, in bytes.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.

See also
  dbcmd(), dbfcmd(), dbfreebuf(), dbgetchar(), dbstrcpy().

Here is the call graph for this function:

## § dbtablecolinfo()

RETCODE dbtablecolinfo | ( | DBPROCESS * | dbproc,
|  | DBINT | column,
|  | DBCOL * | pdbcol
| ) |  |

describe table column attributes with a single call (Freetds-only API function modelled on dbcolinfo)

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  column | Nth in the result set, starting from 1.
  pdbcol | address of structure to be populated by this function.

Returns
  SUCCEED or FAIL.

See also
  dbcolinfo().

Here is the call graph for this function:

## § dbtxptr()

DBBINARY* dbtxptr | ( | DBPROCESS * | dbproc,
|  | int | column
| ) |  |

Get text pointer for a column in the current row.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  column | number of the column in the `SELECT` statement, starting at 1.

Returns
  text pointer for column, may be NULL.

See also
  dbtxtimestamp(), dbwritetext().

Here is the call graph for this function:

## § dbtxtimestamp()

DBBINARY* dbtxtimestamp | ( | DBPROCESS * | dbproc,
|  | int | column
| ) |  |

Get text timestamp for a column in the current row.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  column | number of the column in the `SELECT` statement, starting at 1.

Returns
  timestamp for column, may be NULL.

See also
  dbtxptr(), dbwritetext().

Here is the call graph for this function:

## § dbuse()

RETCODE dbuse | ( | DBPROCESS * | dbproc,
|  | const char * | name
| ) |  |

Change current database.

Analagous to the unix command `cd`, dbuse() makes name the default database. Waits for an answer from the server.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  name | database to use.

Return values

  SUCCEED | query was processed without errors.
  FAIL | query was not processed

See also
  dbchange(), dbname().

Here is the call graph for this function:

## § dbvarylen()

DBINT dbvarylen | ( | DBPROCESS * | dbproc,
|  | int | column
| ) |  |

Determine whether a column can vary in size.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  column | Nth in the result set, starting from 1.

Return values

  TRUE | datatype of column can vary in size, or is nullable.
  FALSE | datatype of column is fixed and is not nullable.

See also
  dbcollen(), dbcolname(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols(), dbprtype().

Here is the call graph for this function:

## § dbversion()

const char* dbversion | ( | void |  | ) |

See which version of db-lib is in use.

Returns
  null-terminated ASCII string representing the version of db-lib.

Remarks
  FreeTDS returns the CVS version string of dblib.c.

See also

Here is the call graph for this function:

## § dbwillconvert()

DBBOOL dbwillconvert | ( | int | srctype,
|  | int | desttype
| ) |  |

Test whether or not a datatype can be converted to another datatype.

Parameters

  srctype | type converting from
  desttype | type converting to

Remarks
  dbwillconvert() lies sometimes. Some datatypes should be convertible but aren't yet in our implementation. Legal unimplemented conversions return TRUE.

Return values

  TRUE | convertible, or should be.
  FAIL | not convertible.

See also
  dbaltbind(), dbbind(), dbconvert(), dbconvert_ps(), `src/dblib/unittests/convert`().c().

Here is the call graph for this function:

## § dbwritetext()

RETCODE dbwritetext | ( | DBPROCESS * | dbproc,
|  | char * | objname,
|  | DBBINARY * | textptr,
|  | DBTINYINT | textptrlen,
|  | DBBINARY * | timestamp,
|  | DBBOOL | log,
|  | DBINT | size,
|  | BYTE * | text
| ) |  |

Send text or image data to the server.

Parameters

  dbproc | contains all information needed by db-lib to manage communications with the server.
  objname | table name
  textptr | text pointer to be modified, obtained from dbtxptr().
  textptrlen | Ignored. Supposed to be `DBTXPLEN`.
  timestamp | text timestamp to be modified, obtained from dbtxtimestamp() or dbtxtsnewval(), may be `NULL`.
  log | `TRUE` if the operation is to be recorded in the transaction log.
  size | overall size of the data (in total, not just for this call), in bytes. A guideline, must not overstate the case.
  text | the chunk of data to write.

Return values

  SUCCEED | everything worked.
  FAIL | not sent, possibly because timestamp is invalid or was changed in the database since it was fetched.

See also
  dbmoretext(), dbtxptr(), dbtxtimestamp(), dbwritetext(), dbtxtsput().

Here is the call graph for this function: