[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Corrupt Index Delphi 4/Paradox7

Posted on 2001-06-21
2
Medium Priority
?
1,002 Views
Last Modified: 2007-12-19
Hi,

   To set the scene, I have a DBgrid and input fields below the source is an SQL Query object. The grid/input is SQL based to allow reselection according to criteria etc. This one screen therefore supplies enquiry,insert and update facility over one table.

My problem is that on rare occasions the underlying table is reporting a corrupted index but I can never reproduce it.

I'm pretty sure that I've written the application in such a way that it wont leave an update half way through etc

I have observed the accumulation of _QSQ?.DB files, these I presume to be temporary files created for the SQL view?
Generally these files vanish as the application is closed but this is not always happening. On one occasion I was informed that a power cut had occured - at least six records prior to the cut had not been recorded and on restarting the system the index was corrupt, I can understand why an index corruption may have ocurred here but why the missing data?

 So to ask specifics:

1) Can anyone tell me what _QSQ.DB files are?

2) When using an SQL Query object to update a data file is the data cached or written directly to disk (I have CachedUpdates=False). How can I ensure it is written straight to disk?

3) Is it best practice to explicitly open and close tables/Queries at application start/finish. Delphi always seems to handle this for me, I think :)

4) what is the most likely cause of Index corruption? I presume an uncompleted update.

5) Is it just me :)

Thanks Folks,

Regards,


        Ralph.
0
Comment
Question by:RalphPorter
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
nnbbb09 earned 600 total points
ID: 6215370
Ralphm

No it's not just you. The BDE can be a real pain sometimes. We've had the same problem with updates not being committed after a post, so if the application terminates abnormally then a batch of records would go missing.

1. The QSQ tables are temporary bde tables creating when running sql statements. These should be placed in the BDE private directory and deleted when the session is closed.

2. Check your LOCAL SHARE property in BDE administrator and ensure it is set to true. This seemed to cure the problem with records going missing).

3. I always explicitly open/close tables/queries as and when they are needed. Although Delphi should close the connection as the object is freed.

4. I think the most likely cause of index corruption is abnormal termination of the application. At least that's what it seems like to me.

This is a procedure that I found on the web that allows you to set various BDE parameter values.

Call it like this to set LOCALSHARE to true everytime the application starts up

SetBDEParameter('\SYSTEM\INIT\;LOCAL SHARE','TRUE');


procedure SetBDEParameter(Param: string; Value: string);
var
  hCfg: hDBICfg;
  Config: SYSConfig;
  Path, Option: string;
  ParamCount, I: word;
  pFields, pFld: pFLDDesc;
  pRecBuf, pRec: pBYTE;
  Found, SelfInitialized: boolean;
  rslt: DBIResult;

begin

  {$Ifdef WIN32}

  hCfg := nil; pFld := nil; pRec := nil; Found := False; SelfInitialized := False;
  try
    if Pos(';', Param) = 0 then
      raise EDatabaseError.Create('Invalid parameter passed to function.  There must ' +
         'be a semi-colon delimited sting passed');
    Path := Copy(Param, 0, Pos(';', Param) - 1);
    Option := Copy(Param, Pos(';', Param) + 1, Length(Param) - Pos(';', Param));
    rslt := DbiGetSysConfig(Config);

    if rslt <> DBIERR_NONE then
    begin
      if rslt = DBIERR_NOTINITIALIZED  then // Engine not initialized error...
      begin
        SelfInitialized := True;
        DbiInit(nil);
        Check(DbiGetSysConfig(Config));
      end
      else
        Check(rslt);
    end;

    Check(DbiOpenConfigFile(Config.szIniFile, FALSE, hCfg));
    Check(DbiCfgGetRecord(hCfg, PChar(Path), ParamCount, nil, nil));

    pFields := AllocMem(ParamCount * sizeof(FLDDesc));
    pFld := pFields;
    pRecBuf := AllocMem(10000);
    pRec := pRecBuf;

    { Get the node values... }

    Check(DbiCfgGetRecord(hCfg, PChar(Path), ParamCount, pFields, pRecBuf));

    for I := 0 to ParamCount - 1 do
    begin
      if pFields^.szName = Option then
      begin
        StrPCopy(PChar(pRecBuf), Value);
        Check(DbiCfgModifyRecord(hCfg,  PChar(Path), ParamCount, pFld, pRec));
        Found := True;
      end;

      Inc(pFields);
      Inc(pRecBuf, 128);
    end;

    if Found = False then
      raise EDatabaseError.Create(Param + ' entry was not found in configuration file');

  finally
    if pFld <> nil then
      FreeMem(pFld);
    if pRec <> nil then
      FreeMem(pRec);

    if hCfg <> nil then
    Check(DbiCloseConfigFile(hCfg, TRUE, TRUE, FALSE));

    if SelfInitialized = True then
      DbiExit;
  end;

  {$Else}
     raise EDatabaseError.Create('Non supported function in 16 bit');
  {$EndIf}

end;

p.s. the Borland community site seems to have a lot of tips on getting the best out of the BDE. http://community.borland.com

regards

Jo
0
 

Author Comment

by:RalphPorter
ID: 6228036
Hi Jo,

     Sorry for the delay, I couldn't seem to get on the server for some reason. Anyway thanks for the informative answer I have taken your advice and now of course I must wait to see if the problem is resolved or not. Thanks again.

Best Regards,

        Ralph.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

656 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