INSERT can be executed with open?

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
dust258
Posts: 2
Joined: Wed 19 Jan 2011 08:31

INSERT can be executed with open?

Post by dust258 » Wed 19 Jan 2011 08:51

Hi,

I'm working on a small module in my application, witch enables the user to edit SQL-Statements (only SELECT).

When TIBCQuery.open is called, the resulting list is displayed in a TDBGrid.
The problem is, that the user can use INSERT or UPDATE-Statements to manipulate the Data.

After the call of an INSERT-Statement (with open), an exception is raised (no Data in the Database).
But with the next Execute-Statement (witch I call in the on-close of the Form), the failed INSERT-Statements also gets executed (and the Data inserted into the Database).

EDIT: I'm workin with Delphi 2007 and Version 6.90.0.60

dust258
Posts: 2
Joined: Wed 19 Jan 2011 08:31

Post by dust258 » Wed 19 Jan 2011 09:10

Hmmm, found something:

Code: Select all

  try
    query.Open;
  except
    on e : Exception do
    begin
      query.Transaction.Rollback;
      MessageDLG(e.Message,mtError,[mbOK],0);
    end;
  end;
This fixes my problem, but is there an option for this?

AndreyZ

Post by AndreyZ » Wed 19 Jan 2011 14:32

Hello,

You shouldn't execute Insert statements using the Open method. If you want to execute Insert, Update, and Select statements in the same way, you should use the Execute method. If SQL statement is a query, Execute calls the Open method.

AndreyZ

Post by AndreyZ » Wed 19 Jan 2011 14:33

We will fix the problem with active transaction in one of the next builds.

Post Reply