本文整理汇总了C++中IAttachment::openCursor方法的典型用法代码示例。如果您正苦于以下问题:C++ IAttachment::openCursor方法的具体用法?C++ IAttachment::openCursor怎么用?C++ IAttachment::openCursor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAttachment
的用法示例。
在下文中一共展示了IAttachment::openCursor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
int rc = 0;
setenv("ISC_USER", "sysdba", 0);
setenv("ISC_PASSWORD", "masterkey", 0);
ThrowStatusWrapper status(master->getStatus());
IProvider* prov = master->getDispatcher();
IAttachment* att = NULL;
ITransaction* tra = NULL;
IResultSet* rs = NULL;
const char* dbName = "employee";
try
{
att = prov->attachDatabase(&status, dbName, 0, NULL);
tra = att->startTransaction(&status, 0, NULL);
// Comment some tables
att->execute(&status, tra, 0, "comment on table employee is 'Employees'",
SAMPLES_DIALECT, NULL, NULL, NULL, NULL);
att->execute(&status, tra, 0, "comment on table customer is 'Customers'",
SAMPLES_DIALECT, NULL, NULL, NULL, NULL);
att->execute(&status, tra, 0, "comment on table country is 'Countries and national currencies'",
SAMPLES_DIALECT, NULL, NULL, NULL, NULL);
tra->commitRetaining(&status);
// Print tables list
FB_MESSAGE(Input, ThrowStatusWrapper,
(FB_INTEGER, systemFlag)
) input(&status, master);
FB_MESSAGE(Output, ThrowStatusWrapper,
(FB_SMALLINT, relationId)
(FB_VARCHAR(31), relationName)
(FB_VARCHAR(100), description)
) output(&status, master);
input.clear();
input->systemFlag = 0;
rs = att->openCursor(&status, tra, 0,
"select rdb$relation_id, rdb$relation_name, rdb$description"
" from rdb$relations"
" where rdb$system_flag = ?"
" order by rdb$relation_id",
SAMPLES_DIALECT, input.getMetadata(), input.getData(), output.getMetadata(), NULL, 0);
printf(" ID Name/comment\n");
while (rs->fetchNext(&status, output.getData()) == IStatus::RESULT_OK)
{
unsigned lRelName = output->relationNameNull ? 0 : output->relationName.length;
unsigned lDesc = output->descriptionNull ? 0 : output->description.length;
printf("%4d %*.*s%c%*.*s\n", output->relationId,
lRelName, lRelName, output->relationName.str,
lDesc ? '/' : ' ',
lDesc, lDesc, output->description.str);
}
rs->close(&status);
rs = NULL;
tra->commit(&status);
tra = NULL;
att->detach(&status);
att = NULL;
}
catch (const FbException& error)
{
// handle error
rc = 1;
char buf[256];
master->getUtilInterface()->formatStatus(buf, sizeof(buf), error.getStatus());
fprintf(stderr, "%s\n", buf);
}
// release interfaces after error caught
if (rs)
rs->release();
if (tra)
tra->release();
if (att)
att->release();
// generic cleanup
prov->release();
status.dispose();
}