Deleting Data with ColdFusion

ColdFusion is very efficient at adding and updating data, but not at deleting it. DELETE is always a dangerous operation, and the ColdFusion developers didn’t want to make it too easy to delete data by mistake.

To delete data in a ColdFusion template, you must use the SQL DELETE statement, as shown in Listing 14.12. The code first checks to ensure that a FilmID was passed; if the URL.FilmID field isn’t present, the statement terminates. If a FilmID is passed, a <cfquery> is used to pass a SQL DELETE statement to the data source.

See Chapter 6 for an explanation of the DELETE statement.
Listing 14.12. delete1.cfm—Deleting Table Data with SQL DELETE
<!--- Name: delete1.cfm Author: Ben Forta (ben@forta.com) Description: ...

Get Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.