Solved

powerbuilder 11.5 transaction,rollback,commit

Posted on 2009-07-15
5
1,370 Views
Last Modified: 2013-12-26
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
0
Comment
Question by:basilhs_s
  • 2
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
shru_0409 earned 250 total points
ID: 24858070
boolean ld_update
int      rtn1,rtn2,rtn3

rtn1 = dw_1.Update()

IF rtn1 = 1 THEN
  ld_update = TRUE
ELSE
 ld_update = FALSE
END IF

rtn2 = dw_2.Update()

IF rtn2 = 1 THEN
  ld_update = TRUE
ELSE
 ld_update = FALSE
END IF
rtn3 = dw_3.Update()

IF rtn3 = 1 THEN
  ld_update = TRUE
ELSE
 ld_update = FALSE
END IF


IF ld_update THEN
  COMMIT USING SQLCA;
ELSE
 ROLLBACK USING SQLCA;
END IF
0
 

Author Comment

by:basilhs_s
ID: 24858851
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?
0
 
LVL 18

Expert Comment

by:diasroshan
ID: 24867025
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
0
 
LVL 18

Assisted Solution

by:diasroshan
diasroshan earned 250 total points
ID: 24867103
Sorry, ignore the above, it shud be as below,
If dw_1.update() = 1 Then
    If dw_2.update() = 1 Then
        If dw_3.update() = 1 Then
              Commit;
        Else
              Rollback;
        End If
     Else
             Rollback
    End If
Else
      Rollback
End If
0
 

Author Closing Comment

by:basilhs_s
ID: 31603659
thanks to all. both solutions were very understandable
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now