DeleteSQL property |
Applies to
TIB_Dataset
Declaration
Property DeleteSQL : TIB_StringList;
Description
This property is used to supply a custom SQL statement that will take care
of deleting the current row of the dataset. It uses the same syntax as the
VCL's TUpdateSQL.DeleteSQL property does.
For example:
DELETE FROM MYTABLE WHERE MYKEY = :OLD_MYKEY
By prefacing the column name with OLD_ on the parameter it will be sure to use
the old value so that it will for sure align with the state of the record on
the server.
It is NOT necessary to use this component if you have properly assigned KeyLinks
to the dataset. IBO automatically generates the standard statements to perform
deletes.
I have found this property useful to perform non-standard actions when deleting
a record from a dataset. One case could be where the dataset is actually
derived from a select stored procedure. You may also have declared another
stored procedure to perform the delete.
For example:
EXECUTE PROCEDURE MYDELETEPROC ( :OLD_MYKEY )
This will pass in the necessary information to the stored procedure and then as
long as you did your job right it will take care of whatever database actions
are required to effectively delete that record.
Keep in mind that when using a stored procedure you do not have the automatic
protection of checking the RowsAffected property performed for you. It will be
a very good idea to thoroughally test such practices.