dbtabsource

DB Library for C

DB Library for C

dbtabsource

Returns the name and number of the table from which a particular result column was derived.

Syntax

LPCSTR dbtabsource ( PDBPROCESS dbproc,
INT colnum,
LPINT tabnum );

Arguments

dbproc

Is the DBPROCESS structure that is the handle for a particular workstation or Microsoft® SQL Server™ 2000 process. It contains all the information that DB-Library uses to manage communications and data between the workstation and SQL Server.

colnum

Is the number of the result column. Column numbers start at 1.

tabnum

Is a pointer to an integer, which is filled in with the table's number. Many DB-Library functions that deal with browse mode accept either a table name or a table number. If dbtabsource returns NULL (see Returns), tabnum is set to -1.

Returns

A pointer to the name of the table from which this result column was derived. A NULL return value can mean one of the following:

  • The DBPROCESS structure is inactive or not enabled. This is an error that causes an application's error handler to be invoked.

  • The SELECT statement does not contain the FOR BROWSE clause.

  • The column number is out of range.

  • The column is the result of an expression, such as "MAX(colname)".
Remarks

dbtabsource is one of the DB-Library browse-mode functions. For a detailed discussion of browse mode, see Browse Mode in Programming DB-Library for C.

The dbtabsource function allows an application to determine which tables provided the columns in the current set of result rows. This information is valuable when using dbqual to construct WHERE clauses for UPDATE and DELETE statements based on ad hoc queries. If the query has been hard-coded into the program, this function is unnecessary.

The dbtabsource function can be called any time after dbresults.

See Also

dbcolbrowse

dbtabbrowse

dbcolsource

dbtabcount

dbqual

dbtsnewval

dbresults

dbtsput