Power Builder - DW Update sobre 2 tablas

 
Vista:

DW Update sobre 2 tablas

Publicado por Sixto (9 intervenciones) el 20/01/2005 11:31:14
Bien, el problema es muy simple: No se como puedo hacer para que con un único datawindow pueda lanzar un update sobre varias tablas.

Cuando edito las propiedades de 'Update properties' del datawindow no puedo seleccionar dos tablas para poder seleccionar varias campos de las dos tablas.

Debería de haber otra forma de indicar que una columna de un datawindow sea updateable ¿o no?

Salu2. Y gracias.

PD:La unica solucion que he podido hacer es poner los datos de una tabla en un datawindow y los datos de la otra en otro datawindow pero me gustaría saber como podría hacer esto.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:DW Update sobre 2 tablas

Publicado por Sixto (9 intervenciones) el 24/01/2005 17:29:25
Ya encontré la respuesta en la ayuda del PowerBuilder:

Updating more than one table An important use of Modify is to make it possible to update more than one table from one DataWindow object. The following script updates the table that was specified as updatable in the DataWindow painter; then it uses Modify to make the other joined table updatable and to specify the key column and which columns to update. This technique eliminates the need to create multiple DataWindow objects or to use embedded SQL statements to update more than one table.

In this example, the DataWindow object joins two tables: department and employee. First department is updated, with status flags not reset. Then employee is made updatable and is updated. If all succeeds, the Update commands resets the flags and COMMIT commits the changes. Note that to make the script repeatable in the user's session, you must add code to make department the updatable table again:

integer rc

string err

/* The SELECT statement for the DataWindow is:

SELECT department.dept_id, department.dept_name,

employee.emp_id, employee.emp_fname,

employee.emp_lname FROM department, employee ;

*/

// Update department, as set up in the DW painter

rc = dw_1.Update(TRUE, FALSE)

IF rc = 1 THEN

//Turn off update for department columns.

dw_1.Modify("department_dept_name.Update = No")

dw_1.Modify("department_dept_id.Update = No")

dw_1.Modify("department_dept_id.Key = No")

// Make employee table updatable.

dw_1.Modify( &

"DataWindow.Table.UpdateTable = ~"employee~"")

//Turn on update for desired employee columns.

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")

//Then update the employee table.

rc = dw_1.Update()

IF rc = 1 THEN

COMMIT USING SQLCA;

ELSE

ROLLBACK USING SQLCA;

MessageBox("Status", &

+ "Update of employee table failed. " &

+ "Rolling back all changes.")

END IF

ELSE

ROLLBACK USING SQLCA;

MessageBox("Status", &

+ "Update of department table failed. " &

+ "Rolling back changes to department.")

END IF

Salu2.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

RE:DW Update sobre 2 tablas

Publicado por FRANCISCO PORTALES (214 intervenciones) el 24/02/2005 15:58:20
hace una vista con las varias tablas, y de la vista hace el dw. alli te deberia dejar actualizar en varias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar