 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Roberto Colpani Guest
|
Posted: Fri May 11, 2007 6:27 pm Post subject: FLDDesc30 |
|
|
On my project I have the necessity to work with the datatype of TField that
is of TFieldType Enum.
To get this enum value I have this two procedure:
function TDBXConnection.SetTableSchema(const ATableName: String;
PrevTableSchema: PTableSchema): PTableSchema;
Var
CurrFieldSchema, PrevFieldSchema: PFieldSchema;
Counter: Word;
AFieldDesc: FLDDesc30;
begin
CheckDataSets;
try
try
SQLDataSet.SetSchemaInfo(stColumns, ATableName, '');
ClientDataSet.IndexFieldNames := 'COLUMN_POSITION';
ClientDataSet.Open;
New(Result);
Result^.Next := nil;
if PrevTableSchema <> nil then
PrevTableSchema^.Next := Result;
Result^.FieldsList := nil;
Result^.TableName := ATableName;
Result^.TableAlias := ATableName;
while not(ClientdataSet.Eof) do
begin
if Result^.FieldsList = nil then
begin
New(CurrFieldSchema);
CurrFieldSchema^.Next := nil;
Result^.FieldsList := CurrFieldSchema;
end
else
begin
PrevFieldSchema := CurrFieldSchema;
New(CurrFieldSchema);
CurrFieldSchema^.Next := nil;
PrevFieldSchema^.Next := CurrFieldSchema;
end;
AFieldDesc.iFldNum := ClientDataSet.FieldByName('RECNO').AsInteger;
AFieldDesc.iFldType :=
ClientDataSet.FieldByName('COLUMN_DATATYPE').AsInteger;
AFieldDesc.iSubType :=
ClientDataSet.FieldByName('COLUMN_SUBTYPE').AsInteger;
AFieldDesc.iUnits1 :=
ClientDataSet.FieldByName('COLUMN_PRECISION').AsInteger;
AFieldDesc.iUnits2 :=
ClientDataSet.FieldByName('COLUMN_SCALE').AsInteger;
AFieldDesc.iLen :=
ClientdataSet.FieldByName('COLUMN_LENGTH').AsInteger;
CurrFieldSchema^.FieldName :=
ClientDataSet.FieldByName('COLUMN_NAME').AsString;
CurrFieldSchema^.DataType := Ord(ConvertFieldType(AFieldDesc));
CurrFieldSchema^.DisplayLabel := CurrFieldSchema^.FieldName;
CurrFieldSchema^.DisplayWidth :=
ClientDataSet.FieldByName('COLUMN_LENGTH').AsInteger - 1;
CurrFieldSchema^.Format := '';
CurrFieldSchema^.FieldCase := fcNormal;
CurrFieldSchema^.LookUp := False;
CurrFieldSchema^.LookUpSQL := '';
CurrFieldSchema^.OutPutFields := '';
CurrFieldSchema^.ReferentialIntegrity := False;
CurrFieldSchema^.BlobFormat := bfNone;
CurrFieldSchema^.ProcedureName := '';
CurrFieldSchema^.Visible := True;
CurrFieldSchema^.HelpContext := -1;
ClientDataSet.Next;
end;
Result^.TableLinks := 0;
Result^.Visible := True;
except
on E:Exception do
MessageDlg(E.Message, mtError, [mbOk], 0);
end;
finally
ClientDataSet.Close;
end;
end;
function TDBXConnection.ConvertFieldType(FieldDesc: FLDDesc30): TFieldType;
begin
with FieldDesc do
begin
if iFldType < MAXLOGFLDTYPES then
Result := DataTypeMap[iFldType]
else
Result := ftUnknown;
if iFldType in [fldFMTBCD, fldBCD] then
begin
iUnits2 := Abs(iUnits2);
if iUnits1 < iUnits2 then // iUnits1 indicates Oracle 'usable
decimals'
iUnits1 := iUnits2;
// ftBCD supports only up to 18-4. If Prec > 14 or Scale > 4, make
FMTBcd
if (iUnits1 > (18-4)) or (iUnits2 > 4) then
begin
Result := ftFMTBcd;
iFldType := fldFMTBCD;
if (iUnits1 = 3 and (iUnits2 in [0,38]) then
begin
iUnits1 := 32;
iUnits2 := 8;
end;
if iUnits1 > 32 then
iUnits1 := 32;
end;
end;
case iFldType of
fldZSTRING, fldBYTES, fldVARBYTES, fldRef:
begin
if iUnits1 = 0 then { Ignore MLSLABEL field type on Oracle }
Result := ftUnknown;
end;
fldINT16, fldUINT16:
begin
if iLen <> 2 then
Result := ftUnknown;
end;
fldINT32:
begin
if iSubType = fldstAUTOINC then
begin
Result := ftAutoInc;
end;
end;
fldFLOAT:
begin
if iSubType = fldstMONEY then
Result := ftCurrency;
end;
fldBLOB:
begin
if (iSubType >= fldstMEMO) and (iSubType <= fldstBFILE) then
Result := BlobTypeMap[iSubType];
end;
end;
end;
end;
This work with Delphi 2006. Now with Delphi 2007, the FLDDesc30 structure
there isn't. How can I do? The FLDDesc30 is now FLDDesc40? And if so where
is? |
|
| Back to top |
|
 |
Armando Luiz Dettmer Guest
|
Posted: Sun May 13, 2007 8:16 pm Post subject: Re: FLDDesc30 |
|
|
| Quote: | This work with Delphi 2006. Now with Delphi 2007, the FLDDesc30
structure there isn't. How can I do? The FLDDesc30 is now FLDDesc40?
And if so where is?
|
Hi Roberto.
I'm working in the port of dbExpressPLUS to D2007 and found the FLDDesc
class definition inside SqlExpr unit (\source\database\scr\pas\dbx\vcl).
Note that it's a CLASS not a RECORD.
HIH
-- |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|