Subject API problem with SQL_LONG
Author burmair
Yes, I'm new at this, so I've probably made a silly mistake. If you
would point it out for me, I'd be very grateful.

Starting with some of the C api examples, I've modified them to
explore various FB features. I create a database, then a table.
Using XSQLDA, I insert a row, then retrieve the row. I've run into a
problem with what should be a very simple operation using SQL_LONG.
Here are (I think) the relevant lines from my program:

static char* create_tbl = "CREATE TABLE dbinfo (when_created

static char* insert_data = "INSERT INTO dbinfo (when_created, name,
age, stuff) VALUES (?, ?, ?, ?)";

#if 0
// This WORKS
float age = 99.0;
in_sqlda->sqlvar[2].sqldata = (char *)&age;
in_sqlda->sqlvar[2].sqllen = sizeof(float);
in_sqlda->sqlvar[2].sqltype = SQL_FLOAT;
in_sqlda->sqlvar[2].sqlind = &flag2;
// This does NOT work
long age = 99;
in_sqlda->sqlvar[2].sqldata = (char *)&age;
in_sqlda->sqlvar[2].sqllen = sizeof(long);
in_sqlda->sqlvar[2].sqltype = SQL_LONG;
in_sqlda->sqlvar[2].sqlind = &flag2;

The columns "when_created", "name", and "stuff" are all written and
read back correctly. For the "age" column, if I start with a float
(or double or even text), the value 99 is coerced, and written and
read back correctly. However, if I start with a long, the value
becomes 0 when read back from the DB.

I've used IBExpert (handy tool!) to examine the DB directly to verify
that the DB contains what I expect. The value 99 doesn't get stored
if I send it in as a SQL_LONG, but it does if I send it in as a SQL_FLOAT.

I'm using the 2.0.1 embedded server.

What have I done wrong??