#include "ocilib.h"

#define INSERT_SQL_00    MT("INSERT INTO C_PICRECORD_00 (ID, DEV_ID) VALUES (:id, :devid)")
#define CHECK_SUCCESS(ret, x, err, clear) ret = x;if(ret < 1){GET_LAST_ERROR(err);goto clear;} int CFLOracleOCIVisitor::insertVehRecords(DB_Write_info_t** dbInfo, int count)
{
if(isConnected() != )
return -; int nRet = ;
std::string strTmp;
OCI_Statement* stm = OCI_StatementCreate( m_conn);
if(NULL == stm)
{
m_Error = OCI_GetLastError();
return -;
}
uint32* tab_id = new uint32[count];
memset(tab_id, , count);
char* tab_devid = new char[count*];
memset(tab_devid, , count*);
//Prepare
CHECK_SUCCESS(nRet, OCI_Prepare(stm, INSERT_SQL_00), m_Error, clear);
// binding
CHECK_SUCCESS(nRet, OCI_BindArraySetSize(stm, count), m_Error, clear);
OCI_BindArrayOfUnsignedInts(stm, ":id", (uint32*)tab_id, );
OCI_BindArrayOfStrings(stm, ":devid", (char*)tab_devid, , );
for(int i = ; i < count; i++)
{
tab_id[i] = dbInfo[i]->dbId;
memcpy(tab_devid+i*, dbInfo[i]->devId, );
}
//execute
CHECK_SUCCESS(nRet, OCI_Execute(stm), m_Error, clear);
CHECK_SUCCESS(nRet, OCI_Commit(m_conn), m_Error, clear); clear:
OCI_StatementFree(stm); delete[] tab_id;
delete[] tab_devid;
return nRet;
}
05-01 02:45