標準APIを使ったサンプル
#include <stdio.h>
#include <bzs/db/protocol/tdap/client/database.h>
#include <bzs/db/protocol/tdap/client/table.h>
#include <bzs/db/protocol/tdap/client/dbDef.h>
using namespace bzs::db::protocol::tdap::client;
using namespace bzs::db::protocol::tdap;
static const short fieldnum_id = 0;
static const short fieldnum_name = 1;
static const short fieldnum_group = 2;
static const short fieldnum_tel = 3;
static const char_td keynum_group = 1;
void showError(const _TCHAR* caption, const _TCHAR* tableName, short statusCode)
{
_TCHAR tmp[1024] = { 0x00 };
_tprintf(_T("[ERROR] %s No.%ld %s\n"), caption, statusCode, tmp);
}
bool updateUsers(
table* tb)
{
tb->
setFV(fieldnum_group, 1);
{
break;
tb->
setFV(fieldnum_group, 3);
else
}
return ((tb->
stat() == STATUS_EOF) || (tb->
stat() == 0));
}
{
bool newConnection = false;
if (!db->
connect(uri, newConnection))
{
showError(_T(
"connect daatabase"), NULL, db->
stat());
return false;
}
db->
open(uri, TYPE_SCHEMA_BDF);
{
showError(_T(
"open daatabase"), NULL, db->
stat());
return false;
}
return true;
}
#pragma argsused
int _tmain(int argc, _TCHAR* argv[])
{
int result = 0;
static const _TCHAR* uri = _T("tdap://localhost/test?dbfile=test.bdf");
{
showError(_T(
"open user table"), NULL, db->
stat());
else
{
if (updateUsers(tbu))
_tprintf(_T("Update records success. \n"));
}
}
return result;
}
コンビニエンスAPIを使ったサンプル
#include <bzs/db/protocol/tdap/client/trdboostapi.h>
#include <iostream>
using namespace bzs::db::protocol::tdap::client;
using namespace bzs::db::protocol::tdap;
static const short fieldnum_id = 0;
static const short fieldnum_group = 2;
static const char_td keynum_group = 1;
int isGroupOne(const fields& fds)
{
return (fds[fieldnum_group].i() == 1) ? filter_validate_value
: filter_invalidate_value;
}
void changeGroupTo3(const fields& fds)
{
fds[fieldnum_group] = 3;
}
{
}
#pragma argsused
int _tmain(int argc, _TCHAR* argv[])
{
try
{
_T("test"));
bool newConnection = false;
updateUsers(tb);
std::cout << "Insert records success." << std::endl;
return 0;
}
catch (bzs::rtl::exception& e)
{
std::tcout << _T("[ERROR] ") << *bzs::rtl::getMsg(e) << std::endl;
}
return 1;
}