Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 3 of 3 total |
WHERE clause with BYTES type |
Thu, May 25 2006 8:09 AM | Permanent Link |
"Davide" | hi,
i'm using BCB5 and DBISAM 4.22 do the WHERE command run well if the compared field is a BYTES type ? for exemple: SELECT idx FROM myTable WHERE field1= :Pfield1 i try also with LIKE command ... field1 is a BYTES type.. the result dataset is always empty Davide. |
Thu, May 25 2006 8:45 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Davide,
<< i'm using BCB5 and DBISAM 4.22 do the WHERE command run well if the compared field is a BYTES type ? for exemple: SELECT idx FROM myTable WHERE field1= :Pfield1 i try also with LIKE command ... field1 is a BYTES type.. the result dataset is always empty >> Are you sure that the values are exactly identical, byte-for-byte, and that the lengths are the same ? If you're using an ftBytes field, then the length of the data that you're assigning to the field must match the field length exactly. Here's an example for a Bytes field with a length of 10: procedure TForm1.PopulateButtonClick(Sender: TObject); var TempBytes: array[0..9] of Byte; I: Integer; begin with DBISAMTable1 do begin Open; Append; for I:=0 to 9 do TempBytes[I]:=I; FieldByName('BytesField').SetData(@TempBytes); Post; Close; end; end; procedure TForm1.QueryButtonClick(Sender: TObject); var TempBytes: Variant; I: Integer; begin with DBISAMQuery1 do begin SQL.Text:='SELECT * FROM BytesTest WHERE BytesField=:BytesParam'; TempBytes:=VarArrayCreate([0,9],varByte); for I:=0 to 9 do TempBytes[I]:=I; with ParamByName('BytesParam') do begin DataType:=ftBytes; Value:=TempBytes; end; Open; end; end; I would also suggest that you might want to look into using just a straight BLOB field instead of a Bytes field. They are easier to deal with, and are variable in length. -- Tim Young Elevate Software www.elevatesoft.com |
Mon, May 29 2006 3:04 AM | Permanent Link |
"Davide" | thanks Tim, next days i'll try..
"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> ha scritto nel messaggio news:6A6F7FAB-071E-4216-8E51-20449A4BFEC7@news.elevatesoft.com... > Davide, > > << i'm using BCB5 and DBISAM 4.22 > do the WHERE command run well if the compared field is a BYTES type ? > > for exemple: > SELECT idx FROM myTable WHERE field1= :Pfield1 > i try also with LIKE command ... > > field1 is a BYTES type.. > the result dataset is always empty >> > > Are you sure that the values are exactly identical, byte-for-byte, and > that the lengths are the same ? If you're using an ftBytes field, then > the length of the data that you're assigning to the field must match the > field length exactly. > > Here's an example for a Bytes field with a length of 10: > > procedure TForm1.PopulateButtonClick(Sender: TObject); > var > TempBytes: array[0..9] of Byte; > I: Integer; > begin > with DBISAMTable1 do > begin > Open; > Append; > for I:=0 to 9 do > TempBytes[I]:=I; > FieldByName('BytesField').SetData(@TempBytes); > Post; > Close; > end; > end; > > procedure TForm1.QueryButtonClick(Sender: TObject); > var > TempBytes: Variant; > I: Integer; > begin > with DBISAMQuery1 do > begin > SQL.Text:='SELECT * FROM BytesTest WHERE BytesField=:BytesParam'; > TempBytes:=VarArrayCreate([0,9],varByte); > for I:=0 to 9 do > TempBytes[I]:=I; > with ParamByName('BytesParam') do > begin > DataType:=ftBytes; > Value:=TempBytes; > end; > Open; > end; > end; > > I would also suggest that you might want to look into using just a > straight BLOB field instead of a Bytes field. They are easier to deal > with, and are variable in length. > > -- > Tim Young > Elevate Software > www.elevatesoft.com > > |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |