Pascal Data Objects

function TPDO.query_delete_multitable ( const tables: Ansistring; const table_joins: Ansistring; const condition: ansistring = ''): int64;

TPDO.query_delete_multitable internally assembles a multiple table SQL delete 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.


tables: the names of the tables from which data will be deleted. (note1) table_joins: defines the initial dataset, including JOINS with ON qualifiers condition: optionally narrows down data even more. Misuse can clear all listed tables.

Return Values

TPDO.query_delete_multitable returns the number of rows deleted by the operation


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


procedure example;
     rows_deleted: integer;
     rows_deleted := db.query_delete_multitable('n, s','nfl_teams AS n JOIN stadiums AS s ON n.nfl_team);
     writeln ('deleted ' + inttostr(rows_deleted) + ' teams.');

The above example may output:

deleted 6 teams.