Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

COPY_TABLE

I am trying to utilise the copy_table command to programatically take a temporary backup of a table before I do some data manipulations.
This task would be re-run at a timeframe I determine so I am interested in overwriting the destination next time once it exists.

The main command is obviously this:
Copy_Table(TableName, "", "", BackupTableName, 0, 0, 1, 0, ErrRV, 0) ; // Overwrite and let it ake details from source

There are other commands to attach the BackupTableName once created to be able to access. That seems to work fine on the first run.

However, every subsequent run fails. I have seen a few error messages in my playing around but the one most oommon is:
FS146: The "%1%" table already exists.

I am not sure why I keep getting that when I have the overwrite flag set to true.

My expectation, based on the documentation is that it is OK to exist and whatever was there will be replaced.
(If true (1), and a table exists with the same name as newtablename, overwrite it. If the table does not exist, a new one is created.)

I could obviously add code to delete the table first but I didnt expect that to be needed.
Am I missing something simple?

Comments

  • Is it the copy that's failing or the attach?

    Wondering if the first time around, you're
    • copying from source to new.
    • Attaching new.
    Then, running a subsequent time.
    • copying from source to new with overwrite
    • attaching new - fails because it's attached already
  • @AusMarkB

    Its the Copy. I am doing a Set_Status(0) PRE and a Get_Status POST so am not even getting to the Attach on subsequent runs.

    I am actually doing a TABLE_EXISTS check first.
    First Time
    If it doesnt exist it is a Copy_TABLE then Attach and save DB.


    Subsequent
    If it does exists, COPY_TABLE then do a Detach first then Attach/Save DB to make sure the DICT is up to date etc.
Sign In or Register to comment.