function TPDO.query_update (const tablename: Ansistring; const set_expressions: Ansistring; const condition: Ansistring = ''; const order: Ansistring = ''; const limit: longword = 0): int64;
TPDO.query_update internally assembles a single table SQL update statement based on the database driver in use. This function is particularly helpful when the application can be connected to multiple databases, so the program should have to be written to specific drivers.
tablename: name of table with optional alias condition: the conditions normally found in the WHERE clause limit: the maximum number of rows to be deleted that meet the conditions order by: only used with limit, it orders the rows before limiting the number deleted.
TPDO.query_update returns the number of rows deleted by the operation
Limiting updates is generally considered bad form, and most databases don't support it directly, although MySQL does and recently Firebird 2.0 adds a ROWS keyword. For maximum portability, consider not using LIMIT and ORDER BY for updates.
This applies to single tables only. Some database support multi-table udpates, so this is covered by another command.
procedure example; var rows_updated: integer; Begin rows_updated := db.query_update('nfl_teams','location = ''Neverland''','nfl_team = 45')); writeln ('updated ' + inttostr(rows_deleted) + ' teams.'); end;
The above example may output:
deleted 1 teams.