Link to home
Start Free TrialLog in
Avatar of basilhs_s
basilhs_s

asked on

powerbuilder 11.5 transaction,rollback,commit

i am having a window with three datawindows dw_1, dw_2,dw_3
there is a push button pb_update with the following code
dw_1.update()
dw_2.update()
dw_3.update()
how can we see these statements as a transaction? if something goes wrong in  any of these three lines how can we invoke a rollback statement?  if there are triggers that are going to be fired in the data base what will happen with them?

i am using powerbuilder pb 11.5 and sql server 2000
ASKER CERTIFIED SOLUTION
Avatar of shru_0409
shru_0409
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of basilhs_s
basilhs_s

ASKER

this is an acceptable approach but if i had 5 datawindows for example i would have to put some extra lines to code.

we tried this approach
TRY
dw_1.update()
dw_2.update()
dw_3.update()      
commit;

CATCH (exception e1)
     TRY
      rollback;
      CATCH (exception e2)
             MessageBox("Rollback failed", e2.getMessage())
     END TRY

MessageBox("Transaction failed", e1.getMessage())
END TRY

how can we force dw_update to fire an execption if something goes wrong?
Hi,

Or, try,

If dw_1.update() = 1 Then
    If dw_2.update() = 1 Then
        If dw_3.update() = 1 Then
              Commit;
        Else
              Rollback;
        End If
    End If
End If


Cheers,
Rosh
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks to all. both solutions were very understandable