?
Solved

How to return these variables

Posted on 1999-01-20
3
Medium Priority
?
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 60 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Suggested Courses
Course of the Month13 days, 6 hours left to enroll

801 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