Solved

powerbuilder 11.5 transaction,rollback,commit

Posted on 2009-07-15
5
1,384 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

930 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

9 Experts available now in Live!

Get 1:1 Help Now