Solved

How to return these variables

Posted on 1999-01-20
3
216 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

746 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now