CodePudding user response:
More data window table update
Principle:
Data window data from two or more than two tables, equivalent to more than one table of a view of the connection is established, for the data window, PB is cannot be modified by default, of course, we can set the Update Properties, data window Update Properties whether can be used to set the data window Update, Update table, can Update column, etc., but it can't set up two tables can be updated at the same time; So when modify its data items, we cannot simply use dw_1, update () to update the table, we can set the data window can be updated in the application of A table A (and its renewable column), other tables to be updated, after updating the table A, set up another table B as renewable, exhibit A is set to not update and so on,
Solution example:
We PowerBuilder7 bring ASA6 database, for example:
1, create a new data window d_grid_dep_emp, which Select statement for
SELECT department. Dept_id,
Department. Dept_name,
The employee emp_id,
The employee emp_fname,
The employee. Emp_lname
FROM the department, the employee
Where the employee. Dept_id=department. Dept_id
2, set data window d_grid_dep_emp properties, the column taborder instead of non-zero value; Rows and click menu - & gt; Update Properties, set the data window Allow Updates to the Table to Update to department, for Updateable Columns for the department. The dept_id, department. Dept_name,
3, update the data in the window the window button clicked event script:
Long ll_rtn
//modify the Department table, Department table in step 2 is set to update)
Ll_rtn=dw_1. Update (true, false)
If ll_rtn=1 then
//close to modify the Department table
Dw_1. Modify (" department_dept_name. Update='No' ")
Dw_1. Modify (" department_dept_id. Update='No' ")
Dw_1. Modify (" department_dept_id. Key='No' ")
//set the Employee table become the new can modify the table
Dw_1. Modify (" DataWindow. Table. UpdateTable='employee' ")
Dw_1. Modify (" employee_emp_id. Update='Yes' ")
Dw_1. Modify (" employee_emp_fname. Update='Yes' ")
Dw_1. Modify (" employee_emp_lname. Update='Yes' ")
Dw_1. Modify (" employee_emp_id. Key='Yes' ")
//modify the Employee table
Ll_rtn=dw_1. The Update ()
IF ll_rtn=1 THEN
COMMIT the USING the SQLCA;
Dw_1. Retrieve ()
Messagebox (' message 'and' updated successfully! ')
The ELSE
The ROLLBACK USING SQLCA;
MessageBox (' message 'and' update failed! ')
END the IF
//reset mark
Dw_1. Modify (" department_dept_name. Update='Yes' ")
Dw_1. Modify (" department_dept_id. Update='Yes' ")
Dw_1. Modify (" department_dept_id. Key='Yes' ")
Dw_1. Modify (" DataWindow. Table. UpdateTable='department' ")
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' ")
The ELSE
The ROLLBACK USING SQLCA;
MessageBox (' message 'and' update failed! ')
END the IF
This completes the update of two tables, of course, we can put the above function into a function, called when required,
CodePudding user response: