|
-
Dec 20th, 2002, 11:05 AM
#1
Thread Starter
Addicted Member
C++ and Embeded SQL
Hello, i have a function that should insert a record into a database, this is called 10,000 in a row, and i have this code:
Code:
/**
*putNextCharacterandPostcode(unsigned char *characterstring, char *postcode, int length)
*@param unsigned char *characterstring
*@param *postcode
*@param int length
*@return bool
*Puts a character in the sink.
*Uses length param to determine the length of the binary input that it will recieve.
*Inserts Character and references it by a postcode.
*returns true if successful and false if not.
*/
bool CharacterSinkODBC::putNextCharacterandPostcode(unsigned char *characterstring, char *postcode, int length){
int temp = 0;
SQLINTEGER len = length;
SQLAllocHandle( SQL_HANDLE_STMT, this->hDbc ,&this->hStmt);
//OUTPUT
SQLBindParameter(this->hStmt, //StatementHandle
1, //ParameterNumber
SQL_PARAM_OUTPUT, //InputOutputType
SQL_INTEGER, //ValueType INput
SQL_INTEGER, //ParameterType Actual Table Type
0, //ColumnSize
0, //DecimalDigits
&temp, //ParameterValuePtr
sizeof(temp), //BufferLength
NULL); //StrLen_or_IndPtr
//CHARACTERSTRING
SQLBindParameter(this->hStmt, //StatementHandle
2, //ParameterNumber
SQL_PARAM_INPUT, //InputOutputType
SQL_C_BINARY, //ValueType Input
SQL_BINARY, //ParameterType Actual Table Type
1000, //ColumnSize
0, //DecimalDigits
characterstring, //ParameterValuePtr
len, //BufferLength
&len);
//POSTCODE STRING
SQLBindParameter(this->hStmt, //StatementHandle
3, //ParameterNumber
SQL_PARAM_INPUT, //InputOutputType
SQL_C_CHAR, //ValueType Input
SQL_VARCHAR, //ParameterType Actual Table Type
10, //ColumnSize
0, //DecimalDigits
(SQLCHAR *)postcode, //ParameterValuePtr
sizeof(postcode), //BufferLength
NULL); //StrLen_or_IndPtr
ret = SQLExecDirect(this->hStmt,
(SQLCHAR*) "{? = CALL [sp_insertPrototypeCharacterandPostcode](?,?)}",
SQL_NTS );
SQLFreeHandle( SQL_HANDLE_STMT, this->hStmt );
if(!SQL_SUCCEEDED(this->ret)){
this->SQLError(this->ret);
return false;
}
else{
this->rowNum.push_back(temp);
this->norecordsinserted++;
return true;
}
}
I was wondering if i was making any huge mistakes in this that would cause a performance problem etc...
Andy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|