Subject Re: [ib-support] API XSQLVAR struct ?
Author Raul Chirea
Hi William,

""William L. Thomson Jr."" <support@...> wrote in message

> Ok, let me see if I can make my question easier.
> What type of var array should I create so I can get the output out of
> osqlda->sqlvar[i].sqldata = // <- Here

It depends of "osqlda->sqlvar[i].sqltype" you use for that field.
"osqlda->sqlvar[i].sqldata" is JUST A POINTER to a memory area in which
server expects/places parameter/field data. For example if you bind, let's
say, a double field you should do like this:

double dblval;
osqlda->sqlvar[i].sqltype = SQL_DOUBLE;
osqlda->sqlvar[i].sqldata = (char *)malloc(sizeof(double));
/* and after a fetch you can read the fetched value from that location */

dblval = *((double *)(osqlda->sqlvar[i].sqldata));

/* after that the "dblval" variable should contain the value of that field

> It says it is a char * and returns the location of the data.

Yes but in this case "char *" means just a pointer. Mabe it would be better
to be "void *" !

> But if I pass a char * var to it I have problems. Now I have swapped to
> SQL_TEXT instead of SQL_VARYING. But I will have to later on create an
> switch case statement to retrieve the different types of data. Or is
> that even needed, since any number can become a char */[], and I can
> cast it back to a number from there?

Yes, the server+API tries to cast the data as you request and if it can't
returns an error.