DB Library for C

DB Library for C


Returns the number of tables involved in the current SELECT statement.


INT dbtabcount ( PDBPROCESS 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.


The number of tables, including SQL Server work tables, involved in the current set of row results. A value of -1 is returned if an invalid dbproc value is sent to dbtabcount.


The dbtabcount function 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.

A SELECT statement can generate a set of result rows whose columns are derived from several database tables. To perform browse-mode updates of columns in a statement's select list, the application must know how many tables were involved in the query, because each table requires a separate UPDATE statement. The dbtabcount function can provide this information for ad hoc queries. If the query has been hard-coded into the program, this function is unnecessary.

The count returned by this function includes any SQL Server work tables used in processing the query. The SQL Server sometimes creates temporary, internal work tables to process a query. It deletes these work tables by the time it finishes processing the statement. Work tables cannot be updated and are not available to the application. Therefore, before using a table number, the application must make sure that it does not belong to a work table. The dbtabname function can be used to determine whether a particular table number refers to a work table.

The dbtabcount function can be called any time after dbresults.

See Also