本文整理汇总了C++中IBS::Self方法的典型用法代码示例。如果您正苦于以下问题:C++ IBS::Self方法的具体用法?C++ IBS::Self怎么用?C++ IBS::Self使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBS
的用法示例。
在下文中一共展示了IBS::Self方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
void StatementImpl::Execute(const std::string& sql)
{
if (! sql.empty()) Prepare(sql);
if (mHandle == 0)
throw LogicExceptionImpl("Statement::Execute",
_("No statement has been prepared."));
// Check that a value has been set for each input parameter
if (mInRow != 0 && mInRow->MissingValues())
throw LogicExceptionImpl("Statement::Execute",
_("All parameters must be specified."));
CursorFree(); // Free a previous 'cursor' if any
IBS status;
if (mType == IBPP::stSelect)
{
// Could return a result set (none, single or multi rows)
(*gds.Call()->m_dsql_execute)(status.Self(), mTransaction->GetHandlePtr(),
&mHandle, 1, mInRow == 0 ? 0 : mInRow->Self());
if (status.Errors())
{
//Close(); Commented because Execute error should not free the statement
std::string context = "Statement::Execute( ";
context.append(mSql).append(" )");
throw SQLExceptionImpl(status, context.c_str(),
_("isc_dsql_execute failed"));
}
if (mOutRow != 0)
{
mResultSetAvailable = true;
mCursorOpened = true;
}
}
else
{
// Should return at most a single row
(*gds.Call()->m_dsql_execute2)(status.Self(), mTransaction->GetHandlePtr(),
&mHandle, 1, mInRow == 0 ? 0 : mInRow->Self(),
mOutRow == 0 ? 0 : mOutRow->Self());
if (status.Errors())
{
//Close(); Commented because Execute error should not free the statement
std::string context = "Statement::Execute( ";
context.append(mSql).append(" )");
throw SQLExceptionImpl(status, context.c_str(),
_("isc_dsql_execute2 failed"));
}
}
}
示例2: Fetch
bool StatementImpl::Fetch(IBPP::Row& row)
{
if (! mResultSetAvailable)
throw LogicExceptionImpl("Statement::Fetch(row)",
_("No statement has been executed or no result set available."));
RowImpl* rowimpl = new RowImpl(*mOutRow);
row = rowimpl;
IBS status;
int code = (*gds.Call()->m_dsql_fetch)(status.Self(), &mHandle, 1,
rowimpl->Self());
if (code == 100) // This special code means "no more rows"
{
mResultSetAvailable = false;
// Oddly enough, fetching rows up to the last one seems to open
// an 'implicit' cursor that needs to be closed.
mCursorOpened = true;
CursorFree(); // Free the explicit or implicit cursor/result-set
row.clear();
return false;
}
if (status.Errors())
{
Close();
row.clear();
throw SQLExceptionImpl(status, "Statement::Fetch(row)",
_("isc_dsql_fetch failed."));
}
return true;
}
示例3: Cancel
void EventsImpl::Cancel()
{
if (mQueued)
{
if (mDatabase->GetHandle() == 0) throw LogicExceptionImpl("EventsImpl::Cancel",
_("Database is not connected"));
IBS vector;
// A call to cancel_events will call *once* the handler routine, even
// though no events had fired. This is why we first set mEventsQueued
// to false, so that we can be sure to dismiss those unwanted callbacks
// subsequent to the execution of isc_cancel_events().
mTrapped = false;
mQueued = false;
(*gds.Call()->m_cancel_events)(vector.Self(), mDatabase->GetHandlePtr(), &mId);
if (vector.Errors())
{
mQueued = true; // Need to restore this as cancel failed
throw SQLExceptionImpl(vector, "EventsImpl::Cancel",
_("isc_cancel_events failed"));
}
mId = 0; // Should be, but better be safe
}
}
示例4: StartRestore
void ServiceImpl::StartRestore(const std::string& bkfile, const std::string& dbfile,
int pagesize, IBPP::BRF flags)
{
if (mHandle == 0)
throw LogicExceptionImpl("Service::Restore", _("Service is not connected."));
if (bkfile.empty())
throw LogicExceptionImpl("Service::Restore", _("Backup file must be specified."));
if (dbfile.empty())
throw LogicExceptionImpl("Service::Restore", _("Main database file must be specified."));
IBS status;
SPB spb;
spb.Insert(isc_action_svc_restore);
spb.InsertString(isc_spb_bkp_file, 2, bkfile.c_str());
spb.InsertString(isc_spb_dbname, 2, dbfile.c_str());
if (flags & IBPP::brVerbose) spb.Insert(isc_spb_verbose);
if (pagesize != 0) spb.InsertQuad(isc_spb_res_page_size, pagesize);
unsigned int mask;
if (flags & IBPP::brReplace) mask = isc_spb_res_replace;
else mask = isc_spb_res_create; // Safe default mode
if (flags & IBPP::brDeactivateIdx) mask |= isc_spb_res_deactivate_idx;
if (flags & IBPP::brNoShadow) mask |= isc_spb_res_no_shadow;
if (flags & IBPP::brNoValidity) mask |= isc_spb_res_no_validity;
if (flags & IBPP::brPerTableCommit) mask |= isc_spb_res_one_at_a_time;
if (flags & IBPP::brUseAllSpace) mask |= isc_spb_res_use_all_space;
if (mask != 0) spb.InsertQuad(isc_spb_options, mask);
(*gds.Call()->m_service_start)(status.Self(), &mHandle, 0, spb.Size(), spb.Self());
if (status.Errors())
throw SQLExceptionImpl(status, "Service::Restore", _("isc_service_start failed"));
}
示例5: StartBackup
void ServiceImpl::StartBackup(const std::string& dbfile,
const std::string& bkfile, IBPP::BRF flags)
{
if (mHandle == 0)
throw LogicExceptionImpl("Service::Backup", _("Service is not connected."));
if (dbfile.empty())
throw LogicExceptionImpl("Service::Backup", _("Main database file must be specified."));
if (bkfile.empty())
throw LogicExceptionImpl("Service::Backup", _("Backup file must be specified."));
IBS status;
SPB spb;
spb.Insert(isc_action_svc_backup);
spb.InsertString(isc_spb_dbname, 2, dbfile.c_str());
spb.InsertString(isc_spb_bkp_file, 2, bkfile.c_str());
if (flags & IBPP::brVerbose) spb.Insert(isc_spb_verbose);
unsigned int mask = 0;
if (flags & IBPP::brIgnoreChecksums) mask |= isc_spb_bkp_ignore_checksums;
if (flags & IBPP::brIgnoreLimbo) mask |= isc_spb_bkp_ignore_limbo;
if (flags & IBPP::brMetadataOnly) mask |= isc_spb_bkp_metadata_only;
if (flags & IBPP::brNoGarbageCollect) mask |= isc_spb_bkp_no_garbage_collect;
if (flags & IBPP::brNonTransportable) mask |= isc_spb_bkp_non_transportable;
if (flags & IBPP::brConvertExtTables) mask |= isc_spb_bkp_convert;
if (mask != 0) spb.InsertQuad(isc_spb_options, mask);
(*gds.Call()->m_service_start)(status.Self(), &mHandle, 0, spb.Size(), spb.Self());
if (status.Errors())
throw SQLExceptionImpl(status, "Service::Backup", _("isc_service_start failed"));
}
示例6: Repair
void ServiceImpl::Repair(const std::string& dbfile, IBPP::RPF flags)
{
if (mHandle == 0)
throw LogicExceptionImpl("Service::Repair", _("Service is not connected."));
if (dbfile.empty())
throw LogicExceptionImpl("Service::Repair", _("Main database file must be specified."));
IBS status;
SPB spb;
spb.Insert(isc_action_svc_repair);
spb.InsertString(isc_spb_dbname, 2, dbfile.c_str());
unsigned int mask;
if (flags & IBPP::rpValidateFull) mask = (isc_spb_rpr_full | isc_spb_rpr_validate_db);
else if (flags & IBPP::rpValidatePages) mask = isc_spb_rpr_validate_db;
else if (flags & IBPP::rpMendRecords) mask = isc_spb_rpr_mend_db;
else throw LogicExceptionImpl("Service::Repair",
_("One of rpMendRecords, rpValidatePages, rpValidateFull is required."));
if (flags & IBPP::rpReadOnly) mask |= isc_spb_rpr_check_db;
if (flags & IBPP::rpIgnoreChecksums) mask |= isc_spb_rpr_ignore_checksum;
if (flags & IBPP::rpKillShadows) mask |= isc_spb_rpr_kill_shadows;
spb.InsertQuad(isc_spb_options, mask);
(*gds.Call()->m_service_start)(status.Self(), &mHandle, 0, spb.Size(), spb.Self());
if (status.Errors())
throw SQLExceptionImpl(status, "Service::Repair", _("isc_service_start failed"));
Wait();
}
示例7: AffectedRows
int StatementImpl::AffectedRows()
{
if (mHandle == 0)
throw LogicExceptionImpl("Statement::AffectedRows", _("No statement has been prepared."));
if (mDatabase == 0)
throw LogicExceptionImpl("Statement::AffectedRows", _("A Database must be attached."));
if (mDatabase->GetHandle() == 0)
throw LogicExceptionImpl("Statement::AffectedRows", _("Database must be connected."));
int count;
IBS status;
RB result;
char itemsReq[] = {isc_info_sql_records};
(*gds.Call()->m_dsql_sql_info)(status.Self(), &mHandle, 1, itemsReq,
result.Size(), result.Self());
if (status.Errors()) throw SQLExceptionImpl(status,
"Statement::AffectedRows", _("isc_dsql_sql_info failed."));
if (mType == IBPP::stInsert)
count = result.GetValue(isc_info_sql_records, isc_info_req_insert_count);
else if (mType == IBPP::stUpdate)
count = result.GetValue(isc_info_sql_records, isc_info_req_update_count);
else if (mType == IBPP::stDelete)
count = result.GetValue(isc_info_sql_records, isc_info_req_delete_count);
else if (mType == IBPP::stSelect)
count = result.GetValue(isc_info_sql_records, isc_info_req_select_count);
else count = 0; // Returns zero count for unknown cases
return count;
}
示例8: Wait
void ServiceImpl::Wait()
{
IBS status;
SPB spb;
RB result(1024);
std::string msg;
spb.Insert(isc_info_svc_line);
for (;;)
{
// Sleeps 1 millisecond upfront. This will release the remaining
// timeslot of the thread. Doing so will give a good chance for small
// services tasks to finish before we check if they are still running.
// The deal is to limit (in that particular case) the number of loops
// polling _service_query that will happen.
Sleep(1);
// _service_query will only block until a line of result is available
// (or until the end of the task if it does not report information)
(*gds.Call()->m_service_query)(status.Self(), &mHandle, 0, 0, 0,
spb.Size(), spb.Self(), result.Size(), result.Self());
if (status.Errors())
throw SQLExceptionImpl(status, "ServiceImpl::Wait", _("isc_service_query failed"));
// If message length is zero bytes, task is finished
if (result.GetString(isc_info_svc_line, msg) == 0) return;
status.Reset();
result.Reset();
}
}
示例9: ExecuteImmediate
void StatementImpl::ExecuteImmediate(const std::string& sql)
{
if (mDatabase == 0)
throw LogicExceptionImpl("Statement::ExecuteImmediate", _("An IDatabase must be attached."));
if (mDatabase->GetHandle() == 0)
throw LogicExceptionImpl("Statement::ExecuteImmediate", _("IDatabase must be connected."));
if (mTransaction == 0)
throw LogicExceptionImpl("Statement::ExecuteImmediate", _("An ITransaction must be attached."));
if (mTransaction->GetHandle() == 0)
throw LogicExceptionImpl("Statement::ExecuteImmediate", _("ITransaction must be started."));
if (sql.empty())
throw LogicExceptionImpl("Statement::ExecuteImmediate", _("SQL statement can't be 0."));
IBS status;
Close();
(*gds.Call()->m_dsql_execute_immediate)(status.Self(), mDatabase->GetHandlePtr(),
mTransaction->GetHandlePtr(), 0, const_cast<char*>(sql.c_str()),
short(mDatabase->Dialect()), 0);
if (status.Errors())
{
std::string context = "Statement::ExecuteImmediate( ";
context.append(sql).append(" )");
throw SQLExceptionImpl(status, context.c_str(),
_("isc_dsql_execute_immediate failed"));
}
}
示例10: Fetch
bool StatementImpl::Fetch()
{
if (! mResultSetAvailable)
throw LogicExceptionImpl("Statement::Fetch",
_("No statement has been executed or no result set available."));
IBS status;
ISC_STATUS code = (*gds.Call()->m_dsql_fetch)(status.Self(), &mHandle, 1, mOutRow->Self());
if (code == 100) // This special code means "no more rows"
{
mResultSetAvailable = false;
// Oddly enough, fetching rows up to the last one seems to open
// an 'implicit' cursor that needs to be closed.
mCursorOpened = true;
CursorFree(); // Free the explicit or implicit cursor/result-set
return false;
}
if (status.Errors())
{
Close();
throw SQLExceptionImpl(status, "Statement::Fetch",
_("isc_dsql_fetch failed."));
}
// Close the 'implicit' cursor to allow for forther Execute() calls
// on the prepared statement without fetching up to the last row
mCursorOpened = true;
return true;
}
示例11: Counts
void DatabaseImpl::Counts(int* Insert, int* Update, int* Delete,
int* ReadIdx, int* ReadSeq)
{
if (mHandle == 0)
throw LogicExceptionImpl("Database::Counts", _("Database is not connected."));
char items[] = {isc_info_insert_count,
isc_info_update_count,
isc_info_delete_count,
isc_info_read_idx_count,
isc_info_read_seq_count,
isc_info_end};
IBS status;
RB result(1024);
status.Reset();
(*gds.Call()->m_database_info)(status.Self(), &mHandle, sizeof(items), items,
result.Size(), result.Self());
if (status.Errors())
throw SQLExceptionImpl(status, "Database::Counts", _("isc_database_info failed"));
if (Insert != 0) *Insert = result.GetCountValue(isc_info_insert_count);
if (Update != 0) *Update = result.GetCountValue(isc_info_update_count);
if (Delete != 0) *Delete = result.GetCountValue(isc_info_delete_count);
if (ReadIdx != 0) *ReadIdx = result.GetCountValue(isc_info_read_idx_count);
if (ReadSeq != 0) *ReadSeq = result.GetCountValue(isc_info_read_seq_count);
}
示例12: Users
void DatabaseImpl::Users(std::vector<std::string>& users)
{
if (mHandle == 0)
throw LogicExceptionImpl("Database::Users", _("Database is not connected."));
char items[] = {isc_info_user_names,
isc_info_end};
IBS status;
RB result(8000);
status.Reset();
(*gds.Call()->m_database_info)(status.Self(), &mHandle, sizeof(items), items,
result.Size(), result.Self());
if (status.Errors())
{
status.Reset();
throw SQLExceptionImpl(status, "Database::Users", _("isc_database_info failed"));
}
users.clear();
char* p = result.Self();
while (*p == isc_info_user_names)
{
p += 3; // Get to the length byte (there are two undocumented bytes which we skip)
int len = (int)(*p);
++p; // Get to the first char of username
if (len != 0) users.push_back(std::string().append(p, len));
p += len; // Skip username
}
return;
}
示例13: Create
void DatabaseImpl::Create(int dialect)
{
if (mHandle != 0)
throw LogicExceptionImpl("Database::Create", _("Database is already connected."));
if (mDatabaseName.empty())
throw LogicExceptionImpl("Database::Create", _("Unspecified database name."));
if (mUserName.empty())
throw LogicExceptionImpl("Database::Create", _("Unspecified user name."));
if (dialect != 1 && dialect != 3)
throw LogicExceptionImpl("Database::Create", _("Only dialects 1 and 3 are supported."));
// Build the SQL Create Statement
std::string create;
create.assign("CREATE DATABASE '");
if (! mServerName.empty()) create.append(mServerName).append(":");
create.append(mDatabaseName).append("' ");
create.append("USER '").append(mUserName).append("' ");
if (! mUserPassword.empty())
create.append("PASSWORD '").append(mUserPassword).append("' ");
if (! mCreateParams.empty()) create.append(mCreateParams);
// Call ExecuteImmediate to create the database
isc_tr_handle tr_handle = 0;
IBS status;
(*gds.Call()->m_dsql_execute_immediate)(status.Self(), &mHandle, &tr_handle,
0, const_cast<char*>(create.c_str()), short(dialect), NULL);
if (status.Errors())
throw SQLExceptionImpl(status, "Database::Create", _("isc_dsql_execute_immediate failed"));
Disconnect();
}
示例14: ModifyUser
void ServiceImpl::ModifyUser(const IBPP::User& user)
{
if (mHandle == 0)
throw LogicExceptionImpl("Service::ModifyUser", _("Service is not connected."));
if (user.username.empty())
throw LogicExceptionImpl("Service::ModifyUser", _("Username required."));
IBS status;
SPB spb;
spb.Insert(isc_action_svc_modify_user);
spb.InsertString(isc_spb_sec_username, 2, user.username.c_str());
if (! user.password.empty())
spb.InsertString(isc_spb_sec_password, 2, user.password.c_str());
if (! user.firstname.empty())
spb.InsertString(isc_spb_sec_firstname, 2, user.firstname.c_str());
if (! user.middlename.empty())
spb.InsertString(isc_spb_sec_middlename, 2, user.middlename.c_str());
if (! user.lastname.empty())
spb.InsertString(isc_spb_sec_lastname, 2, user.lastname.c_str());
if (user.userid != 0)
spb.InsertQuad(isc_spb_sec_userid, (int32_t)user.userid);
if (user.groupid != 0)
spb.InsertQuad(isc_spb_sec_groupid, (int32_t)user.groupid);
(*gds.Call()->m_service_start)(status.Self(), &mHandle, 0, spb.Size(), spb.Self());
if (status.Errors())
throw SQLExceptionImpl(status, "Service::ModifyUser", _("isc_service_start failed"));
Wait();
}
示例15: Shutdown
void ServiceImpl::Shutdown(const std::string& dbfile, IBPP::DSM mode, int sectimeout)
{
if (mHandle == 0)
throw LogicExceptionImpl("Service::Shutdown", _("Service is not connected."));
if (dbfile.empty())
throw LogicExceptionImpl("Service::Shutdown", _("Main database file must be specified."));
IBS status;
SPB spb;
spb.Insert(isc_action_svc_properties);
spb.InsertString(isc_spb_dbname, 2, dbfile.c_str());
switch (mode)
{
case IBPP::dsDenyAttach :
spb.InsertQuad(isc_spb_prp_deny_new_attachments, sectimeout);
break;
case IBPP::dsDenyTrans :
spb.InsertQuad(isc_spb_prp_deny_new_transactions, sectimeout);
break;
case IBPP::dsForce :
spb.InsertQuad(isc_spb_prp_shutdown_db, sectimeout);
break;
}
(*gds.Call()->m_service_start)(status.Self(), &mHandle, 0, spb.Size(), spb.Self());
if (status.Errors())
throw SQLExceptionImpl(status, "Service::Shutdown", _("isc_service_start failed"));
Wait();
}