Title: Adding data using Cold Fusion
1Adding data using Cold Fusion
- Step 1 Display a form to collect the data.
The input fields must have the same - name as that of the columns in
the destination table - Step 2 Submit the form to Cold Fusion for
processing - Step 3 Add the row via the ODBC driver using
SQL
2The Add record form
lthtmlgt ltheadgt lttitlegtAdd sales
repslt/titlegt lt/headgt ltbodygt lth1gtAdd a new sales
replt/h1gt ltform action"slsrepadd2.cfm"
method"post"gt ltpgt ltbgtSales rep
numberlt/bgt ltinput type"text" name"slsrnumb"
size"3" maxlength"10"gt ltbrgt Name ltinput
type"text" name"slsrname" size"20"
maxlength"30"gt ltbrgt Address ltinput type"text"
name"slsraddr" size"30" maxlength"50"gt ltbrgt Tot
al commission
ltinput type"text" name"totcomm" size"5"
maxlength"10"gt ltbrgt
3The Add record form contd.
Commision rate ltinput type"text"
name"commrate" size"5" maxlength"10"gt ltpgt ltinp
ut type"submit" value"Add sales rep"gt ltinput
type"reset" value"Clear"gt lt/formgt lt/bodygt lt/html
gt
4Processing additions using insert statement
ltcfquery datasource"oracle"gt insert into slsrep
values (slsrnumb, 'slsrname', 'slsraddr',
totcomm, commrate) lt/cfquerygt lthtmlgt ltheadgt lt
titlegtSales re addedlt/titlegt lt/headgt ltbodygt lth1gt
Sales rep addedlt/h1gt ltcfoutputgt Sales rep
ltbgtslsrnamelt/bgt added. lt/cfoutputgt lt/bodygt lt/h
tmlgt
5Processing additions using cfinsert tag
- Hides the complexity of building dynamic SQL
statements
ltcfinsert datasource"oracle" tablename
"SLSREP" formfields"slsrnumb, slsrname,
slsraddr, totcomm"gt lthtmlgt ltheadgt lttitlegtSales
re addedlt/titlegt lt/headgt ltbodygt lth1gt Sales rep
addedlt/h1gt ltcfoutputgt Sales rep
ltbgtslsrnamelt/bgt added. lt/cfoutputgt lt/bodygt lt/h
tmlgt