Hemant3498
16th November 2011, 11:34
hi all,
I m searching for a function which can compare a existing table record and the current values before updating the table.
can any one help me out?
thanks
mark_h
16th November 2011, 15:37
Maybe explaining what you are trying to accomplish would generate other responses. I guess you could store off the record buffer like this:
string record.buf(1) based
long record.len
function store.tpppc231.record.buffer()
{
if not record.len then
db.row.length(ttpppc231, record.len)
alloc.mem(record.buf, record.len)
endif
record.buf = rcd.ttpppc231
}
Then let the user make changes and compare record.buf to rcd.ttablexxx. If they were not equal it should mean a change was made. Never tried this myself.
JaapJD
16th November 2011, 16:41
Mark's solution is a little but risky. The record buffer contains more than the table fields only (for example ref counters).
I totally agree with:
Maybe explaining what you are trying to accomplish would generate other responses.
BaanInOhio
18th November 2011, 17:11
Investigate use of the RDI functions to get the number of bytes that are consumed by the actual table fields. The internal fields (those that you don't want to compare) are at the end of the 'rcd' buffer.
Use 'cmp.mem' to compare record buffers. Simply using "=" will not work since the strings are terminated when a null character is encountered. The 'rcd' buffer will contain plenty of nulls due to the way that numeric fields are stored (packed). You can use the RDI functions to determine starting points of specific fields if a sub-string comparison is desired.