function TPDO.query_update_multitable (const table_joins: Ansistring; const set_expressions: Ansistring; const condition: ansistring = ''): int64;
TPDO.query_update_multitable internally assembles a multiple 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.
Parameters
tables: the names of the tables from which data will be updated. (note1) table_joins: defines the initial dataset, including JOINS with ON qualifiers condition: optionally narrows down data even more.
Return Values
TPDO.query_update_multitable returns the number of rows updated by the operation
Notes
note 1: If the table_joins parameter describes the tables and defines their aliases, then the alias must be used with the tables parameter, not their real name.
note 2: the table joins should only use the following keywords: JOIN, LEFT JOIN, NATURAL LEFT JOIN, CROSS JOIN, INNER JOIN, AS Be very alert with CROSS JOIN, you rarely ever want this cartesian join. The INNER JOIN is redundant for JOIN The LEFT OUTER JOIN is redundant for LEFT JOIN The RIGHT OUTER JOIN isn't supported by all databases because you can switch the order and use LEFT JOIN
Example
procedure example; var rows_updated: integer; Begin rows_updated := db.query_update_multitable('nfl_teams AS n, stadiums as s','n.location = ''Bermuda'', s.capacity=9999', 'n.nfl_team = s.nfl_team and n.nfl_team = 45'); writeln ('updated ' + inttostr(rows_updated) + ' multitable rows'); end;
The above example may output:
updated 2 multitable rows.