?
Solved

powerbuilder 11.5 transaction,rollback,commit

Posted on 2009-07-15
5
Medium Priority
?
1,512 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
shru_0409 earned 1000 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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month9 days, 18 hours left to enroll

762 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