CFUPDATE

The CFUPDATE tag updates existing records in data sources.

Syntax

<CFUPDATE DATASOURCE="ds_name"
    DBTYPE="type"
    DBSERVER="dbms"
    DBNAME="database name"
    TABLENAME="table_name"
    TABLEOWNER="name"
    TABLEQUALIFIER="qualifier"
    USERNAME="username"
    PASSWORD="password"
    PROVIDER="COMProvider" 
    PROVIDERDSN="datasource" 
    FORMFIELDS="field_names">

DATASOURCE

Required. Name of the data source that contains your table.

DBTYPE

Optional. The database driver type:

DBSERVER

Optional. For native database drivers and the SQLOLEDB provider, specifies the name of the database server machine. If specified, DBSERVER overrides the server specified in the data source.

DBNAME

Optional. The database name (Sybase System 11 driver and SQLOLEDB provider only). If specified, DBNAME overrides the default database specified in the data source.

TABLENAME

Required. Name of the table you want to update. Note the following:

TABLEOWNER

Optional. For data sources that support table ownership (for example, SQL Server, Oracle, and Sybase SQL Anywhere), use this field to specify the owner of the table.

TABLEQUALIFIER

Optional. For data sources that support table qualifiers, use this field to specify the qualifier for the table. The purpose of table qualifiers varies across drivers. For SQL Server and Oracle, the qualifier refers to the name of the database that contains the table. For the Intersolv dBase driver, the qualifier refers to the directory where the DBF files are located.

USERNAME

Optional. If specified, USERNAME overrides the username value specified in the ODBC setup.

PASSWORD

Optional. If specified, PASSWORD overrides the password value specified in the ODBC setup.

PROVIDER

Optional. COM provider (OLE-DB only).

PROVIDERDSN

Optional. Data source name for the COM provider (OLE-DB only).

FORMFIELDS

Optional. A comma-separated list of form fields to update. If this attribute is not specified, all fields in the form are included in the operation.

Example

<!--- This example shows the use of CFUPDATE to change
records in a data source --->

<!--- if course_ID has been passed to this form, then
perform the update on that record in the data source --->
<CFIF IsDefined("form.course_ID") is "True">
<CFUPDATE DATASOURCE="cfsnippets"
TABLENAME="courses" FORMFIELDS="course_ID,number,Descript">
</CFIF>

<!--- perform a query to reflect any updated information
if course_ID is passed through a url, we are selecting a
record to update ... select only that record with the
WHERE clause
 --->
<CFQUERY NAME="GetCourseInfo" DATASOURCE="cfsnippets">
SELECT     Number, Course_ID, Descript
FROM       Courses
<CFIF IsDefined("url.course_ID") is True>
WHERE        Course_ID = #url.course_ID#
</CFIF>
ORDER by Number
</CFQUERY>

<HTML>
<HEAD>
<TITLE>CFUPDATE Example</TITLE>
</HEAD>

<BODY bgcolor=silver>
<H3>CFUPDATE Example</H3>

<!--- if we are updating a record, don't show
the entire list --->
<CFIF NOT IsDefined("url.course_ID")>
<P><H3><a href="cfupdate.cfm">Show Entire List</A></H3>

<FORM METHOD="POST" ACTION="cfupdate.cfm">

<H3>You can alter the contents of this
record, and then click "submit" to use
CFUPDATE and alter the database</H3>

<P>Course Number <INPUT TYPE="Text" NAME="number"
  VALUE="<CFOUTPUT>#GetCourseInfo.number#</CFOUTPUT>">
<P>Course Description<BR>
<TEXTAREA NAME="Descript" COLS="40" ROWS="5">
<CFOUTPUT>#GetCourseInfo.Descript#</CFOUTPUT>
</TEXTAREA>
<INPUT TYPE="Hidden" NAME="course_id"
  VALUE="<CFOUTPUT>#GetCourseInfo.Course_ID#</CFOUTPUT>">
<P><INPUT TYPE="Submit" NAME="">
</FORM>

<CFELSE>
<!--- Show the entire record set in CFTABLE form --->
<CFTABLE QUERY="GetCourseInfo" HTMLTABLE>
<CFCOL  TEXT="<a href='cfupdate.cfm?course_ID=#course_ID#'>Edit Me</a>"
  WIDTH=10 HEADER="Edit<br>this Entry">
<CFCOL  TEXT="#Number#" WIDTH="4" HEADER="Course Number">
<CFCOL  TEXT="#Descript#" WIDTH=100 HEADER="Course Description">
</CFTABLE>
</CFIF>
</BODY>
</HTML>