Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 19 of 19 total
Thread Table exists routine gives lock exception
Wed, Sep 18 2013 7:35 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Peter


To steal a phrase I like

In theory, there is no difference between theory and practice. But, in practice, there is.

You've already said to Tim that its a complex app so its worth simplifying when its easy and may help.

Roy Lambert
Wed, Sep 18 2013 6:27 PMPermanent Link

Peter Evans

Tim,

>
> Here is what is shown in a ShowMessage command after calling
> GetEngineInfo :-

It would be good to get some feedback on my diagnostic information.
Does it show a problem my end?

Also, is there a diagnostic routine in ElevateDB that I can call?

Regards,
  Peter Evans
Mon, Sep 23 2013 2:38 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Peter,

<< When I use ElevateDB Manager to look at the disk database I sometimes see
in the catalogue the in-memory database.

When I use a low level system tool to look at Windows locking a lock is put
on the disk config file. >>

This is normal - you're still using an on-disk configuration.  An in-memory
database is just that, and no more.  If you want the *configuration*
in-memory, then you need to set the TEDBEngine.ConfigMemory property to
True.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Sep 23 2013 2:40 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Peter,

<< I take your point. However, what I do should in theory work. >>

Not exactly.  If you're constantly dropping the database, then you're
incurring an exclusive database lock on each drop, and that can/will
conflict with a shared database lock by other sessions.  That's why it's not
a good idea to constantly create/drop often-used objects in a shared,
on-disk configuration.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Sep 23 2013 2:42 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Peter,

<< It would be good to get some feedback on my diagnostic information.  Does
it show a problem my end? >>

The support forums are not a primary support method.   If you want same-day
responses and an ongoing dialogue, you'll need to open a support session.

Please see my other response about dropping/creating databases.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Sep 23 2013 2:44 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Peter,

Also, in reference to the dropping/creating - is this a multi-user or
multi-threaded application with multiple sessions trying to concurrently
access the in-memory database ?

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Sep 24 2013 9:20 AMPermanent Link

Peter Evans

On 24/09/2013 4:42 AM, Tim Young [Elevate Software] wrote:
>
> Please see my other response about dropping/creating databases.
>

I decided to try another approach to my problem. Then another, see below.

Approach 1) Change EDBSession1 property KeepConnections to F. For all
databases change property KeepConnection to F.

This approach had the good outcome of no longer getting the error.
Well I thought so until I repeated the steps and got the error, earlier
this time.

Approach 2) Change my table exists routine from an execute to a script.
From the limited tests done so far this approach seems to work.

This is the table exists routine using execute :-

Interface

function TableExists(const ThisDatabase : TEDBDatabase;
                     const ThisTable    : String) : Boolean;

Implementation

function TableExists(const ThisDatabase : TEDBDatabase;
                     const ThisTable    : String) : Boolean;
{This works some of the time}
begin
  Result := False;
  IF ( ThisDatabase.Execute(
         'SELECT * FROM Information.Tables ' +
         'WHERE Name=' + Engine.QuotedSQLStr(ThisTable)
                            )) = 1 THEN
    Result := True;
end;

This is table exists routine using a script :-

Interface

function TableExistsScript(const ThisScript   : TEDBScript;
                           const ThisTable    : String) : Boolean;

Implementation

  TableExistsStr =
      'SCRIPT (IN  TableName VARCHAR,' +
      '        OUT FResult BOOLEAN)' +
      ' BEGIN' +
      '  DECLARE InfoCursor SENSITIVE CURSOR FOR InfoStmt;' +
      '  PREPARE InfoStmt FROM ''SELECT * FROM Information.Tables WHERE
Name=?'';' +
      '  OPEN InfoCursor USING TableName;' +
      '  SET FResult = ROWCOUNT(InfoCursor) > 0;' +
      '  CLOSE InfoCursor;' +
      ' END';

function TableExistsScript(const ThisScript   : TEDBScript;
                           const ThisTable    : String) : Boolean;
begin
  Result := False;
  TRY
    ThisScript.SQL.Clear;
    ThisScript.SQL.Add(TableExistsStr);
    ThisScript.Prepare;
    ThisScript.ParamByName('TableName').AsString := ThisTable;
    ThisScript.ExecScript;

    Result := ThisScript.ParamByName('FResult').AsBoolean;

    ThisScript.UnPrepare;
  EXCEPT
    Result := False;
  END;
end;

So why does the script work but not the execute?

This is probably why my drop table routine (which I have posted to these
newsgroups) based on a execute also does not work!

Regards,
  Peter Evans




Mon, Sep 30 2013 2:51 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Peter,

<< So why does the script work but not the execute? >>

The short answer is that there isn't any difference between an Execute() vs.
a script in terms of locking or anything else.  It's just a coincidence,
probably due to timing, that you're seeing a difference in terms of locking
behavior.

If you want to open a support session and send me a project that reproduces
the issue, I'll be happy to look at it and tell you what's going on.

Tim Young
Elevate Software
www.elevatesoft.com

Thu, Oct 24 2013 1:56 AMPermanent Link

Peter Evans

On 1/10/2013 4:51 AM, Tim Young [Elevate Software] wrote:
> Peter,
>

To close off a problem I was having in Drop a table. Can't find the
thread for that now (perhaps buried in this thread), so here will have
to do.

I was getting a lock error #300 when trying to delete a table.

The situation was when I deleted the last record in a table I wanted, in
some situations, to Drop the table. (I have previously given the code to
Drop a table.)

It has taken me over 8 weeks to find a solution. Hopefully the following
code will help others.

Regards,
  Peter Evans

-----

Before I call the code to Drop the table I call these two methods in the
data module in which the table component lies.

In this order!


  MyDataModule.CloseQueriesTables;
  MyDataModule.UnprepareQueries;


PROCEDURE CloseQueriesTables;

PROCEDURE UnprepareQueries;


PROCEDURE TDataMod1.CloseQueriesTables;
VAR
  iIterate : INTEGER;
BEGIN
  FOR iIterate := 0 TO ComponentCount - 1 DO BEGIN
    {Tables}
    IF (Components[iIterate] IS TEDBTable) THEN BEGIN
      TEDBTable(Components[iIterate]).Close;
    END;
    {Queries}
    IF (Components[iIterate] IS TEDBQuery) THEN BEGIN
      TEDBQuery(Components[iIterate]).Close;
    END;
  END;
END;

PROCEDURE TDataMod1.UnprepareQueries;
VAR
  iIterate : INTEGER;
BEGIN
  FOR iIterate := 0 TO ComponentCount - 1 DO BEGIN
    {Queries}
    IF (Components[iIterate] IS TEDBQuery) THEN BEGIN
      TEDBQuery(Components[iIterate]).Unprepare;
    END;
  END;
END;
« Previous PagePage 2 of 2
Jump to Page:  1 2
Image