mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-03 11:29:36 +01:00
+ Initial implementation
This commit is contained in:
parent
8d0b0aa3fe
commit
7761b7ac35
174
fcl/db/tested.pp
Normal file
174
fcl/db/tested.pp
Normal file
@ -0,0 +1,174 @@
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1999 by Michael Van Canneyt, member of the
|
||||
Free Pascal development team
|
||||
|
||||
Tests the TDDGDataset component.
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
program testds;
|
||||
|
||||
uses db,ddg_ds,sysutils;
|
||||
|
||||
Procedure Log(Const Msg : String);
|
||||
begin
|
||||
Writeln(Msg);
|
||||
end;
|
||||
|
||||
Procedure DumpFieldDef(F : TfieldDef);
|
||||
|
||||
begin
|
||||
With F do
|
||||
begin
|
||||
Writeln ('Name : ',Name);
|
||||
Writeln ('FieldNo : ',FieldNo);
|
||||
Writeln ('Size : ',Size);
|
||||
Writeln ('FieldClass : ',FieldClass.ClassName);
|
||||
Writeln ('Required : ',required);
|
||||
Writeln ('Precision : ',Precision);
|
||||
Writeln ('DataType : ',FieldTypeNames[DataType]);
|
||||
Writeln ('InternalCalcField : ',Internalcalcfield);
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure DumpField(F : Tfield);
|
||||
|
||||
begin
|
||||
With F do
|
||||
begin
|
||||
writeln ('-------------------------------------');
|
||||
Writeln ('FieldName : ',FieldName);
|
||||
Writeln ('FieldNo : ',FieldNo);
|
||||
Writeln ('Index : ',Index);
|
||||
Writeln ('DataSize : ',DataSize);
|
||||
Writeln ('Size : ',Size);
|
||||
Writeln ('DataType : ',FieldTypeNames[DataType]);
|
||||
Writeln ('Class : ',ClassName);
|
||||
Writeln ('Required : ',required);
|
||||
Writeln ('ReadOnly : ',ReadOnly);
|
||||
Writeln ('Visible : ',Visible);
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure DumpFieldData (F : TField);
|
||||
|
||||
begin
|
||||
With F Do
|
||||
begin
|
||||
Writeln ('Field : ',FieldName);
|
||||
Writeln ('Data type : ',FieldTypeNames[DataType]);
|
||||
Writeln ('As String : ',Asstring);
|
||||
Case Datatype of
|
||||
ftSmallint, ftInteger, ftWord : Writeln ('As longint : ',AsLongint);
|
||||
ftBoolean : Writeln ('As Boolean : ',AsBoolean);
|
||||
ftFloat : Writeln ('As Float : ',AsFloat);
|
||||
ftDate, ftTime, ftDateTime : Writeln ('As DateTime : ',DateTimeToStr(AsDateTime));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
Var
|
||||
Data : TDDGdataset;
|
||||
I,Count : longint;
|
||||
Bookie : TBookMarkStr;
|
||||
|
||||
Procedure ScrollForward;
|
||||
|
||||
begin
|
||||
Writeln ('Browsing Forward:');
|
||||
Writeln ('------------------');
|
||||
With Data do
|
||||
While NOT EOF do
|
||||
begin
|
||||
Writeln ('================================================');
|
||||
For I:=0 to FieldCount-1 do
|
||||
DumpFieldData(Fields[I]);
|
||||
Next;
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure ScrollBackWard;
|
||||
|
||||
begin
|
||||
Writeln ('Browsing Backward:');
|
||||
Writeln ('-------------------');
|
||||
With Data do
|
||||
While NOT BOF do
|
||||
begin
|
||||
For I:=0 to FieldCount-1 do
|
||||
DumpFieldData(Fields[I]);
|
||||
Prior;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
if paramcount<>1 then
|
||||
begin
|
||||
Writeln ('Usage : testds tablename');
|
||||
Halt(1);
|
||||
end;
|
||||
Log ('Creating Dataset');
|
||||
Data:=TDDGDataset.Create(Nil);
|
||||
With Data do
|
||||
begin
|
||||
Log('Setting Tablename');
|
||||
TableName:=Paramstr(1);
|
||||
Log('Opening Dataset');
|
||||
Open;
|
||||
Log('Dumping fielddefs : ');
|
||||
Writeln ('Fielddefs count : ',FieldDefs.Count);
|
||||
For I:=0 to FieldDefs.Count-1 do
|
||||
DumpFieldDef(FieldDefs.Items[i]);
|
||||
Writeln ('Fields count : ',FieldCount);
|
||||
For I:=0 to FieldCount-1 do
|
||||
DumpField(Fields[i]);
|
||||
ScrollForward;
|
||||
ScrollBackWard;
|
||||
Writeln ('Doing append');
|
||||
writeln ('------------');
|
||||
Append;
|
||||
FieldByName('Name').AsString:='AppendName';
|
||||
FieldByName('Height').AsFloat:=9.99E9;
|
||||
FieldByName('LongField').AsLongInt:=999;
|
||||
FieldByName('ShoeSize').AsLongInt:=999;
|
||||
FieldByName('WordField').AsLongInt:=999;
|
||||
FieldByName('BooleanField').AsBoolean:=False;
|
||||
FieldByName('DateTimeField').AsDateTime:=Now;
|
||||
FieldByName('DateField').AsDateTime:=Date;
|
||||
FieldByName('TimeField').AsDateTime:=Time;
|
||||
Post;
|
||||
Writeln ('Doing Last');
|
||||
Writeln ('----------');
|
||||
Last;
|
||||
For I:=0 to FieldCount-1 do
|
||||
DumpFieldData(Fields[i]);
|
||||
Writeln ('Doing Prior');
|
||||
Writeln ('----------');
|
||||
Prior;
|
||||
For I:=0 to FieldCount-1 do
|
||||
DumpFieldData(Fields[i]);
|
||||
Writeln ('Closing.');
|
||||
Close;
|
||||
end;
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 1999-11-14 19:26:17 michael
|
||||
+ Initial implementation
|
||||
|
||||
Revision 1.3 1999/11/11 17:31:09 michael
|
||||
+ Added Checks for all simple field types.
|
||||
+ Initial implementation of Insert/Append
|
||||
|
||||
Revision 1.2 1999/10/24 17:07:54 michael
|
||||
+ Added copyright header
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user