1. David Vasconcelos
  2. PowerBuilder
  3. Friday, 20 April 2018 14:58 PM UTC

Is there a datawindow expression that can be used to get the actual row id of a row.  Similar to GetRowIDFromRow function.

 

Follow-up, thanks for every ones ideas.  I was trying to avoid adding a column just to keep track of a specific row.  Reason I want the "Row id" is so I can track or identify a specific row no matter if the datawindow was sorted, filtered, rows added or moved around. So.. looks like I will have to add a column for this.  I can also use this specific row id to manipulate properties of objects just for that row and not effect those same objects on other rows...

Lars Mosegaard Accepted Answer Pending Moderation
  1. Tuesday, 24 April 2018 04:24 AM UTC
  2. PowerBuilder
  3. # 1

getrow()

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Monday, 23 April 2018 22:27 PM UTC
  2. PowerBuilder
  3. # 2

In most cases, you don;t need the actual row ID.
In most cases, the row_id is the same as the Row Number.

When people ask this, it's usually because the row_number abnd row_id are not matching up, and THAT is usually the result of deleting rows from a DW.
It gets worse when people are deleting rows from a DW from within a loop.

Why? because the row numbers change IMMEDIATELY after a row is deleted. If you have to 10 rows and delete row 7, the remaining rows are now 1,2,3,4,5,6,7,8,9. Row 8 becomes row 7, row 9 becomes row 8, and row 10 becomes row 9.

 

Whenever you delete rows in a loop be sure to do so in reverse row order. Example:

FOR ll_row = ll_rowcount to 1 STEP -1

   ll_rc = dw_1.DeleteRow (ll_row)

NEXT
 

 

Later -

Olan

Comment
There are no comments made yet.
Matthew Balent Accepted Answer Pending Moderation
  1. Monday, 23 April 2018 11:37 AM UTC
  2. PowerBuilder
  3. # 3

What do you mean by 'actual row id'?  If this is just the row number within the results set in a dw you can use the previous answers given.  If you mean an internal identity type column then you need to retrieve that with your other data from the database.

Comment
There are no comments made yet.
Luiz Ribeiro Accepted Answer Pending Moderation
  1. Friday, 20 April 2018 19:10 PM UTC
  2. PowerBuilder
  3. # 4

Hi David.

 

Try this:

 

1- Create a dummy column in the datawindow (e.g. "Select 0 as c_rowid");

2- Place the code below on the RetrieveRow datawindow event:

This.Object.c_rowid[row] = This.GetRowIDFromRow(row)

 

Regards,

 

Luiz

Comment
There are no comments made yet.
Alfredo Aldama Accepted Answer Pending Moderation
  1. Friday, 20 April 2018 16:52 PM UTC
  2. PowerBuilder
  3. # 5

Hi,

I hope this help you.

Some code

long ll_Row

Any value

ll_Row = dw_name.GetRow()

now you can use ll_Row

dw_name.DeleteRow(ll_Row) 

value = dw_name.object.col_name[index]

Inside of datawindows on a compute field

getrow()

 

Comment
  1. Alfredo Aldama
  2. Friday, 20 April 2018 21:35 PM UTC
Global var



   datawindow dw_global



create global Function 



gf_GetRowIdFromRow ( Arg1 Row)   //Argument Row



return dw_global.GetRowIdFromRow(row) 



In a compute 



gf_GetRowIdFromRow( getrow()) 



Regards !

  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.