SQLRelay
Posted: Fri May 14, 2021 1:53 pm
I have started playing with SQLRelay.
And there is something that I cannot get to work.
That could of course just be because of a bug in the code I have written, but the code seems to work on Windows.
Code fragment:
/* prepare */
sprintf(sqlstr, "INSERT INTO t1 VALUES(%s, %s)", placeholder("1", "f1", "int"), placeholder("2", "f2", "text"));
sqlrcur_prepareQuery(curs, sqlstr);
/* bind parameters */
sqlrcur_inputBindLong(curs, bindname("1", "f1"), f1);
sqlrcur_inputBindString(curs, bindname("2", "f2"), f2);
/* execute */
stat = sqlrcur_executeQuery(curs);
if(!stat) curs_exit(curs);
n = sqlrcur_affectedRows(curs);
The INSERT get executed fine.
But the values inserted are not the expected 999 and 'XXX' but -2147483648 and 'XXX'.
Somehow the integer value does not get in correct.
The declaration of sqlrcur_inputBindLong seems to match:
/** @ingroup sqlrclientwrapper
* Defines a integer input bind variable. */
SQLRCLIENT_DLLSPEC
void sqlrcur_inputBindLong(sqlrcur sqlrcurref, const char *variable,
int64_t value);
Do not get confused by the placeholder and bindname functions.
/* standard (ODBC, DB2, MySQL) */
static char *std_ph(char *num, char *nam, char *typ)
{
return "?";
}
static char *std_bn(char *num, char *nam)
{
return num;
}
should be fine with the database tested (MySQL) and besides if they were wrong then I would get an error.
Any ideas?
And there is something that I cannot get to work.
That could of course just be because of a bug in the code I have written, but the code seems to work on Windows.
Code fragment:
/* prepare */
sprintf(sqlstr, "INSERT INTO t1 VALUES(%s, %s)", placeholder("1", "f1", "int"), placeholder("2", "f2", "text"));
sqlrcur_prepareQuery(curs, sqlstr);
/* bind parameters */
sqlrcur_inputBindLong(curs, bindname("1", "f1"), f1);
sqlrcur_inputBindString(curs, bindname("2", "f2"), f2);
/* execute */
stat = sqlrcur_executeQuery(curs);
if(!stat) curs_exit(curs);
n = sqlrcur_affectedRows(curs);
The INSERT get executed fine.
But the values inserted are not the expected 999 and 'XXX' but -2147483648 and 'XXX'.
Somehow the integer value does not get in correct.
The declaration of sqlrcur_inputBindLong seems to match:
/** @ingroup sqlrclientwrapper
* Defines a integer input bind variable. */
SQLRCLIENT_DLLSPEC
void sqlrcur_inputBindLong(sqlrcur sqlrcurref, const char *variable,
int64_t value);
Do not get confused by the placeholder and bindname functions.
/* standard (ODBC, DB2, MySQL) */
static char *std_ph(char *num, char *nam, char *typ)
{
return "?";
}
static char *std_bn(char *num, char *nam)
{
return num;
}
should be fine with the database tested (MySQL) and besides if they were wrong then I would get an error.
Any ideas?