[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

powerbuilder 11.5 transaction,rollback,commit

Posted on 2009-07-15
5
Medium Priority
?
1,554 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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: …
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.
Suggested Courses

649 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