Subject | Re: [ib-support] API XSQLVAR struct ? |
---|---|
Author | Raul Chirea |
Post date | 2002-07-24T03:33:34Z |
Hi William,
""William L. Thomson Jr."" <support@...> wrote in message
"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
*/
to be "void *" !
returns an error.
Raul.
""William L. Thomson Jr."" <support@...> wrote in message
> Ok, let me see if I can make my question easier.It depends of "osqlda->sqlvar[i].sqltype" you use for that field.
> What type of var array should I create so I can get the output out of
>
> osqlda->sqlvar[i].sqldata = // <- Here
"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 toYes, the server+API tries to cast the data as you request and if it can't
> 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?
returns an error.
Raul.