Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions source/db2ExecuteInsert.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,50 +69,53 @@ int db2ExecuteInsert (DB2Session* session, const DB2Table* db2Table, ParamDesc*
switch (db2Table->cols[param->colnum]->colType){
case SQL_BIGINT:{
char* end = NULL;
SQLBIGINT sqlbint = strtoll(param->value,&end,10);
db2Debug2(" sqlbint: %d",sqlbint);
SQLBIGINT* sqlbint = db2alloc("SQLBIGINT",sizeof(SQLBIGINT));
*sqlbint = strtoll(param->value,&end,10);
db2Debug2(" sqlbint: %d",*sqlbint);
rc = SQLBindParameter( session->stmtp->hsql
, param_count
, SQL_PARAM_INPUT
, SQL_C_SBIGINT
, db2Table->cols[param->colnum]->colType
, 0
, 0
, &sqlbint
, sqlbint
, 0
, &indicators[param_count]
);
}
break;
case SQL_SMALLINT:{
char* end = NULL;
SQLSMALLINT sqlint = strtol(param->value,&end,10);
db2Debug2(" sqlint: %d",sqlint);
SQLSMALLINT* sqlsint = db2alloc("SQLSMALLINT",sizeof(SQLSMALLINT));
*sqlsint = strtol(param->value,&end,10);
db2Debug2(" sqlsint: %d",*sqlsint);
rc = SQLBindParameter( session->stmtp->hsql
, param->colnum+1
, SQL_PARAM_INPUT
, SQL_C_SSHORT
, db2Table->cols[param->colnum]->colType
, 0
, 0
, &sqlint
, sqlsint
, 0
, &indicators[param_count]
);
}
break;
case SQL_INTEGER: {
char* end = NULL;
SQLINTEGER sqlint = strtol(param->value,&end,10);
db2Debug2(" sqlint: %d",sqlint);
SQLINTEGER* sqlint = db2alloc("SQLINTEGER",sizeof(SQLINTEGER));
*sqlint = strtol(param->value,&end,10);
db2Debug2(" sqlint: %d",*sqlint);
rc = SQLBindParameter( session->stmtp->hsql
, param->colnum+1
, SQL_PARAM_INPUT
, SQL_C_SLONG
, db2Table->cols[param->colnum]->colType
, 0
, 0
, &sqlint
, sqlint
, 0
, &indicators[param_count]
);
Expand All @@ -124,18 +127,18 @@ int db2ExecuteInsert (DB2Session* session, const DB2Table* db2Table, ParamDesc*
case SQL_REAL:
case SQL_DOUBLE:
case SQL_DECFLOAT: {
SQL_NUMERIC_STRUCT num = {0};
parse2num_struct(param->value, &num);
db2Debug2(" num: '%s'",num);
SQL_NUMERIC_STRUCT* num = db2alloc("SQL_NUMERIC_STRUCT",sizeof(SQL_NUMERIC_STRUCT));
parse2num_struct(param->value, num);
db2Debug2(" num: '%s'",*num);
rc = SQLBindParameter( session->stmtp->hsql
, param->colnum+1
, SQL_PARAM_INPUT
, SQL_C_NUMERIC
, db2Table->cols[param->colnum]->colType
, num.precision
, num.scale
, &num
, sizeof(num)
, num->precision
, num->scale
, num
, sizeof(*num)
, &indicators[param_count]
);
}
Expand Down
33 changes: 18 additions & 15 deletions source/db2ExecuteQuery.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,50 +74,53 @@ int db2ExecuteQuery (DB2Session* session, const DB2Table* db2Table, ParamDesc* p
switch (colType){
case SQL_BIGINT:{
char* end = NULL;
SQLBIGINT sqlbint = strtoll(param->value,&end,10);
db2Debug2(" sqlbint: %d",sqlbint);
SQLBIGINT* sqlbint = db2alloc("SQLBIGINT",sizeof(SQLBIGINT));
*sqlbint = strtoll(param->value,&end,10);
db2Debug2(" sqlbint: %d",*sqlbint);
rc = SQLBindParameter( session->stmtp->hsql
, param_count
, SQL_PARAM_INPUT
, SQL_C_SBIGINT
, colType
, 0
, 0
, &sqlbint
, sqlbint
, 0
, &indicators[param_count]
);
}
break;
case SQL_SMALLINT:{
char* end = NULL;
SQLSMALLINT sqlint = strtol(param->value,&end,10);
db2Debug2(" sqlint: %d",sqlint);
SQLSMALLINT* sqlsint = db2alloc("SQLSMALLINT",sizeof(SQLSMALLINT));
*sqlsint = strtol(param->value,&end,10);
db2Debug2(" sqlsint: %d",*sqlsint);
rc = SQLBindParameter( session->stmtp->hsql
, param_count
, SQL_PARAM_INPUT
, SQL_C_SSHORT
, colType
, 0
, 0
, &sqlint
, sqlsint
, 0
, &indicators[param_count]
);
}
break;
case SQL_INTEGER: {
char* end = NULL;
SQLINTEGER sqlint = strtol(param->value,&end,10);
db2Debug2(" sqlint: %d",sqlint);
SQLINTEGER* sqlint = db2alloc("SQLINTEGER",sizeof(SQLINTEGER));
*sqlint = strtol(param->value,&end,10);
db2Debug2(" sqlint: %d",*sqlint);
rc = SQLBindParameter( session->stmtp->hsql
, param_count
, SQL_PARAM_INPUT
, SQL_C_SLONG
, colType
, 0
, 0
, &sqlint
, sqlint
, 0
, &indicators[param_count]
);
Expand All @@ -129,17 +132,17 @@ int db2ExecuteQuery (DB2Session* session, const DB2Table* db2Table, ParamDesc* p
case SQL_REAL:
case SQL_DOUBLE:
case SQL_DECFLOAT: {
SQL_NUMERIC_STRUCT num = {0};
parse2num_struct(param->value, &num);
db2Debug2(" num: '%s'",num);
SQL_NUMERIC_STRUCT* num = db2alloc("SQL_NUMERIC_STRUCT",sizeof(SQL_NUMERIC_STRUCT));
parse2num_struct(param->value, num);
db2Debug2(" num: '%s'",*num);
rc = SQLBindParameter( session->stmtp->hsql
, param_count
, SQL_PARAM_INPUT
, SQL_C_NUMERIC
, colType
, num.precision
, num.scale
, &num
, num->precision
, num->scale
, num
, sizeof(num)
, &indicators[param_count]
);
Expand Down
Loading