Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Replication
Tue, Apr 30 2019 2:44 PMPermanent Link

Greg Hallam

Microcalm Solutions Inc

I have the following script preparing updates for replication.  It is all working fine but I notice that I am sending a 900 byte file every minute that is essentially empty.  How can I change my script to only send update files that have records and is this a good idea?

BEGIN
  DECLARE UpdateFile VARCHAR DEFAULT '';

  USE "Office";
  -- create the update file to send to the remote stores

  -- Assign main update file name
  SET UpdateFile = 'Office-' + REPLACE(':', '-', CAST(CURRENT_TIMESTAMP AS VARCHAR));

  EXECUTE IMMEDIATE 'SAVE UPDATES FOR DATABASE "HBS Office"
                    AS "' + UpdateFile + '"
                    TO STORE "Office" TABLES Barcode, CashMaster, CashDetail,
                    ProductInventory, SecDesc, UserAccess, Users, YardAddress';

  -- Copy the main office update file to each store
  EXECUTE IMMEDIATE 'COPY FILE "' + UpdateFile + '.EDBUpd" IN STORE
                    "Office" TO "' + UpdateFile + '.EDBUpd" IN STORE
                    "Boston"';

  EXECUTE IMMEDIATE 'DELETE FILE "' + UpdateFile + '.EDBUpd" FROM STORE "Office"';
END
Tue, Apr 30 2019 3:51 PMPermanent Link

Terry Swiers

add  '  IF NOT EMPTY'  to the end of the save updates statement.

I would also suggest adding code to check to see if the file exists before you attempt to copy and delete it.
Image