'SQL information exception.' when issuing 'Commit;' SQL
Posted: 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;
# # #
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;