1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
| ///////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2015 by Charta Software B.V. //
// All rights reserved //
// //
// Version: 1.7.0.83525 //
// Web site: https://pascal.chartasoftware.com/ //
// //
// This code and information are provided "as is" without warranty of //
// any kind. Dissemination of this information or reproduction of //
// this material is strictly forbidden unless prior written permission //
// is obtained from Charta Software B.V.. //
// //
///////////////////////////////////////////////////////////////////////////
unit Sql.Result;
interface
uses
Boolean,
Color.Rgb,
DateTime,
DateTime.Calendar.Gregorian.Date,
DateTime.Calendar.Gregorian.Instant,
DateTime.Calendar.Gregorian.Time,
Decimal,
FloatingPoint._64,
FloatingPoint._64.Interval,
Geometry._2d,
Geometry._2d.FloatingPoint64.Point,
Integer,
Integer._32,
Memory.Block,
NamedFile,
Text,
Type_,
Type_.Structured,
Type_.Structured.Value,
Uri,
Uuid,
Value,
Xml.Value;
type
TSqlQueryResultMethod = (sqrmStoreResult, sqrmUseResult);
TSqlResult = class(TObject)
public
function GetRowCount(): TInteger32; virtual; abstract;
function GetType(): TRecordType; virtual; abstract;
function FetchRow(): TBoolean; virtual; abstract;
function ReadNull(): TBoolean; virtual; abstract;
function ReadText(): TText; virtual; abstract;
function ReadInteger(): TInteger; virtual; abstract;
function ReadDecimal(): TDecimal; virtual; abstract;
function ReadFloatingPoint(): TFloatingPoint64; virtual; abstract;
function ReadBoolean(): TBoolean; virtual; abstract;
function ReadFloatingPoint64Point(): T2dFloatingPoint64Point; virtual; abstract;
function ReadFloatingPoint64Interval(): TFloatingPoint64Interval; virtual; abstract;
function ReadColor(): TRgbColor; virtual; abstract;
function ReadUri(): TUri; virtual; abstract;
function ReadUuid(): TUuid; virtual; abstract;
function ReadByteBlock(): TMemoryBlock; virtual; abstract;
function ReadNamedFile(): TNamedFile; virtual; abstract;
function ReadXmlValue(): TXmlValue; virtual; abstract;
function Read2dGeometry(): T2dGeometry; virtual; abstract;
function ReadRecordSet(): TRecordSet; virtual; abstract;
function ReadType(): TType; virtual; abstract;
function ReadDateTime(): TDateTime; virtual; deprecated 'Use ReadInstant() instead'; abstract;
function ReadDate(): TGregorianDate; virtual; abstract;
function ReadTime(): TGregorianTime; virtual; abstract;
function ReadInstant(): TGregorianInstant; virtual; abstract;
function ReadValue(): TValue; virtual; abstract;
function Old_ReadValue(Type_: TType): TValue; deprecated;
end;
implementation
uses
Boolean.Type_,
Boolean.Value,
Currency.Type_,
DateTime.Type_,
Decimal.Type_,
Decimal.Value,
Exception,
Integer.Type_,
Integer.Value,
SerialIdentifier.Type_,
Text.Type_,
Text.Value,
Type_.System,
Uuid.Type_,
Uuid.Value,
Value.Unknown;
{ TSqlResult }
function TSqlResult.Old_ReadValue(Type_: TType): TValue;
begin
if ReadNull() then
Result := TUnknown.Create()
else if Type_ is TBooleanType then
Result := TBooleanValue.Create(ReadBoolean())
else if (Type_ is TIntegerType) or (Type_ is TSerialIdentifierType) then
Result := TIntegerValue.Create(ReadInteger())
else if Type_ is TTextType then
Result := TTextValue.Create(ReadText())
else if Type_ is TUuidType then
Result := TUuidValue.Create(ReadUuid())
else if Type_ is TDateType then
Result := ReadDate()
else if Type_ is TCurrencyType then
Result := TDecimalValue.Create(ReadDecimal()) // TODO: Currently there is no TCurrency support and TDecimals are used.
else if Type_ is TDecimalType then
Result := TDecimalValue.Create(ReadDecimal())
else if Type_ is TTimeOfDayType then
Result := ReadTime()
else if Type_ is TDateTimeType then
Result := ReadInstant()
else
raise EException.Create('Unsupported type: ' + Type_.ToText());
end;
end.
|