Using Databases in E3: Chapter 7 – Deleting Records.

Records can be deleted in two ways: by filter, or by all existing records.

To delete only one or more records of a database table, you must configure the SQL code of the Query so that there is a filter which selects what data to erase. This is the SQL code structure.

DELETE FROM (function used) TABLENAME (table used)
WHERE FIELDNAME (field of the variable used as a filter) = FIELDVALUE

As shown in the next example.

Figure 1: SQL code example using the DELETE FROM clause

NOTE: For the Access database, add * between DELETE and FROM. In case of SQL Server or Oracle databases, this is not necessary.

To delete all records from a database, you must configure the SQL code of the Query this way:

DELETE (function used)
FROM TABLENAME (table to erase)

As shown in the next example.

Figure 2: SQL code example using the DELETE clause

Exercise

  1. Create a Query and a button which delete only a record of the filter.
  2. Create a Query and a button which delete all records of a Historic.
Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *