Solved

powerbuilder 11.5 transaction,rollback,commit

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
easiest way to find port number 12 107
Eclipse XML hightlightning 5 55
missing "main" in Java on Eclipse 4 71
Use tracing facilities in your browser steps 2 117
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: …
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.

777 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