本文整理汇总了C++中IBS类的典型用法代码示例。如果您正苦于以下问题:C++ IBS类的具体用法?C++ IBS怎么用?C++ IBS使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IBS类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LogicExceptionImpl
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;
}
示例2: _
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
}
}
示例3: LogicExceptionImpl
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();
}
示例4: LogicExceptionImpl
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();
}
示例5: LogicExceptionImpl
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;
}
示例6: 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();
}
}
示例7: LogicExceptionImpl
void TransactionImpl::RollbackRetain()
{
if (mHandle == 0)
throw LogicExceptionImpl("Transaction::RollbackRetain", _("Transaction is not started."));
IBS status;
(*gds.Call()->m_rollback_retaining)(status.Self(), &mHandle);
if (status.Errors())
throw SQLExceptionImpl(status, "Transaction::RollbackRetain");
}
示例8: Rollback
void TransactionImpl::Rollback()
{
if (mHandle == 0) return; // Transaction not started anyway
IBS status;
(*gds.Call()->m_rollback_transaction)(status.Self(), &mHandle);
if (status.Errors())
throw SQLExceptionImpl(status, "Transaction::Rollback");
mHandle = 0; // Should be, better be sure
}
示例9: CursorFree
void StatementImpl::CursorFree()
{
if (mCursorOpened)
{
mCursorOpened = false;
if (mHandle != 0)
{
IBS status;
(*gds.Call()->m_dsql_free_statement)(status.Self(), &mHandle, DSQL_close);
if (status.Errors())
throw SQLExceptionImpl(status, "StatementImpl::CursorFree(DSQL_close)",
_("isc_dsql_free_statement failed."));
}
}
}
示例10: Disconnect
void ServiceImpl::Disconnect()
{
if (mHandle == 0) return; // Already disconnected
IBS status;
// Detach from the service manager
(*gds.Call()->m_service_detach)(status.Self(), &mHandle);
// Set mHandle to 0 now, just in case we need to throw, because Disconnect()
// is called from Service destructor and we want to maintain a coherent state.
mHandle = 0;
if (status.Errors())
throw SQLExceptionImpl(status, "Service::Disconnect", _("isc_service_detach failed"));
}
示例11: Rollback
void TransactionImpl::Rollback()
{
if (mHandle == 0) return; // Transaction not started anyway
IBS status;
(*gds.Call()->m_rollback_transaction)(status.Self(), &mHandle);
if (status.Errors())
throw SQLExceptionImpl(status, "Transaction::Rollback");
mHandle = 0; // Should be, better be sure
/*
size_t i;
for (i = mStatements.size(); i != 0; i--)
mStatements[i-1]->CursorFree();
*/
}
示例12: Inactivate
void DatabaseImpl::Disconnect()
{
if (mHandle == 0) return; // Not connected anyway
// Put the connection to rest
Inactivate();
// Detach from the server
IBS status;
(*gds.Call()->m_detach_database)(status.Self(), &mHandle);
// Should we throw, set mHandle to 0 first, because Disconnect() may
// be called from Database destructor (keeps the object coherent).
mHandle = 0;
if (status.Errors())
throw SQLExceptionImpl(status, "Database::Disconnect", _("isc_detach_database failed"));
}
示例13: LogicExceptionImpl
void TransactionImpl::Commit()
{
if (mHandle == 0)
throw LogicExceptionImpl("Transaction::Commit", _("Transaction is not started."));
IBS status;
(*gds.Call()->m_commit_transaction)(status.Self(), &mHandle);
if (status.Errors())
throw SQLExceptionImpl(status, "Transaction::Commit");
mHandle = 0; // Should be, better be sure
/*
size_t i;
for (i = mStatements.size(); i != 0; i--)
mStatements[i-1]->CursorFree();
*/
}
示例14: WaitMsg
const char* ServiceImpl::WaitMsg()
{
IBS status;
SPB req;
RB result(1024);
req.Insert(isc_info_svc_line); // Request one line of textual output
// _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,
req.Size(), req.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, mWaitMessage) == 0) return 0;
// Task is not finished, but we have something to report
return mWaitMessage.c_str();
}