1. Sofhin Wong
  2. PowerBuilder
  3. Tuesday, 9 July 2024 03:50 AM UTC

Hi all

 

I wonder if I'm able to do so....

 

I have two identical datawindow, dw_1 and dw_2. Both shows different columns, but select statement is the same.

dw_1 only have one row, multiple row is not allowed here, but for dw_2, multiple row is allowed.

 

So what I'm trying to achieve is:

- When I modify anything in dw_1, I want it to copy all values into dw_2, but do not insert row.

 

For example:

dw_1 = 1 row only

dw_2 = 3 rows

When I modify column A in dw_1, I want to update dw_2 column A value also.

 

I tried to use rowsCopy, but it will insert one row

 

Thank you

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 9 July 2024 04:05 AM UTC
  2. PowerBuilder
  3. # 1

Hi Sophin;

  Suggestion: Have a look at the ShareData() method.

Regards ... Chris 

Comment
  1. Sofhin Wong
  2. Tuesday, 9 July 2024 06:57 AM UTC
Hi, thanks for the suggestion. If I use shareData, my dw_2 as my primary dw, dw_1 as my secondary dw, it will insert more than one row for dw_1... However, if dw_1 is my primary dw, dw_2 is secondary dw, changes apply only on first row in dw_2.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 9 July 2024 14:57 PM UTC
In that case, use the RowsCopy DW_1 => DW_2

Then use the DW_.2.ResetUpdate ( ) command to clear the row / column flags.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 9 July 2024 04:05 AM UTC
  2. PowerBuilder
  3. # 2

Hi, Sofhin -

Use RowsCopy, but then follow that, changing the status flag for all of the columns in the entire new row using the DataWindow control's SetItemStatus method. Hint: Check the PB Help topic on this method, and note that by specifying a column number of zero (0), you can change the status of every column object in the DataWindow with a single call.

Best regards, John

Comment
  1. Sivaprakash BKR
  2. Tuesday, 9 July 2024 05:00 AM UTC
If you use RowsCopy, I think it will insert a new row in dw_2. So you may have to delete that particular row in dw_2, then insert (or rowscopy) the updated data.

Instead of Rowscopy you can think of using exportjson and importjsonbykey also.

Rowscopy might fail even if the order of the column gets re-located, but importJSONbyKey will succeed.
  1. Helpful 1
  1. René Ullrich
  2. Tuesday, 9 July 2024 05:40 AM UTC
To have only one row you may also do a Reset() to remove all data before you copy the row.
  1. Helpful
  1. Sofhin Wong
  2. Tuesday, 9 July 2024 06:32 AM UTC
I will look into it. Thanks, John.

Yes, you're right, when using rowsCopy, it will insert one row into dw_2.
  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.