Problem with to long Values for a Param and prepared Statements
Posted: Thu 12 Jul 2012 12:44
Hello,
ich have a problem with IBDAC 4.0.2 (also in 3.5.0) and Delphi xe2/2009.
I have a Firebird-table with char(10) field. I try a select with this field in my where-clause. The value has more than 10 chars, the value is '1234567890123' and I have a row in my table, with the value '1234567890'. If I open my query unprepared, the query don't find this row (recordcount = 0). If I open the query prepared i find the row.
A different behaviour is very bad in this case.
An excample:
My Table:
CREATE TABLE TEST (
TEXT CHAR(10) NOT NULL,
constraint PK_TEST primary key (TEXT))
My Source:
procedure TForm1.Button1Click(Sender: TObject);
var
Dataset: Tibcquery;
Value: string;
begin
Dataset := TIBCQuery.Create(nil);
Dataset.sql.Text := 'Select * from TEST where TEXT = :TEXT';
Dataset.Options.CacheBlobs := false;
Dataset.Options.DescribeParams := true;
Dataset.Prepare;
Value := '1234567890123';
Dataset.parambyname('TEXT').Value := Value;
Dataset.open;
caption := inttostr(Dataset.recordcount);
Dataset.Append;
Dataset.fieldbyname('TEXT').Value := Value;
Dataset.Post;
Dataset.close;
Dataset.UnPrepare;
Dataset.Free;
end;
Execute this, it will append a line to the table. With the Next klick, the recordcount is 1 after the open, after that it is 2. Then comment the prepare/unprepare-lines out and run it again, the recordcount ist 0, every time.
Is there in 4.2 still the same behaviour? Is it volitional?
Regards Jan
ich have a problem with IBDAC 4.0.2 (also in 3.5.0) and Delphi xe2/2009.
I have a Firebird-table with char(10) field. I try a select with this field in my where-clause. The value has more than 10 chars, the value is '1234567890123' and I have a row in my table, with the value '1234567890'. If I open my query unprepared, the query don't find this row (recordcount = 0). If I open the query prepared i find the row.
A different behaviour is very bad in this case.
An excample:
My Table:
CREATE TABLE TEST (
TEXT CHAR(10) NOT NULL,
constraint PK_TEST primary key (TEXT))
My Source:
procedure TForm1.Button1Click(Sender: TObject);
var
Dataset: Tibcquery;
Value: string;
begin
Dataset := TIBCQuery.Create(nil);
Dataset.sql.Text := 'Select * from TEST where TEXT = :TEXT';
Dataset.Options.CacheBlobs := false;
Dataset.Options.DescribeParams := true;
Dataset.Prepare;
Value := '1234567890123';
Dataset.parambyname('TEXT').Value := Value;
Dataset.open;
caption := inttostr(Dataset.recordcount);
Dataset.Append;
Dataset.fieldbyname('TEXT').Value := Value;
Dataset.Post;
Dataset.close;
Dataset.UnPrepare;
Dataset.Free;
end;
Execute this, it will append a line to the table. With the Next klick, the recordcount is 1 after the open, after that it is 2. Then comment the prepare/unprepare-lines out and run it again, the recordcount ist 0, every time.
Is there in 4.2 still the same behaviour? Is it volitional?
Regards Jan