Insert multiple times gets optimized away.

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
marcov
Senior Boarder
Senior Boarder
Posts: 95
Joined: 24.06.2010, 09:17

Insert multiple times gets optimized away.

Post by marcov »

I've a TZQuery with the an insert into statement.

I run this 5 times with the same parameters in a for loop, which should result in 5 rows with different autonumbered ids.

However only one or two rows are inserted (and only those commands are visible in sql monitor).

The for loop is a bit braindead

for i:=0 to number-1 do
begin
qry.execsql;
qry.active:=true;
end;

Even if I add some parameter that forces the tuples to be different (I put the loopcounter in some memo) this still happen.

What is the proper way of doing this?
Wild_Pointer
Expert Boarder
Expert Boarder
Posts: 164
Joined: 18.03.2008, 13:03
Contact:

Post by Wild_Pointer »

marcov,

Code: Select all

for i:=0 to number-1 do 
begin 
  qry.execsql; 
end;

should be enough. If you still experience problems try replacing qry.execsql with qry.close; qry.open; commands. It you do only qry.active:=true - only the first time it gets executed as after that qry is active already and no work is done.

Good luck!
Locked