Subject Re: [ib-support] API XSQLVAR struct ?
Author William L. Thomson Jr.
Raul,
Thanks for your response.
On Mon, 2002-07-22 at 19:19, Raul Chirea wrote:
> Hi William,
>
> > I am a bit confused here. Please excuse my lack of knowledge when it
> > comes to C/C++.
>
> You are (excused ;-) !

Again, thank you. :)

> Did you read the API guide ? It contains every step needed to access IB/FB
> using API and good descriptions of the data structures.

Yes, I damn near have it memorized, but it is not helping me with my
problems. I have many as any C/C++ newbie will. But I will not learn
without falling on my face. Thank god for plastic surgery. ;)

> > I am pretty confused about the
> >
> > XSQLVAR.sqldata
> >
> > In the ibase.h file it says it's the address of the data.
> > Defined as a char ISC_FAR *sqldata;
> >
> > First of what is ISC_FAR.
>
> If you are using other OS but DOS ISC_FAR means nothing (as you observed).

Thanks, been a long time since dos, and I mainly played games on it.
What wonderful four color games. ;)

> > Further more why is the only way to retrieve the actual data is by using
> > a struct with a var inside the struct to get the data from the position
> > in the row?
>
> I'm not sure I understand your question !
> Anyway, "char *sqldata" is a buffer you must allocate to receive data into
> it, as well as "short *sqlind" if you want to have a "null" indicator.

Here goes. I create a struct like

struct VAR {
short var_length;
string var_string[30];
};

I then create an array of structs which seem to all be using the amount
of memory for one struct. But that is another problem I am working on.

I then do a loop like

for(int i=0;i<num_cols;i++) {
osqlda->sqlvar[i].sqldata = (char *)&var[i];
osqlda->sqlvar[i].sqltype = SQL_VARYING + 1;
osqlda->sqlvar[i].sqlind = &flag[i];
}

Then I can get at the actual data by doing another loop while fetching
like

while((fetch_code = isc_dsql_fetch(status,&stmt_handle,1,osqlda)) == 0){
for(int i=0;i<num_cols;i++) {
cout << var[i].var_string << " ";
}
cout << endl;
}

So I am asking why the only way I can get at the data is by passing a
struct.

osqlda->sqlvar[i].sqldata = (char *)&var[i];

and then doing

var[i].var_string

To get at my data. I would like to not use a struct if possible?
But every attempt at something other than a struct fails?

--
Sincerely,
William L. Thomson Jr.
Support Group
Obsidian-Studios Inc.
439 Amber Way
Petaluma, Ca. 94952
Phone 707.766.9509
Fax 707.766.8989
http://www.obsidian-studios.com