2
我用libpqxx用于连接到PostgreSQL的+ DB用C。我想加密一列表并用当前列替换它。我写这个:如何替换PostgreSQL +上表的列值?
int num;
cout << "Select Your COLUMN Number For Encryption: ";
cin >> num;
/* Create SQL statement */
sql = "SELECT * from " + tbName;
/* Execute SQL query */
result R3(N.exec(sql));
/* List down all the records */
for (result::const_iterator c = R3.begin(); c != R3.end(); ++c) {
c[num].as<string>() = encnum->encryptionData(3,5,c[num].as<int>());
cout << "Encryption = " << c[num].as<string>() << endl;
}
但结果就像加密之前。我的错在哪里,以及如何将值替换为列中的其他值?
如果你想更新表列,那么你应该执行[更新](https://www.postgresql.org/docs/9.6/static/dml-update.html)语句。 – karastojko
你能告诉我吗?我尝试更新一个值,但我想更新整个列。 @karastojko – Richard
你试试[简介示例](http://pqxx.org/development/libpqxx/),其中有更新语句? – karastojko