Deleting Data
8
The employee is deleted from the Employee table and the message displays.
Reviewing the code
The following table describes the code and its function:
Code
<cfquery name="DeleteEmployee"
</cfquery>
<cfoutput>
You have deleted #Form.FirstName#
</cfoutput>
Deleting multiple records
You can use a SQL condition to delete several records. The following example deletes
the records for everyone in the Sales department (which has Dept_ID number 4)
from the Employee table:
DELETE FROM Employee
WHERE Dept_ID = 4
To delete all the records from the Employee table, you use the following code:
DELETE FROM Employee
Note
Deleting records from a database is not reversible. Use DELETE statements carefully.
View deleteform.cfm a browser by specifying the page URL and an Employee ID,
for example, http://localhost/myapps/updateform.cfm?Emp_ID=3. and click the
Submit button.
datasource="CompanyInfo">
DELETE FROM Employee
WHERE Emp_ID = #Form.Emp_ID#
#Form.LastName# from the
Employees database.
Description
Delete the record in the database whose
Emp_ID column matches the Emp_ID
(hidden) field on the form. Since the
Emp_ID is the table's primary key, only one
record gets deleted.
Inform the user that the record was deleted.
113
Need help?
Do you have a question about the COLDFUSION 5-DEVELOPING and is the answer not in the manual?
Questions and answers