1. Ashutosh Varshney
  2. PowerBuilder
  3. Friday, 1 April 2022 15:48 PM UTC

Hello Folks,

I have a mutli row datawindow and I need to undo changes made to one particular row - i.e. restore it to the retrieved state. I know I need to do a RowsCopy but am not sure about the syntax. I hope someone can help me with it.

dw_1.RowsCopy (6, 6, Original!, dw_1, 6, Primary!) 


 Thank You.

Accepted Answer
Ronnie Po Accepted Answer Pending Moderation
  1. Friday, 1 April 2022 17:03 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Ashutosh,

To restore row 6 for example, this should do it:

dw_1.object.data.primary.current[6] = dw_1.object.data.primary.original[6]
Comment
  1. Chris Pollach @Appeon
  2. Friday, 1 April 2022 17:32 PM UTC
That is the best way Ronnie! :-)
  1. Helpful
  1. John Fauss
  2. Friday, 1 April 2022 18:08 PM UTC
Ah... dot notation! Of course! Very nice, Ronnie!!!
  1. Helpful
  1. Ashutosh Varshney
  2. Friday, 1 April 2022 18:32 PM UTC
Aha... That is what I was looking for. Thanks a ton Ronnie!
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 1 April 2022 17:38 PM UTC
  2. PowerBuilder
  3. # 1

Hi Ashutosh ;

  Another suggestion other than Ronnie's great reply, would be to use the ReSelectRow() DC/DS command. The advantage of this approach is that not only are you clearing the Row/Column update flags for that row in the primary buffer but, you're also getting the "latest" data from the DBMS vs the "Original" buffer (which may now be "stale dated" data). Food for thought. HTH

Regards ... Chris

Comment
  1. Ashutosh Varshney
  2. Friday, 1 April 2022 18:34 PM UTC
Thanks Chris. That is good to know.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Friday, 1 April 2022 16:27 PM UTC
  2. PowerBuilder
  3. # 2

Hi, Ashutosh -

"Original!" is not a valid enumerated value for a DWBuffer datatype. You can verify this by viewing the PB Help topic for "DWBuffer constant (DataWindows)".

You will have to extract the individual data values column by column using GetItemXXXXX method calls with fourth argument (originalvalue) set to True, then use SetItem on each extracted original item value. I suspect you'll probably also want to reset the entire row's ItemStatus flags after recovering the row's original data values.

Regards, John

Comment
  1. Ashutosh Varshney
  2. Friday, 1 April 2022 16:44 PM UTC
Thanks John. 



You are correct - Original! is not a valid constant. I could have sworn I did something similar with RowsCopy many moons ago - but I am mistaken. 



Thanks for your input. Much appreciated.
  1. Helpful
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.