Reuse of temp-table rowids

Posted by Darren Parr on 25-Apr-2013 09:20

Hi

I'm sure there is a parameter for preventing reuse of temp-table rowid values but I can't find it. We have several routines which monitor temp-table usage by storing the rowid of a particular temp-table record in another temp-table. We're finding that under 11.2 that s delettion of a temp-table record and a creation mof a different temp-table record results in the same rowid being reissued.

This didnt happen with 10.2B?

Any ideas?

Thanks


Darren

All Replies

Posted by Admin on 25-Apr-2013 09:28

Haven't heard of such a parameter.

But as temp-tables reside in a local temp-table database (dbi file), my guess is that similar rules apply as with database tables. So ROWID's are expected to be reused. And when passing temp-tables from AppServer to client, ROWID's change as well.

Posted by Darren Parr on 25-Apr-2013 09:50

Hi

Thanks Mike. I'll take a look at how we might change this.

Posted by Peter Judge on 25-Apr-2013 10:23

Thanks Mike. I'll take a look at how we might change this.

>

The approach AutoEdge uses is at http://communities.progress.com/pcom/docs/DOC-105097 .

The TL:DR version is to use the unique indexes on the temp-tables to construct a key that's unique independently of the rowids. For comparison, the OE Mobile JSDO also creates a unique ID (each table gets an _id field) and in that case it's a number. However, that value has no meaning on the server side, so this may not be an appropriate approach if you care about this across an AppServer.

-- peter

Posted by gus on 26-Apr-2013 09:36

There is no such parameter. Never has been.

You cannot control the assignment of rowids and you cannot predict them either.

A rowid is an encoding of the storage location occupied by a row, along with the id of the storage area where it lives. When you create a row and it is sent to the database or a local temporary table, a rowid is assigned as a side-effect of allocating space to store the row. The storage manager determines where to store the row based on a variety of factors and conditions. The rowid is the result of this allocation operation.

Once created and stored, a row's rowid will not change. When you delete a row, the place where it was stored can later be used to store a different row.

From the standpoint of the application, you should treat rowids as random numbers.

Note that rows from different tables can sometimes have the same rowid. In multitenant environments, sometimes you will have the same rowid for rows in the same table but owned by different tenants.

Posted by Darren Parr on 26-Apr-2013 10:39

Hi

Thanks to everyone. I guess I was probably confusing this with another parameter I'd seen before.

I guess the only potential solution to our problem is when we go to an OO ABL. Who knows how that might look but I might be able to override the rowid function on a temp-table to provide myself with a way of dealing with it.

Thanks


Darren

Posted by gus on 26-Apr-2013 10:43

what's the actual problem you need to solve?

Posted by Peter Judge on 26-Apr-2013 10:48

I guess the only potential solution to our problem is when we go to an OO

ABL. Who knows how that might look but I might be able to override the

rowid function on a temp-table to provide myself with a way of dealing

with it.

Even in OOABL there is no way to override the ROWID function on a temp-table itself (TTs and datasets are no different in the OOABL). You will need to resolve this yourself in P code or CLS code.

-- peter

Posted by Thomas Mercer-Hursh on 26-Apr-2013 10:56

What kind of monitoring are you doing?   Do you just need to know if the TT has changed since last access?  I would think there were better ways to monitor that than ROWID.

Posted by Admin on 26-Apr-2013 11:13

A GUID field in every record might be an easier solution.

Posted by gus on 26-Apr-2013 12:33

>A GUID field in every record might be an easier solution.

>

>

solution to what?

Posted by Admin on 26-Apr-2013 12:38

The initial request?

"storing the rowid of a particular temp-table record in another temp-table"

ROWID's are problematic. OO does not provide the solution he's assuming. Keep it simple, use a GUID as a record identifier.

Posted by Thomas Mercer-Hursh on 26-Apr-2013 12:39

solution to what?

To a problem which may or may not be the problem which the OP was trying to solve?

I would guess that Mike is guessing that the OP needed to know whether the row had changed and I'm guessing that the issue is knowing whether the table has changed.

Posted by gus on 26-Apr-2013 13:48

sorry Mike, but "storing the rowid of a particular temp-table record in

another temp-table" is not a problem. it is the OP's solution to some as

yet unstated problem.

I would like to know what that problem is. then we can see if we can come

up with a more suitable solution.

Posted by Darren Parr on 29-Apr-2013 10:03

Hi

Its a old system that predates adm1 but which is distributed.

We have a temp-table called ttData which has a raw field in it which is used to hold other temp-tables. Multiples of different temp-tables are copied from client to server using this method. So we can pass any amount of data in this way.

Obviously this is before PDS's even existed.

So on the client and server we have a degree of unmarshalling of data. The temp-table is transferred into ttData records. Once unmarshalled we keep track of the exact temp-table record by storing the temp-table rowid in ttData.ttRowID.

So when populating the data back for trsnaport we can put it back into ttData. We have some issues with the rowids being reused which messes things up.

I don't like this but its in several thousand programs. It would have been nice if rowids could have been made unique but a colleague has got around it by addressing the possibility of not being unique and coding for it.

Thanks

Darren

Posted by gus on 30-Apr-2013 08:52

one way to do this is to have a column which is a unique key in the table.

another is to continue to use rowid as part of the key but add something else to the upper bits (which are going to be zeros in temporary tables). a simple counter in a global variable might suffice.

Posted by Admin on 30-Apr-2013 09:05

one way to do this is to have a column which is a unique key in the table.

Hence my suggestion to use a GUID.

This thread is closed