问题
How do I find the reason for a "Record not found or changed by another user" error when working with dbExpress?
How do I find the SQL statement (with the actual parameter values) that fails?
回答1:
make sure that the compiler uses Debug DCUs.
set a breakpoint in the first line of the Procedure
TSQLResolver.DoExecSQL
in unitdb\Provider
run the operation which causes the error message (for example, modifying a record in a data-aware component)
if the debugger stops, the generated SQL command can be viewed
check the SQL statement for conditions which could cause the error
At this point, only constant expressions in the statement like ... 'where Field1 is null and Field2 = 0' can be checked. in DoExecSQL, the SQL statement uses placeholders (?) for parameter values, so if the constant expression conditions did not show anything helpful, continue debugging:
- to see the actual parameter values, set a breakpoint in function TSQLConnection.Execute (in unit SqlExpr) and step through the parameter evaluation loop.
来源:https://stackoverflow.com/questions/9773147/dbexpress-record-not-found-or-changed-by-another-user