RAD Studio
ContentsIndex
PreviousUpNext
Using the Update SQL Editor
To create the SQL statements for an update component

  1. Using the Object Inspector, select the name of the update object from the drop-down list for the dataset's UpdateObject property. This step ensures that the Update SQL editor you invoke in the next step can determine suitable default values to use for SQL generation options.
  2. Right-click the update object and select UpdateSQL Editor from the context menu. This displays the Update SQL editor. The editor creates SQL statements for the update object's ModifySQL, InsertSQL, and DeleteSQL properties based on the underlying data set and on the values you supply to it.
The Update SQL editor has two pages. The Options page is visible when you first invoke the editor. Use the Table Name combo box to select the table to update. When you specify a table name, the Key Fields and Update Fields list boxes are populated with available columns. 

The Update Fields list box indicates which columns should be updated. When you first specify a table, all columns in the Update Fields list box are selected for inclusion. You can multi-select fields as desired. 

The Key Fields list box is used to specify the columns to use as keys during the update. For Paradox, dBASE, and FoxPro the columns you specify here must correspond to an existing index, but this is not a requirement for remote SQL databases. Instead of setting Key Fields you can click the Primary Keys button to choose key fields for the update based on the table's primary index. Click Dataset Defaults to return the selection lists to the original state: all fields selected as keys and all selected for update. 

Check the Quote Field Names check box if your server requires quotation marks around field names. 

After you specify a table, select key columns, and select update columns, click Generate SQL to generate the preliminary SQL statements to associate with the update component's ModifySQL, InsertSQL, and DeleteSQL properties. In most cases you will want or need to fine tune the automatically generated SQL statements. 

To view and modify the generated SQL statements, select the SQL page. If you have generated SQL statements, then when you select this page, the statement for the ModifySQL property is already displayed in the SQL Text memo box. You can edit the statement in the box as desired.

Warning: Keep in mind that generated SQL statements are starting points for creating update statements. You may need to modify these statements to make them execute correctly. For example, when working with data that contains NULL values, you need to modify the WHERE clause to read

WHERE field IS NULL

rather then using the generated field variable. Test each of the statements directly yourself before accepting them. 

Use the Statement Type radio buttons to switch among generated SQL statements and edit them as desired. 

To accept the statements and associate them with the update component's SQL properties, click OK.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!