refreshRecord method
Implementation
bool refreshRecord(TUpdateKind updateKind) {
var result = false;
final q = TCustomSQLQuery(null);
try {
q.database = database;
q.transaction = transaction;
q.sql.text = sqlConnection!.constructRefreshSQL(this, updateKind);
for (var i = 0; i < q.params.count; i++) {
final p = q.params[i];
var n = p.name;
if (n.length >= 4 && n.substring(0, 4).toUpperCase() == 'OLD_') {
n = n.substring(4);
}
final f = fields.findField(n);
if (f != null) {
p.assignField(f);
}
}
q.open();
try {
if (q.eof && q.bof) {
databaseError(SErrRefreshEmptyResult, this);
} else {
if (q.recordCount != 1) {
databaseErrorFmt(
SErrRefreshNotSingleton, [q.recordCount], this);
}
for (var i = 0; i < q.fields.count; i++) {
final f = q.fields[i];
final fd = fields.findField(f.fieldName);
if (fd != null) {
fd.assign(f);
result = true; // We could check if the new value differs
// from the old, but we won't. (original comment kept as-is)
}
}
}
} finally {
q.close();
}
} finally {
q.free();
}
return result;
}