Professional Documents
Culture Documents
Multiplie Table Update
Multiplie Table Update
Datawindow
This Script Demonstrates How A Datawindow Based Upon A Join Of Multiple Tables Can Have Update Capability Against
All Of Those Tables, Eliminating The Need To Create Multiple Datawindows Or Write Embedded SQL Scripts To
Propagate Changes Across Tables .
int rc
string err
The datawindow is built upon a join of two tables, department and employee. The select that it is based upon appears
as follows:
The datawindow was initially set up with update capability against the department table. So when the datawindow is
initially updated, it will apply the SQL statements to the department table and the columns in the department table that
are set to be updateable. Set the second Update argument (resetflag) to false so that the update status's of the
datawindow are not cleared if the update is successful. This will allow us to change tables and issue a second update
on the datawindow this time applying the SQL statements to the second table. (We will assume that SetTransObject
was used, so that our database changes will not be automatically committed for us.)
IF rc = 1 THEN
dw_1.Modify("employee_emp_id.Update=No")
dw_1.Modify("employee_emp_fname.Update=No")
dw_1.Modify("employee_emp_lname.Update=No")
dw_1.Modify("employee_emp_id.Key=No")
ELSE
MessageBox(Update of department table failed, Rolling back changes to &
department)
ROLLBACK USING SQLCA;
END IF
The above example uses Modify to change the update properties of the datawindow. Dot notation can also be used to
make these changes. The following is an example of dot notation to make these changes:
dw_1.Object.department_dept_name.Update = 'Yes'
dw_1.Object.department_dept_id.Update = 'Yes'
dw_1.Object.department_dept_id.Key = 'Yes'
dw_1.Object.DataWindow.Table.UpdateTable = 'department'