SQLRetrieveColSize

Syntax

SQLRetrieveColSize(ConnectNum, ColNum)

Remarks

Determines the maximum width of the string values in the specified column of the data source. To use SQLRetrieveColSize, a macro must have already established a connection using SQLOpen. Also, a query must already have been executed using SQLQueryExec, and results must be pending. Use the value returned by SQLRetrieveColSize in a String$() instruction to create a variable large enough to contain the value assigned to it by subsequent SQLQueryRetrieve instructions.

You cannot use SQLRetrieveColSize to determine the width of a column in the query results returned by SQLExecQuery.

Argument

Explanation

ConnectNum

The unique connection ID for a data source. If ConnectNum is not valid, SQLQueryExec would have returned an error value. In such a case, SQLRetrieveColSize places error information in memory for the error functions, if such information is available.


SQLRetrieveColSize returns the maximum width of the specified column in the data source. Note that the column size is one-based; that is, the first column is 1, not 0 (zero).

SQLRetrieveColSize returns 0 (zero) if it cannot determine the maximum width of the column, and places error information in memory for the error functions, if such information is available.

If there are no results pending on the connection, no data was found, or there is no data, SQLRetrieveColSize returns –1 (SQL_NoMoreData).

Example

The following example uses the value returned by SQLRetrieveColSize in a String$() instruction to make the variable stor$ large enough to use in the subsequent SQLQueryRetrieve instruction. The value returned by SQLRetrieveColSize is also used in the SQLQueryRetrieve instruction to indicate how many characters to return from specified column of the data source.


storsize = SQLRetrieveColSize(connect_no, 1)
stor$ = String$(storsize, 35)        'creates a string # characters
SQLQueryRetrieve(connect_no, 1, stor$, storsize)