Matching temp table ROWID to database ROWID

Romasio

New Member
Hello everyone :) Could not find an answer anywhere, so....

THE SITUATION: Having query and using it to populate records to temp table. Query results are shown in BROWSE. Managed to figure out that
ROWID of records in temp table DIFFER from those in the database. That's my hurdle.

QUESTIONS:
  1. When I want to delete an actual record in database selecting that record in the BROWSE, HOW? Could do that if ROWIDs were the same on both tables... but they aren't!
  2. How do I go about moving temp table records to database table after I have done working with them? I mean MOVING and not COPYING to avoid duplicate records etc... If it is even possible.. :confused:

I hope you understand my problem, would appreciate some help soon.
Thanks in advance :rolleyes:
 
What version of Progress are you on?

If it's 10 something then try using prodatasets.
Especially look at before-table, datasource and save-row-changes.

In earlier versions it is more difficult to handle things like deletion of a temp-table and committing that to the database. (but offcource, not impossible ), normal changes are easy to deal with as long as you make sure each temp-table record also holds the key values for the corresponding tables. (assuming there is a 1 to 1 relationship with the temp-table and the database table).

BTW ROWID is a unique identifier for a record. If it's a record from a database table then it corresponds to the physical location of that record in the database if it is a temp-table record then it is a unique identifier for that temp-table record. That' s why the rowids differ.

Regards,

Casper.
 
Thanks Casper for quick reply.

I am using version 10.C and will look into ProDataSets in the morning :)

What did you mean by "key values for the corresponding tables"? Both temp table and database tables are identical, if that is what you meant.

Now suppose both tables DO NOT have unique fields, there can be identical records on any of the tables. And then we have BROWSE with results of some query with certain WHERE criteria. Now, what I would like is to be able select one row in the BROWSE and press "Delete" BUTTON to remove record from actual database table. Then refresh and see BROWSE without that particular record.

So my initial problem was how to associate records from temp table with those in database? Suppose changing table structure and ProDataSets is not an option :)

What version of Progress are you on?

If it's 10 something then try using prodatasets.
Especially look at before-table, datasource and save-row-changes.

In earlier versions it is more difficult to handle things like deletion of a temp-table and committing that to the database. (but offcource, not impossible ), normal changes are easy to deal with as long as you make sure each temp-table record also holds the key values for the corresponding tables. (assuming there is a 1 to 1 relationship with the temp-table and the database table).

BTW ROWID is a unique identifier for a record. If it's a record from a database table then it corresponds to the physical location of that record in the database if it is a temp-table record then it is a unique identifier for that temp-table record. That' s why the rowids differ.

Regards,

Casper.
 
Now I have an idea... I think one of the possible ways is to add extra field to the temp-table saving ROWID of the actual record in database when copying rows to the temp-table. This way it would be possible to actually know what to delete and what to update given ROWID. What do you think of that? :awink:

Suppose we have such temp-table and want to edit a record in the database using procedure in AppServer. Best way would be to pass temp-table or just ROWID of the record? What if we want to edit multiple records?

I am not yet sure how temp-tables are better than working directly with the database, an example would help ;) Thanks.
 
Hi,
I hope your idea seems to be nice man... :awink:

One small concern is that why can't you prefer buffer in this case. If the case is that the query is the main concern then probably you can still use BUFFER for this;

Syntax: (Progress Help)
-------
DEFINE [ [ NEW ] SHARED ] BUFFER buffer FOR table
[ PRESELECT ] [ LABEL label ]
So still you can use PRESELECT option. Correct me if i am wrong.

Can Casper or someone else provide some update on this thread if they have any concerns?

Thanks in advance.
 
I always do updates on the db, based on a temp-table, exactly the way Romasio suggested. You create a temp-table with, in my case, 2 extra columns. One with the original ROWID of the database (and you just update the db using FIND-BY-ROWID) and one column with a logical value, meaning that you modified the record in the temptable. The latter is for performance issues, when you intent to copy large resultsets into the temptable but only wish to modify a small amount of the records.

Moving the records is done with a loop through the temptable, deciding if the record is modified, finding the original record, modify the original record and then deleting the record from the temptable.
 
What do you do if you create or delete a record?

By using prodatasets it's very easy to handle these kinds of actions.

Casper

BTW palthe nice town: Groningen, I was born there :)
 
Very late reply :biggrin:, but you said it yourself: prodatasets are available in 10+ and most of our clients are still on ancient 9.1E.
So the find-by-rowid is a very handy way to modify the databasebuffer (also the deletion of records. Creating has never been a problem with inserting into browse and a corresponding buffer-create).

Prodatasets are definitely the way to go if you do not have to worry about compatibility issues.

I love Groningen by the way, lived here for over 12 years now!
 
Back
Top