'SQL information exception.' when issuing 'Commit;' SQL

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
junior
Posts: 4
Joined: Thu 15 Oct 2009 03:18

'SQL information exception.' when issuing 'Commit;' SQL

Post by junior » Thu 15 Oct 2009 03:33

It's very easy to run into this problem. I have created a simple example to demonstrate this problem. Previously, the same code works with IBX Query, but now it no longer, and I found that the problem is when it comes across 'commit'. I need to run 'commit' inside my database creation script, that's why I encountered this problem. Please nevermind about the last transaction commit in the code, it's only for comparison. Here's the example:

# # #

procedure TForm1.btnWriteClick(Sender: TObject);
begin
// start transaction
if not ibtranMain.Active then
ibtranMain.StartTransaction;

// perform a simple insert here
ibqMain.Close;
ibqMain.SQL.Text := 'insert into testtable (val1, mem) values(:val1, :mem)';
ibqMain.Prepare;

ibqMain.ParamByName('val1').AsString := edContent.Text;
ibqMain.ParamByName('mem').AsMemo := mmWrite.Lines.Text;

ibqMain.ExecSQL;

// test code here, if try to commit it via SQL, exception raised here
ibqMain.SQL.Text := 'commit';
ibqMain.ExecSQL;

// this will work as usual, in this case it's only for illustration purpose, please ignore the upcoming commit.
if ibtranMain.Active then
ibtranMain.Commit;
end;

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Fri 16 Oct 2009 08:58

TIBCQuery does not have a feature for executing special commands like COMMIT.

You should call the Commit method of TIBCTransaction.

junior
Posts: 4
Joined: Thu 15 Oct 2009 03:18

Post by junior » Sat 17 Oct 2009 14:27

I am actually migrating from IBX to IBDAC, and before that I used TIBQuery that could handle commit. In this case, which of the component could handle commit? I need this feature because I run a full script which has a few commits to create a database.

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 19 Oct 2009 07:58

The TIBCScript component can execute COMMIT statements.

Post Reply