1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| UnicodeString name, dateStart, dateFinish;
jint channelType, channelFolderID, businessHourFrom, businessHourTo, nbObjLimit, totalSizeLimit, dateFrequence;
jbyte businessHourTimeZoneOffset;
jboolean nature, active;
data_in >> channelType >> nature >> name >> channelFolderID >> businessHourTimeZoneOffset >> businessHourFrom
>> businessHourTo >> active >> nbObjLimit >> totalSizeLimit >> dateStart >> dateFinish >> dateFrequence;
int result = 0;
try {
begin_transaction();
// CREDENTIAL INSERTION
int idCredential = new_channelCredential(channelType, data_in);
if (idCredential == -1)
{
rollback_transaction();
return -1;
}
// CHANNEL INSERTION
auto_ptr<odbc::PreparedStatement> cipstmt(con->prepareStatement(("INSERT INTO Channel (name, idCredential, idChannelFolder, type_, nature, businessHourTimeZoneOffset, businessHourFrom, businessHourTo, active, nbObjLimit, totalSizeLimit, dateStart, dateFinish, dateFrequence) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")));
cipstmt->setString(1, strToUTF8(name));
cipstmt->setInt(2, idCredential);
cipstmt->setInt(3, channelFolderID);
cipstmt->setInt(4, channelType);
cipstmt->setBoolean(5, nature);
cipstmt->setByte(6, businessHourTimeZoneOffset);
cipstmt->setInt(7, businessHourFrom);
cipstmt->setInt(8, businessHourTo);
cipstmt->setBoolean(9, active);
cipstmt->setInt(10, nbObjLimit);
cipstmt->setInt(11, totalSizeLimit);
cipstmt->setString(12, strToUTF8(dateStart));
cipstmt->setString(13, strToUTF8(dateFinish));
cipstmt->setInt(14, dateFrequence);
cipstmt->executeUpdate();
{ // last inserted id
auto_ptr<odbc::PreparedStatement> ps(con->prepareStatement("SELECT idChannel FROM Channel ORDER BY idChannel DESC"));
auto_ptr<odbc::ResultSet> rs(ps->executeQuery());
if (rs->next()) {
result = rs->getInt(1);
}
}
cipstmt->close();
commit_transaction();
} catch (const odbc::SQLException& e) {
rollback_transaction();
ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("-%D Monitor: DataSource exception: %s\n"), ODBCXX_STRING_CSTR(e.getMessage())), -1);
} |