+ Fix for ftLargeInt fields from Jesus Reyes

git-svn-id: trunk@4000 -
This commit is contained in:
joost 2006-06-29 20:01:52 +00:00
parent 3b6b7a5973
commit 8341107c90
3 changed files with 55 additions and 8 deletions

View File

@ -257,6 +257,7 @@ begin
ftBoolean : result := sizeof(wordbool); ftBoolean : result := sizeof(wordbool);
ftBCD : result := sizeof(currency); ftBCD : result := sizeof(currency);
ftFloat : result := sizeof(double); ftFloat : result := sizeof(double);
ftLargeInt : result := sizeof(largeint);
ftTime, ftTime,
ftDate, ftDate,
ftDateTime : result := sizeof(TDateTime) ftDateTime : result := sizeof(TDateTime)

View File

@ -9,7 +9,7 @@
# * odbc # * odbc
# * postgresql # * postgresql
type=interbase type=oracle
# name # name
# gives the name of the database that should be used. # gives the name of the database that should be used.
@ -17,7 +17,7 @@ type=interbase
# used. More information about how to create a dabatase can be find in the # used. More information about how to create a dabatase can be find in the
# documentation of the database-engine. # documentation of the database-engine.
name=/opt/firebird/examples/employee.fdb name=//192.168.3.1/xe
# user # user
# name is the name of a user which must have all rights on the selected # name is the name of a user which must have all rights on the selected
@ -26,11 +26,12 @@ name=/opt/firebird/examples/employee.fdb
# How to set up users and their rights can be found in the database-engine # How to set up users and their rights can be found in the database-engine
# documentation. # documentation.
user=sysdba user=system
# password # password
# password is the password of the provided user. If the password is incorrect, # password is the password of the provided user. If the password is incorrect,
# all or one of the test could fail. # all or one of the test could fail.
password=masterkey password=rosivrepus
hostname=

View File

@ -75,6 +75,8 @@ type
implementation implementation
uses math;
ResourceString ResourceString
SErrEnvCreateFailed = 'The creation of an Oracle environment failed.'; SErrEnvCreateFailed = 'The creation of an Oracle environment failed.';
SErrHandleAllocFailed = 'The allocation of the error handle failed.'; SErrHandleAllocFailed = 'The allocation of the error handle failed.';
@ -349,12 +351,23 @@ begin
FieldType := ftFloat; FieldType := ftFloat;
OFieldType := SQLT_FLT; OFieldType := SQLT_FLT;
OFieldSize:=sizeof(double); OFieldSize:=sizeof(double);
end; end
else if (oscale <=4) and (OPrecision<=12) then
begin
FieldType := ftBCD;
FieldSize := sizeof(Currency);
OFieldType := SQLT_VNU;
OFieldSize:= 22;
end
else FieldType := ftUnknown;
end; end;
OCI_TYPECODE_CHAR, OCI_TYPECODE_CHAR,
OCI_TYPECODE_VARCHAR, OCI_TYPECODE_VARCHAR,
OCI_TYPECODE_VARCHAR2 : begin FieldType := ftString; inc(OFieldsize) ;FieldSize := OFieldSize; OFieldType:=SQLT_STR end; OCI_TYPECODE_VARCHAR2 : begin FieldType := ftString; FieldSize := OFieldSize; inc(OFieldsize) ;OFieldType:=SQLT_STR end;
OCI_TYPECODE_DATE : FieldType := ftDate; OCI_TYPECODE_DATE : FieldType := ftDate;
OCI_TYPECODE_TIMESTAMP,
OCI_TYPECODE_TIMESTAMP_LTZ,
OCI_TYPECODE_TIMESTAMP_TZ : FieldType := ftDateTime;
else else
FieldType := ftUnknown; FieldType := ftUnknown;
end; end;
@ -394,8 +407,14 @@ end;
function TOracleConnection.LoadField(cursor: TSQLCursor; FieldDef: TFieldDef; buffer: pointer): boolean; function TOracleConnection.LoadField(cursor: TSQLCursor; FieldDef: TFieldDef; buffer: pointer): boolean;
var dt : TDateTime; var dt : TDateTime;
b : pbyte; b : pbyte;
size,i : byte;
exp : shortint;
cur : Currency;
ts : TTimeStamp;
dattim : ^TDateTime;
begin begin
with cursor as TOracleCursor do if fieldbuffers[FieldDef.FieldNo-1].ind = -1 then with cursor as TOracleCursor do if fieldbuffers[FieldDef.FieldNo-1].ind = -1 then
@ -405,6 +424,25 @@ begin
result := True; result := True;
case FieldDef.DataType of case FieldDef.DataType of
ftString : move(fieldbuffers[FieldDef.FieldNo-1].buffer^,buffer^,FieldDef.Size); ftString : move(fieldbuffers[FieldDef.FieldNo-1].buffer^,buffer^,FieldDef.Size);
ftBCD : begin
b := fieldbuffers[FieldDef.FieldNo-1].buffer;
size := b[0];
cur := 0;
if (b[1] and $80)=$80 then // then the number is positive
begin
exp := (b[1] and $7f)-65;
for i := 2 to size do
cur := cur + (b[i]-1) * intpower(100,-(i-2)+exp);
end
else
begin
exp := (not(b[1]) and $7f)-65;
for i := 2 to size-1 do
cur := cur + (101-b[i]) * intpower(100,-(i-2)+exp);
cur := -cur;
end;
move(cur,buffer^,FieldDef.Size);
end;
ftFloat : move(fieldbuffers[FieldDef.FieldNo-1].buffer^,buffer^,sizeof(double)); ftFloat : move(fieldbuffers[FieldDef.FieldNo-1].buffer^,buffer^,sizeof(double));
ftInteger : move(fieldbuffers[FieldDef.FieldNo-1].buffer^,buffer^,sizeof(integer)); ftInteger : move(fieldbuffers[FieldDef.FieldNo-1].buffer^,buffer^,sizeof(integer));
ftDate : begin ftDate : begin
@ -412,6 +450,13 @@ begin
dt := EncodeDate((b[0]-100)*100+(b[1]-100),b[2],b[3]); dt := EncodeDate((b[0]-100)*100+(b[1]-100),b[2],b[3]);
move(dt,buffer^,sizeof(dt)); move(dt,buffer^,sizeof(dt));
end; end;
ftDateTime : begin
dattim := fieldbuffers[FieldDef.FieldNo-1].buffer;
// dt := EncodeDate((b[0]-100)*100+(b[1]-100),b[2],b[3]);
// dt := ComposeDateTime(EncodeDate((b[0]-100)*100+(b[1]-100),b[2],b[3]), EncodeTime(b[4],b[5],b[6],0));
move(dt,buffer^,sizeof(dt));
end;
else else
Result := False; Result := False;