Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 17 MAY 2000 08:43:00PM Phil Helton wrote:

I have defined two tables that will carry similar data. I want to copy the data from one table to the other (then I will modify the data in the second table through the forms). What are the procedures to copy data from one table to another?


At 18 MAY 2000 06:45AM Oystein Reigem wrote:

Phil,

You say "similar", not "identical". Does that mean the two tables have somewhat different sets of fields?

Identical:

If they are identical you can run the Copy_Table subroutine from the System Editor Exec line or call Copy_Table from a program.

Since the destination table already exists you can also run the Copy_Row routine from Sys Ed Exec line. If you set the scrkeylist parameter to "*" all rows will be copied.

You can also make your own program with a select statement and a readnext/read/write loop where you copy one row at a time.

Not identical:

If the two tables are not identical use the latter method. In the loop, after you read a row into a variable (often the @Record system variable is used), you can extract the fields you need to copy, assemble them into a new row, and write the result to the destination table.

If you program it yourself like this you've got a lot of freedom. Not only does it allow you to copy a subset of fields. You can also have the fields in a different order in the destination table. Furthermore you can change the content of the fields, and insert data for fields that only occur in the destination table. Based on the content of fields you can filter away rows you don't want copied to the destination table. Also you have more control over errors that might occur. E,g, check the @File.error system variable for errors after each readnext, read and write.

If you for some reason need to copy the rows in a certain order, use "select … by" and "readnext … by" instead of select and readnext.

- Oystein -

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/02f3b447d5d15a74852568e30003efdd.txt
  • Last modified: 2023/12/30 11:57
  • by 127.0.0.1