Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return Value from a stored procedure, C++

Status
Not open for further replies.

AndyFutureRoute

Programmer
Dec 5, 2002
7
0
0
GB
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::putNextCharacter(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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top