简体   繁体   中英

Conversion from ibpp to pqxx in C++ project

I have a C++ code which uses Firebird (driver ibpp), and I need to make a conversion to PostgreSQL (pqxx is used). Main file which I need to change is this one . I started, but now I have difficulties.

while (st->Fetch())
{
    st->Get(1, tName);
    st->Get(2, fieldName);
    st->Get(3, fieldType);

    if (tName != tableName)
        continue;

    result.push_back(DbField(fieldName, fieldType, ""));
 } 

I have no idea how to rewrite it using pqxx. I've rewrite some piece of code in pqxx, u can see it here . So can u help me with this fragment?

I've just started working with SQL and it could be great, if someone will explain me how does ibpp code-works. And if u left some links with big pqxx-examples, it would be great.

IBPP fragment executes the query sql1 and the given loop goes through the resulting table rows and pushes them all to the result which is probably kind of vector.

The analogue Postgres code would be

vector<tuple<string, string, string>> result_set;
pqxx::work txn(*conn);
pqxx::result res = txn.exec("SELECT TRIM(RL.RDB$RELATION_NAME), TRIM(FR.RDB$FIELD_NAME), FS.RDB$FIELD_TYPE ...");
for (unsigned i = 0; i < res.size(); ++i)
{
    string first = res[i][0].as<string>("");
    string second = res[i][1].as<string>("");
    string third = res[i][2].as<string>("");
    result_set.push_back(make_tuple(provider, oper, priority));
}

The query of course should be completed, since it is truncated here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM