Hello,
I'm facing some trouble with raw field's in oracle. I made a simple test case with a raw field with 504 Bytes:
>>>>>>>>>
create table test (r4 RAW(504));
<<<<<<<<<
I want to write some coefficients into the database field with DOA:
>>>>>>>>>
procedure TForm1.Button1Click(Sender: TObject);
var
koeff126: array[0..125] of Single;
I: Integer;
begin
for I := 0 to 126 - 1 do
koeff126[i] := I;
with OracleDataSet1 do
begin
Insert;
WriteKoeff(FieldByName('r4'), koeff126, 126);
Post;
end;
end;
procedure TForm1.WriteKoeff(fld: TField; koeff: array of Single;
nKoeff: Integer);
var
aMS: TMemoryStream;
i: Integer;
s: String;
pB: PByte;
begin
aMS := nil;
try
aMS := TMemoryStream.Create;
// Werte erstmal in Stream speichern
for i := 0 to nKoeff - 1 do
aMS.Write(koeff[i], sizeof(Single));
// aus dem Stream einen HEXADEZIMAL-String erzeugen
s := '';
pB := PByte(aMS.Memory);
for i := 0 to aMS.Size - 1 do
begin
s := s + IntToHex(pB^,2);
Inc (pB);
end;
fld.AsString := s;
finally
if aMS <> nil then FreeAndNil(aMS);
end;
end;
<<<<<<<<<
Running this code the ORA-01480 exception is thrown. Writing to raw fields shouldn't depend on NLS-Settings, but for completness here they are:
>>>>>>>>>
NLS_LANGUAGE GERMAN
NLS_TERRITORY GERMANY
NLS_CURRENCY ?
NLS_ISO_CURRENCY GERMANY
NLS_NUMERIC_CHARACTERS ,.
NLS_CHARACTERSET AL32UTF8
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD.MM.RR
NLS_DATE_LANGUAGE GERMAN
NLS_SORT GERMAN
NLS_TIME_FORMAT HH24:MI:SSXFF
NLS_TIMESTAMP_FORMAT DD.MM.RR HH24:MI:SSXFF
NLS_TIME_TZ_FORMAT HH24:MI:SSXFF TZR
NLS_TIMESTAMP_TZ_FORMAT DD.MM.RR HH24:MI:SSXFF TZR
NLS_DUAL_CURRENCY ?
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_RDBMS_VERSION 11.2.0.1.0
<<<<<<<<<
I'm using Delphi 2006 with DOA 4.1.1. What can i do to write the values to the field?
thanks for your help,
regards Frank