Sha256: 5801133f6ce756e80c1e979b4f3972f1df7596166751b8bcd5e086c51e198cf4

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

#include <bzs/db/protocol/tdap/client/trdboostapi.h>
#include <iostream>

using namespace bzs::db::protocol::tdap::client;
using namespace bzs::db::protocol::tdap;


/**
@brief read and delete example

This program deletes one record of a "user" table.


Please execute "create database" , "change schema" and "insert records" example
    before execute this example.

*/



static const short fieldnum_id = 0;
static const char_td keynum_id = 0;

void deleteUser(table_ptr tb)
{
    //Seek record that user id = 3 "satoshi"
    indexIterator it = readIndex_v(tb, eSeekEqual, keynum_id, 3);

    if (it != indexIterator::eos)
        deleteRecord(it);  //delete id = 3
    else
       THROW_BZS_ERROR_WITH_MSG(_T("User id = 3 was not found"));

}


#pragma argsused
int _tmain(int argc, _TCHAR* argv[])
{
    database_ptr db = createDatadaseObject();
    try
    {
        connectParams param(_T("tdap"), _T("localhost"), _T("test"), _T("test"));
        openDatabase(db, param);

        table_ptr tb = openTable(db, _T("user"));
        deleteUser(tb);
        std::cout << "Insert records success." << std::endl;
        return 0;
    }

    catch(bzs::rtl::exception& e)
    {
        std::tcout << *bzs::rtl::getMsg(e) << std::endl;
    }
    return 1;
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
transactd-1.0.1 source/bzs/example/deleteRecords_c.cpp