AndyFutureRoute
Programmer
Hello
I am trying to run a stored procedure that takes in a string and returns an INT, i know the procedure works, but i am now trying o call the procedure from C++. The problem being is that i cannot seem to get the returned int! this is the code i have so far, i'm guessing its wrong, but i'm not sure where:
bool CharacterSinkODBC:
utNextCharacter(char *characterstring){
int temp = 0;
SQLAllocHandle( SQL_HANDLE_STMT, hDbc ,&hStmt);
SQLINTEGER mylen = strlen(characterstring);
SQLBindParameter(hStmt, //StatementHandle
1, //ParameterNumber
SQL_PARAM_OUTPUT, //InputOutputType
SQL_C_ULONG, //ValueType INput
SQL_INTEGER, //ParameterType Actual Table Type
0, //ColumnSize
0, //DecimalDigits
&temp, //ParameterValuePtr
0, //BufferLength
sizeof(int)); //StrLen_or_IndPtr
SQLBindParameter(hStmt, //StatementHandle
1, //ParameterNumber
SQL_PARAM_INPUT, //InputOutputType
SQL_C_CHAR, //ValueType INput
SQL_VARCHAR, //ParameterType Actual Table Type
4000, //ColumnSize
0, //DecimalDigits
(SQLCHAR *)characterstring, //ParameterValuePtr
4000, //BufferLength
&mylen); //StrLen_or_IndPtr
ret = SQLExecDirect(hStmt,
(SQLCHAR*) "{CALL insertPrototypeCharacter(?)}",
SQL_NTS );
if(!SQL_SUCCEEDED(this->ret)){
SQLError(this->ret);
return false;
}
else{
norecordsinserted++;
SQLFreeHandle( SQL_HANDLE_STMT, hStmt );
return true;
}
}
I've attached the file, which might be more help than the pasted code!
I just need to konw if i've bound the parameters properly and if so, how o i extract the result...
Cheers
Andy
I am trying to run a stored procedure that takes in a string and returns an INT, i know the procedure works, but i am now trying o call the procedure from C++. The problem being is that i cannot seem to get the returned int! this is the code i have so far, i'm guessing its wrong, but i'm not sure where:
bool CharacterSinkODBC:
int temp = 0;
SQLAllocHandle( SQL_HANDLE_STMT, hDbc ,&hStmt);
SQLINTEGER mylen = strlen(characterstring);
SQLBindParameter(hStmt, //StatementHandle
1, //ParameterNumber
SQL_PARAM_OUTPUT, //InputOutputType
SQL_C_ULONG, //ValueType INput
SQL_INTEGER, //ParameterType Actual Table Type
0, //ColumnSize
0, //DecimalDigits
&temp, //ParameterValuePtr
0, //BufferLength
sizeof(int)); //StrLen_or_IndPtr
SQLBindParameter(hStmt, //StatementHandle
1, //ParameterNumber
SQL_PARAM_INPUT, //InputOutputType
SQL_C_CHAR, //ValueType INput
SQL_VARCHAR, //ParameterType Actual Table Type
4000, //ColumnSize
0, //DecimalDigits
(SQLCHAR *)characterstring, //ParameterValuePtr
4000, //BufferLength
&mylen); //StrLen_or_IndPtr
ret = SQLExecDirect(hStmt,
(SQLCHAR*) "{CALL insertPrototypeCharacter(?)}",
SQL_NTS );
if(!SQL_SUCCEEDED(this->ret)){
SQLError(this->ret);
return false;
}
else{
norecordsinserted++;
SQLFreeHandle( SQL_HANDLE_STMT, hStmt );
return true;
}
}
I've attached the file, which might be more help than the pasted code!
I just need to konw if i've bound the parameters properly and if so, how o i extract the result...
Cheers
Andy