Solved

How to return these variables

Posted on 1999-01-20
3
218 Views
Last Modified: 2012-06-21
I would like to create a function like this which works on sql api:

char szName[10];
int nCount;

...
SQLBindCol( hStmt, 1, SQL_C_CHAR, szName, sizeof( szName ), NULL );
SQLBindCol( hStmt, 2, SQL_LONG, &nCount, 0, NULL );
SQLFetch( ... );

The variables szName & nCount is not assigned until SQLFetch() is called.  How is the function able to send this values back to me?  Can someone write a small sample for the two on how it does this.

Thanks
0
Comment
Question by:eric07
3 Comments
 
LVL 6

Expert Comment

by:zebada
ID: 1258227
Hi Eric,

The two bind calls pass in the address of szName and nCount.  These addresses are
saved inside the data structure called hStmt. This "saving" of the variable's address
is called bindind which is why the function is called SQLBindCol().

I presume the SQLFetch() function requires you to also pass in hStmt.

When the SQLFetch() function is called the function "knows" the addresses of the two
'C' variables (szName and nCount) since they were "bound" to the hStmt previously.
The SQLFetch() function is then able to store data at those addresses, and limited
by the "size" of the variables. Note: the size is also passed in the SQLBind() statement
for non-simple types.

0
 
LVL 1

Accepted Solution

by:
nsrvijay earned 30 total points
ID: 1258228
Hi
  SqlBinCol binds columns in the result set to data buffers and when u finally call SQlfetch, the driver returns the data to the bound columns.The Sqlfetch function places the data for each bound column in the buffer bound to that column...

bye
vijay
 
0
 

Expert Comment

by:bcn
ID: 1258229
Do you Know SQLC?


0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question