TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: Darin McBride
from: Neil Heller
date: 2003-01-31 10:18:00
subject: Declaring a pointer to a

NH> The count command became part of the SQL standard in SQL-92.  
NH> Unfortunately, I have not been able to find a corresponding
NH> command in  ODBC.  If I were to use the count command in an
NH> SQLExecDirect statement,  I don't have a clue as to how I could
NH> retrieve any sort of return value.

DM> SQLGetData?  Same as any select?

No, that's a different animal.  Here is what Watcom says about 
SQLGetData():

SQLGetData returns result data for a single column in the current row. 
Unlike SQLBindCol, which causes data to be transferred to a program 
variable when SQLFetch or SQLExtendedFetch is called, SQLGetData can 
only return result data for a single column in the current row. In other 
words, SQLFetch or SQLExtendedFetch moves the cursor to the next row and 
implicitly transfers data when SQLBindCol has been used, but SQLFetch or 
SQLExtendedFetch merely move the cursor to the next row when SQLGetData 
is used - the data is only transferred to the program variable when 
SQLGetData is called. It is possible to use SQLBindCol for some columns 
and use SQLGetData for others within the same row.  This function can be 
used to retrieve long data values in portions (for example, data from 
SQL_LONGVARBINARY or SQL_LONGVARCHAR columns).

DM> SQLINTEGER count;
DM> if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_DATA)
DM> {
DM>   SQLINTEGER cb;
DM>   SQLGetData(bstmt, &count, 0, &cb);
DM> }

DM> (This is just from reading the msdn for the last 5 minutes 
DM> after a google search on "odbc api" - I've never dealt with 
DM> odbc before in my life.)

That's good way - I wish ODBC were implemented that way.

Syntax

RETCODE SQLGetData(hstmt,icol,fCType,rgbValue,cbValueMax,pcbValue)
The SQLGetData function accepts the following arguments:

SDWORD FAR * pcbValue

Output: The total number of bytes (excluding the null termination byte) 
available to return in rgbValue or SQL_NO_TOTAL if the number of 
available bytes cannot be determined. If pcbValue is SQL_NO_TOTAL or is 
greater than or equal to cbValueMax, the data in rgbValue is truncated 
to cbValueMax - 1 bytes.
If the data value is NULL, pcbValue is SQL_NULL_DATA.

Returns

SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_NO_DATA_FOUND, 
SQL_STILL_EXECUTING, SQL_ERROR, or SQL_INVALID_HANDLE.

NH> ... as the one above will really result in time savings over
NH> constructing a linked list on the heap for about 200 entries.

DM> YES!  I use count() soooo much, and as long as it's 
DM> counting either everything or something where there's an 
DM> index, it's way faster.  Way, way, way faster.  Even 
DM> without using the index it's still faster than reading 
DM> everything into memory in a linked list and then counting 
DM> that yourself.

If I can construct a linked-list, there's no need to do a count.  Each 
node of the list consists of four pointers, so I don't even have to 
consider paragraph boundaries when constructing the list.

I'm back to trying to implement "count".  It's helpful to know that the 
speed difference is significant.

þ CMPQwk 1.42 999

--- Maximus/2 3.01
* Origin: COMM Port OS/2 juge.com 204.89.247.1 (281) 980-9671 (1:106/2000)
SEEN-BY: 633/267 270
@PATH: 106/2000 1 379/1 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.