Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread How to programmatically detect temporary tables
Sun, May 31 2009 11:30 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

I've just added repair & optimisation into the app I'm working on. I'm zapping the .olds (that's easy) but I bombed the process a few times in the IDE and I have a slew of temporary tables. I could go through and check each one against Tables in Information but I'm hoping there's a better way.

Roy Lambert
Tue, Jun 2 2009 11:12 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

This is my cleanup code. Can anyone spot anything I've missed that might be dangerous? The idea is to get rid of any junk left in there from optimising or just user sillyness.


procedure DoDBCleanup;
var
sr: TSearchRec;
fNam: string;
fExtn: string;
begin
if FindFirst(HHCommons.DBPath + '*.*', faAnyFile, sr) = 0 then begin
 repeat
  fNam := ExtractFileName(sr.Name);
  fExtn := LowerCase(ExtractFileExt(fNam));
  fNam := Copy(fNam, 1, LastDelimiter('.', fNam) - 1);
  if fExtn = '.old' then DeleteFile(HHCommons.DBPath + sr.Name)
  else if fExtn = LowerCase(dm.TfRSession.LocalTableExtension) then begin
   if dm.DB.Execute('SELECT * FROM Information.Tables') = 0 then begin
    DeleteFile(HHCommons.DBPath + fNam + dm.TfRSession.LocalTableExtension);
    DeleteFile(HHCommons.DBPath + fNam + dm.TfRSession.LocalTableBlobExtension);
    DeleteFile(HHCommons.DBPath + fNam + dm.TfRSession.LocalTableIndexExtension);
   end;
  end else begin
   if (fExtn <> LowerCase(dm.TfRSession.LocalTableExtension)) and
    (fExtn <> LowerCase(dm.TfRSession.LocalTableBlobExtension)) and
    (fExtn <> LowerCase(dm.TfRSession.LocalTableIndexExtension)) and
    (fExtn <> LowerCase(dm.TfRSession.LocalBackupExtension)) and
    (LowerCase(sr.Name) <> LowerCase(dm.TfRSession.LocalCatalogName + dm.TfRSession.LocalCatalogExtension)) and
    (LowerCase(sr.Name) <> LowerCase(dm.TfRSession.LocalCatalogName + dm.TfRSession.LocalLockExtension)) and
    (LowerCase(sr.Name) <> LowerCase(dm.TfRSession.LocalConfigName + dm.TfRSession.LocalExtensionExtension)) and
    (LowerCase(sr.Name) <> LowerCase(dm.TfRSession.LocalConfigName + dm.TfRSession.LocalLockExtension))
    then
    DeleteFile(HHCommons.DBPath + sr.Name);
  end;
 until FindNext(sr) <> 0;
 FindClose(sr);
end;
end;

Roy Lambert
Tue, Jun 2 2009 3:23 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< This is my cleanup code. Can anyone spot anything I've missed that might
be dangerous? The idea is to get rid of any junk left in there from
optimising or just user sillyness. >>

I think you're missing a WHERE clause for your SELECT statement from
Information.Tables.

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Jun 3 2009 2:58 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

>I think you're missing a WHERE clause for your SELECT statement from
>Information.Tables.

Not any more - thanks. The one good point is it failed safe Smiley

Roy Lambert
Image