Please execute the "create database" example before execute this example.
標準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>
#include <boost/bind.hpp>
using namespace bzs::db::protocol::tdap::client;
using namespace bzs::db::protocol::tdap;
static const short tablenum_user = 1;
static const short fieldnum_name = 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 changeUserTable(
dbdef* def)
{
{
showError(_T(
"edit schema table"), NULL, def->
stat());
return false;
}
return true;
}
bool openDbExclusive(
database* db,
const _TCHAR* uri)
{
db->
open(uri, TYPE_SCHEMA_BDF, TD_OPEN_EXCLUSIVE);
{
showError(_T(
"open daatabase"), NULL, db->
stat());
return false;
}
return true;
}
void __STDCALL
{
if (count == 0)
_tprintf(_T("\n"));
_tprintf(_T("."));
}
#pragma argsused
int _tmain(int argc, _TCHAR* argv[])
{
int result = 0;
static const _TCHAR* uri = _T("tdap://localhost/test?dbfile=test.bdf");
if (openDbExclusive(db, uri))
{
{
if (changeUserTable(db->
dbDef()))
{
{
showError(_T(
"convert table"), NULL, db->
stat());
}
}
{
}
else
_tprintf(_T("\nchange schema success. \n"));
}else
showError(_T(
"backup table def"), NULL, db->
dbDef()->
stat());
}
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 tablenum_user = 1;
static const short fieldnum_name = 1;
void changeUserTable(
dbdef* def)
{
size);
}
void __STDCALL
onCopyData(
database* db,
table* tb,
int recordCount,
int count,
bool& cancel)
{
if (count == 0)
std::cout << std::endl;
std::cout << ".";
}
#pragma argsused
int _tmain(int argc, _TCHAR* argv[])
{
try
{
_T("test"));
prams.setMode(TD_OPEN_EXCLUSIVE);
db->dbDef()->pushBackup(tablenum_user);
changeUserTable(db->dbDef());
std::cout << "change schema success." << std::endl;
return 0;
}
catch (bzs::rtl::exception& e)
{
std::tcout << _T("[ERROR] ") << *bzs::rtl::getMsg(e) << std::endl;
}
return 1;
}