Solved

BatchMove Copy

Posted on 1998-06-25
6
422 Views
Last Modified: 2010-04-04
I have been trying to do a Table BatchMove and have been encountering several errors.  If I leave the tables open, I receive an error that the tables are open.  If I close the tables the error complains that the process can't be performed on a closed database.  I've tried combinations closing/opening each table with no results.  How do you get this method to work?
0
Comment
Question by:blakec
  • 3
  • 2
6 Comments
 
LVL 2

Accepted Solution

by:
kjteng earned 50 total points
ID: 1355924
If you are using batCopy mode you should not set the active property of destination table to true at design time. Otherwise the IDE will reserve write rights to the table.
Somewhere in you code (before calling batchMove1.execute) set the active property of the destination table to true.

eg.
procedure TForm1.Button1Click(Sender: TObject);
begin
  table2.active:= true;
  batchMove1.execute
end;
0
 

Author Comment

by:blakec
ID: 1355925
I was attempting to use the BatchMove function, not the procedure.  Since all my tables are created and destroyed at runtime, it doesn't sound as if the IDE write is an issue.

Can I get the BatchMove function to work in Delphi 1, or do I have to create the BatchMove object?  Is there an advantage of using one over the other, other than the number of lines of code to perform the operation?

function BatchMove(ASource: TDataSet; AMode: TBatchMode): Longint;

0
 
LVL 2

Expert Comment

by:kjteng
ID: 1355926
It seems that some other application have reserve the files. Are you running on network?

table2.batchMove( table1, batCopy) works no matter the table1/table2 is active or not. I have just tested it, it works even if table1 is opened with exclusive right. Let me know if you need my test program for batchMove. I would email it to you.

The advantage of TBatchMove is that you have more control on the batchmove operation. eg you can map the fields of source and target table if each of the two tables have different fieldnames.
(where batchmove method copy the fields data based on field number).
Just drop a tBatchMove component to the form and view the object inspector for more information.

Please post you code if you need further help.
I will only  be back on June 28.





0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:blakec
ID: 1355927
The tables used in this program are used only by this program for single instance runs.  There will probably never be a sharing violation because the program is designed to run on non-networked laptops.

In this instance, the tables need to be a carbon copy of each other because they may need to be used interchangably.  Following is the source code causing the problem.  The program GPF's on the BatchMove call and the error varies depending on whether the source/destination tables are open or closed.

function LoadArchiveTbl: bool;
begin
     LoadArchiveTbl := True;

     with PadMod1, FileLstTbl do
     begin

          Active := True;
          RestoreTbl.Active := True;

          try
          if BatchMove(RestoreTbl, batCopy) <> RecordCount then
          begin
               LoadArchiveTbl := False;
               FailMsg(BAT_COPY_ERR);
          end;
          except on E: exception do
             begin
                  MsgOk2(E.Message);
                  LoadArchiveTbl := False;
             end;
          end;
          {RestoreTbl.Active := True;}
     end;
end;

P.S.  I didn't realize I had a BatchMove component.  This is such a cool programming tool. :) Wish I could convince my Microsoft Office.
0
 
LVL 2

Expert Comment

by:kjteng
ID: 1355928
As the code you post is not complete I have made some assumptions to test it:

1. Assume padMod1, FailMsg, MsgOk2 is irrelevant to the subject.
2. since LoadArchiveTbl is not prefixed with form name, I presume fileLstTbl1 is declared as a global variable. Consequently I have to declare FileLstTbl and restoreTbl as a global variable (type ttable) and created them at runtime.
3. I also write an onclick event to call LoadArchiveTbl

Test result: Everything is working fine.

My second test is the more conventional method: create the tow tables at designtime. have I also modified the LoadArchiveTbl function as follows:

function TForm1.LoadArchiveTbl: bool;
begin
  LoadArchiveTbl := True;
  with {PadMod1,} FileLstTbl do
  begin
    Active := True;
    RestoreTbl.Active := True;
    try
     if BatchMove(RestoreTbl, batCopy) <> RecordCount then begin
       LoadArchiveTbl := False;
      { FailMsg(BAT_COPY_ERR);}
     end;
       except on E: exception do
          begin
{               MsgOk2(E.Message);}
               LoadArchiveTbl := False;
          end;
       end;
       {RestoreTbl.Active := True;}
  end;
end;

This test works fine too.

Please check what I assume above is the same as what you did in your program. If you still cannot get it work, try to create a new test program to see whether the batchMove function works. If the same error still come out on you test program (which is very unlikely), I would advise you to reinstall you delphi.

goodluck
0
 
LVL 3

Expert Comment

by:rickpet
ID: 1355929
I would assume that one of our 2 tables are corrupt...try your test on new tables...I would pick one of the tables from Delphi\Demos\Data

Also make sure that you have enough disk space for the operation.

How large are your tables???

What kinda of tables are we using???


Rick
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now