Completing the Trip Maintenance application
In
Lesson 5: Implementing the Browsing and Maintenance Database
tripeditaction.cfm page to contain server side edits for the trip edit data entry form. In this final
lesson, you will complete the tripeditaction.cfm page. To complete the action page, you will write
code to do these tasks:
•
Add trips to the Compass Travel database using the cfquery tag and the SQL INSERT
statement.
•
Add trips to the Compass Travel database using the
•
Update the current trip using the
•
Link the current trip to be updated or added by the tripeditaction.cfm with the tripedit.cfm
page.
In addition to completing the Trip Maintenance application, you will develop a ColdFusion page
to update all the prices in the database using the cfquery tag and the SQL UPDATE statement.
Writing code to save new trips to the database
In
Lesson 5: Implementing the Browsing and Maintenance Database
Edit page to collect the data. Now you can modify the Trip Edit action page to insert the data into
the database. There are two approaches to inserting data into a SQL database:
•
Build a SQL INSERT statement and execute it using the
•
Use the ColdFusion
syntax.
Adding data using SQL INSERT with cfquery approach
In previous lessons, you used the SQL SELECT statement to retrieve data and the SQL DELETE
statement to delete data from the Trips table in the Compass Travel database. To add new trips to
the database using SQL, you must understand the syntax of the SQL INSERT statement.
The SQL INSERT statement inserts new rows into a relational table. The format of the INSERT
statement is as follows:
INSERT INTO table_name
VALUES (value1, value2,....)
The database table named Clients contains information about people in the following rows:
LastName
Tom
Peter
After the following SQL statement executes:
INSERT INTO Clients
VALUES ('Smith', 'Kaleigh', '14 Greenway', 'Windham')
118
Chapter 10: Lesson 6: Adding and Updating SQL Data
cfupdate
tag. This approach eliminates the need for you to learn SQL
cfinsert
FirstName
Jones
Green
tag.
cfinsert
tag.
cfquery
Address
12 State St
1 Broadway
Functions, you created the
Functions, you built a Trip
tag.
City
Boston
New York
Need help?
Do you have a question about the COLDFUSION MX 61-GETTING STARTED BUILDING COLDFUSION MX and is the answer not in the manual?