Page 1 of 1

PostgreSQL prepared Query bug

Posted: Mon 19 Jan 2009 13:02
by rant801601
Below code is not working only first record is inserted.
When you remove Prepare then all records are saved.

Testing with PostgreSQL 8.3 and Delphi 2007

1. Table definition:

CREATE TABLE test
(
id integer NOT NULL,
name varchar(40),
uptime timestamp,
userno smallint,
CONSTRAINT test_pk PRIMARY KEY (id)
)

2. Delphi procedure:

procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
t: cardinal;
begin
UniConnection1.Open;

UniConnection1.ExecSQL('delete from test', []);

UniQuery1.Prepare;

t := GetTickCount;

for I := 1 to 100 do
begin
UniQuery1.Params[0].Value := i;
UniQuery1.Params[1].Value := 'test' + IntToStr(i);
UniQuery1.Params[2].Value := Now;
UniQuery1.Params[3].Value := 1;
UniQuery1.Execute;
end;
if UniQuery1.Prepared then
UniQuery1.UnPrepare;

ShowMessage(FormatFloat('0', GetTickCount - t));
end;

Posted: Mon 19 Jan 2009 13:08
by Plash
We have fixed this problem. The fix will be included in the next build of UniDAC.