1. Michał Misijuk
  2. PowerBuilder
  3. Monday, 12 October 2020 11:54 AM UTC


The case is this: for every row in table A- I want to updates these records in table B, which points on A.ID 

What I've managed to do:
- for ll_i = 1 to dw_a.RowCount()
  if in b exists records for a get records from b do ds_b

  end loop

after loop:

And it works, but there is a chance that, for one record in A, everything from B updates succesfully, but for next record somethings crashes, but i've already make one commit. I wish it acted more like a transaction.

So what I want -  before updateing record from table A, check if records in B exists, if they do - append them to datastore, and after get all records:



In NVO object I have a datastore variable

datastore lds_test


lds_test.DataObject = 'records_from_b_for_a'



 To achieve something like this - RetreiveStart event and retrun code = 2 seems perfect, but since it is a local variable, the only thing I can do is:

lds_test.event retrievestart( )

Is it possible to "alter" such events to a local variable?

PB 2017 R3 Build 1858
Oracle 12c

Accepted Answer
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 12 October 2020 12:13 PM UTC
  2. PowerBuilder
  3. # Permalink

Before making any changes, set sqlca.AutoCommit to False.

Check the return from each Update and if an error occurred, do a ROLLBACK and exit the code.

Then at the end of the process set sqlca.AutoCommit to True. Doing that should trigger a COMMIT in the background.



  1. Michał Misijuk
  2. Monday, 12 October 2020 12:23 PM UTC
Hi Roland

So one portion of records goest through update, then another portion retrieves to datastore, removing old ones and if I trigger commit - ALL records will be commited?
  1. Helpful
  1. Roland Smith
  2. Monday, 12 October 2020 12:33 PM UTC
The Update function sends UPDATE SQL statements to the database server so if you retrieve the datastore again, you should be good. I'm not sure about how Oracle transactions work but the updated rows could be picked up by the retrieve even though they aren't committed.
  1. Helpful
  1. Michał Misijuk
  2. Monday, 12 October 2020 13:05 PM UTC
Brilliant! Works perefectly.

Select statement prevents from situation You've mentioned. Thank You very much :)
  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Monday, 12 October 2020 12:20 PM UTC
  2. PowerBuilder
  3. # 1

Hi Michal,

If I understand you right you want to implement the retrievestart event of the datastore in the current context (e.g. window) and not in a class?

You can add datastores like datawindows to your window (also for userobjects and others). This nested datastores are like instance variables. To add a datastore use the menu Insert->Objects->Datastore for a standard datastore or Insert->Objects->Userobject if you want your own class.




There are no comments made yet.
  • Page :
  • 1

There are no replies made for this question yet.
However, you are not allowed to reply to this question.