Subject | Re: [IBO] Problem with transactions |
---|---|
Author | slsolutions2002 |
Post date | 2002-02-05T01:19:46Z |
Have discovered problem but don't know why this happens.
The table was created with:
Create Table Test(
TheKey Integer Not Null,
Name Varchar(30);
Commit;
This is a temporary table that I want to empty then fill with names.
To accomplish this I have a TIB_SCRIPT (scrTest) in the program with
the following SQL:
Delete From Test;
After executing the script I assumed the table was empty. However it
always has 1 record.
To elliminate the possibility of some other interaction I created a
new application. On the form I drop a query,transaction, and a
connection. In the forms onshow routine i open the query. in the
onclose routine i close the query. In the query i add sql SELECT *
FROM TEST. I then add 2 buttons. Button1 is:
var i : integer;
begin
for i := 1 to 3
with qrtest do
begin
insert;
fieldbyname('thekey').value := loop;
post;
end;
button1.caption := inttostr(qrtest.recordcount);
end;
Button2 is:
scrTest.Execute;
button2.caption := inttostr(qrtest.recordcount);
This is what happens. I press button1, the caption changes to 3
which is correct. I press button2, the caption changes to 1 which is
incorrect. For some reason 1 record is not being deleted.
The table was created with:
Create Table Test(
TheKey Integer Not Null,
Name Varchar(30);
Commit;
This is a temporary table that I want to empty then fill with names.
To accomplish this I have a TIB_SCRIPT (scrTest) in the program with
the following SQL:
Delete From Test;
After executing the script I assumed the table was empty. However it
always has 1 record.
To elliminate the possibility of some other interaction I created a
new application. On the form I drop a query,transaction, and a
connection. In the forms onshow routine i open the query. in the
onclose routine i close the query. In the query i add sql SELECT *
FROM TEST. I then add 2 buttons. Button1 is:
var i : integer;
begin
for i := 1 to 3
with qrtest do
begin
insert;
fieldbyname('thekey').value := loop;
post;
end;
button1.caption := inttostr(qrtest.recordcount);
end;
Button2 is:
scrTest.Execute;
button2.caption := inttostr(qrtest.recordcount);
This is what happens. I press button1, the caption changes to 3
which is correct. I press button2, the caption changes to 1 which is
incorrect. For some reason 1 record is not being deleted.
--- In IBObjects@y..., Geoff Worboys (TeamIBO) <geoff@t...> wrote:
> > The qrTest table has 1 record in it.
> > Problem is the loop executes twice.
>
> I just did an experiment against RDB$DATABASE (which only ever has
one
> record) using TIB_Query and my duplicate of your code executed just
> once.
>
> I am inclined to think that the problem is probably due to some
other
> event code or control associated with qrTest.
>
> You will need to experiement a little more to discover what is
> happening. Perhaps breakpoints in your other event code (to see
what
> is getting hit) or you may need to put a breakpoint in the .Next
> processing of the query source.
>
> PS. I am guessing that you are using TIB_Query. For most scanning
> operations TIB_Cursor is more efficient.
>
> --
> Geoff Worboys - TeamIBO
> Telesis Computing