60 |
|
{ } |
61 |
|
{************************************************************************} |
62 |
|
unit FBSQLData; |
63 |
+ |
{$IFDEF MSWINDOWS} |
64 |
+ |
{$DEFINE WINDOWS} |
65 |
+ |
{$ENDIF} |
66 |
|
|
67 |
|
{$IFDEF FPC} |
68 |
< |
{$mode objfpc}{$H+} |
68 |
> |
{$mode delphi} |
69 |
|
{$codepage UTF8} |
70 |
|
{$interfaces COM} |
71 |
|
{$ENDIF} |
116 |
|
function GetSQLDialect: integer; virtual; abstract; |
117 |
|
procedure Changed; virtual; |
118 |
|
procedure Changing; virtual; |
119 |
< |
procedure InternalSetAsString(Value: String); virtual; |
120 |
< |
function SQLData: PChar; virtual; abstract; |
119 |
> |
procedure InternalSetAsString(Value: AnsiString); virtual; |
120 |
> |
function SQLData: PByte; virtual; abstract; |
121 |
|
function GetDataLength: cardinal; virtual; abstract; |
122 |
|
function GetCodePage: TSystemCodePage; virtual; abstract; |
123 |
|
function getCharSetID: cardinal; virtual; abstract; |
124 |
< |
function Transliterate(s: string; CodePage: TSystemCodePage): RawByteString; |
124 |
> |
function Transliterate(s: AnsiString; CodePage: TSystemCodePage): RawByteString; |
125 |
|
procedure SetScale(aValue: integer); virtual; |
126 |
|
procedure SetDataLength(len: cardinal); virtual; |
127 |
|
procedure SetSQLType(aValue: cardinal); virtual; |
129 |
|
|
130 |
|
public |
131 |
|
function GetSQLType: cardinal; virtual; abstract; |
132 |
< |
function GetSQLTypeName: string; overload; |
133 |
< |
class function GetSQLTypeName(SQLType: short): string; overload; |
134 |
< |
function GetName: string; virtual; abstract; |
132 |
> |
function GetSQLTypeName: AnsiString; overload; |
133 |
> |
class function GetSQLTypeName(SQLType: short): AnsiString; overload; |
134 |
> |
function GetName: AnsiString; virtual; abstract; |
135 |
|
function GetScale: integer; virtual; abstract; |
136 |
|
function GetAsBoolean: boolean; |
137 |
|
function GetAsCurrency: Currency; |
143 |
|
function GetAsPointer: Pointer; |
144 |
|
function GetAsQuad: TISC_QUAD; |
145 |
|
function GetAsShort: short; |
146 |
< |
function GetAsString: String; virtual; |
146 |
> |
function GetAsString: AnsiString; virtual; |
147 |
|
function GetIsNull: Boolean; virtual; |
148 |
|
function getIsNullable: boolean; virtual; |
149 |
|
function GetAsVariant: Variant; |
160 |
|
procedure SetAsPointer(Value: Pointer); |
161 |
|
procedure SetAsQuad(Value: TISC_QUAD); |
162 |
|
procedure SetAsShort(Value: short); virtual; |
163 |
< |
procedure SetAsString(Value: String); virtual; |
163 |
> |
procedure SetAsString(Value: AnsiString); virtual; |
164 |
|
procedure SetAsVariant(Value: Variant); |
165 |
|
procedure SetIsNull(Value: Boolean); virtual; |
166 |
|
procedure SetIsNullable(Value: Boolean); virtual; |
167 |
< |
procedure SetName(aValue: string); virtual; |
167 |
> |
procedure SetName(aValue: AnsiString); virtual; |
168 |
|
property AsDate: TDateTime read GetAsDateTime write SetAsDate; |
169 |
|
property AsBoolean:boolean read GetAsBoolean write SetAsBoolean; |
170 |
|
property AsTime: TDateTime read GetAsDateTime write SetAsTime; |
178 |
|
property AsPointer: Pointer read GetAsPointer write SetAsPointer; |
179 |
|
property AsQuad: TISC_QUAD read GetAsQuad write SetAsQuad; |
180 |
|
property AsShort: short read GetAsShort write SetAsShort; |
181 |
< |
property AsString: String read GetAsString write SetAsString; |
181 |
> |
property AsString: AnsiString read GetAsString write SetAsString; |
182 |
|
property AsVariant: Variant read GetAsVariant write SetAsVariant; |
183 |
|
property Modified: Boolean read getModified; |
184 |
|
property IsNull: Boolean read GetIsNull write SetIsNull; |
198 |
|
function GetColumn(index: integer): TSQLVarData; |
199 |
|
function GetCount: integer; |
200 |
|
protected |
201 |
< |
FUniqueRelationName: string; |
201 |
> |
FUniqueRelationName: AnsiString; |
202 |
|
FColumnList: array of TSQLVarData; |
203 |
|
function GetStatement: IStatement; virtual; abstract; |
204 |
|
function GetPrepareSeqNo: integer; virtual; abstract; |
208 |
|
public |
209 |
|
procedure Initialize; virtual; |
210 |
|
function IsInputDataArea: boolean; virtual; abstract; {Input to Database} |
211 |
< |
procedure PreprocessSQL(sSQL: string; GenerateParamNames: boolean; |
212 |
< |
var sProcessedSQL: string); |
211 |
> |
procedure PreprocessSQL(sSQL: AnsiString; GenerateParamNames: boolean; |
212 |
> |
var sProcessedSQL: AnsiString); |
213 |
|
function ColumnsInUseCount: integer; virtual; |
214 |
< |
function ColumnByName(Idx: string): TSQLVarData; |
214 |
> |
function ColumnByName(Idx: AnsiString): TSQLVarData; |
215 |
|
function CheckStatementStatus(Request: TStatementStatus): boolean; virtual; abstract; |
216 |
|
procedure GetData(index: integer; var IsNull: boolean; var len: short; |
217 |
< |
var data: PChar); virtual; |
217 |
> |
var data: PByte); virtual; |
218 |
|
procedure RowChange; |
219 |
|
function StateChanged(var ChangeSeqNo: integer): boolean; virtual; abstract; |
220 |
|
property Count: integer read GetCount; |
221 |
|
property Column[index: integer]: TSQLVarData read GetColumn; |
222 |
< |
property UniqueRelationName: string read FUniqueRelationName; |
222 |
> |
property UniqueRelationName: AnsiString read FUniqueRelationName; |
223 |
|
property Statement: IStatement read GetStatement; |
224 |
|
property PrepareSeqNo: integer read GetPrepareSeqNo; |
225 |
|
property TransactionSeqNo: integer read GetTransactionSeqNo; |
230 |
|
TSQLVarData = class |
231 |
|
private |
232 |
|
FParent: TSQLDataArea; |
233 |
< |
FName: string; |
233 |
> |
FName: AnsiString; |
234 |
|
FIndex: integer; |
235 |
|
FModified: boolean; |
236 |
|
FUniqueName: boolean; |
237 |
|
FVarString: RawByteString; |
238 |
|
function GetStatement: IStatement; |
239 |
< |
procedure SetName(AValue: string); |
239 |
> |
procedure SetName(AValue: AnsiString); |
240 |
|
protected |
241 |
|
function GetSQLType: cardinal; virtual; abstract; |
242 |
|
function GetSubtype: integer; virtual; abstract; |
243 |
< |
function GetAliasName: string; virtual; abstract; |
244 |
< |
function GetFieldName: string; virtual; abstract; |
245 |
< |
function GetOwnerName: string; virtual; abstract; |
246 |
< |
function GetRelationName: string; virtual; abstract; |
243 |
> |
function GetAliasName: AnsiString; virtual; abstract; |
244 |
> |
function GetFieldName: AnsiString; virtual; abstract; |
245 |
> |
function GetOwnerName: AnsiString; virtual; abstract; |
246 |
> |
function GetRelationName: AnsiString; virtual; abstract; |
247 |
|
function GetScale: integer; virtual; abstract; |
248 |
|
function GetCharSetID: cardinal; virtual; abstract; |
249 |
|
function GetCodePage: TSystemCodePage; virtual; abstract; |
250 |
|
function GetIsNull: Boolean; virtual; abstract; |
251 |
|
function GetIsNullable: boolean; virtual; abstract; |
252 |
< |
function GetSQLData: PChar; virtual; abstract; |
252 |
> |
function GetSQLData: PByte; virtual; abstract; |
253 |
|
function GetDataLength: cardinal; virtual; abstract; |
254 |
|
procedure SetIsNull(Value: Boolean); virtual; abstract; |
255 |
|
procedure SetIsNullable(Value: Boolean); virtual; abstract; |
256 |
< |
procedure SetSQLData(AValue: PChar; len: cardinal); virtual; abstract; |
256 |
> |
procedure SetSQLData(AValue: PByte; len: cardinal); virtual; abstract; |
257 |
|
procedure SetScale(aValue: integer); virtual; abstract; |
258 |
|
procedure SetDataLength(len: cardinal); virtual; abstract; |
259 |
|
procedure SetSQLType(aValue: cardinal); virtual; abstract; |
260 |
|
procedure SetCharSetID(aValue: cardinal); virtual; abstract; |
261 |
|
public |
262 |
|
constructor Create(aParent: TSQLDataArea; aIndex: integer); |
263 |
< |
procedure SetString(aValue: string); |
263 |
> |
procedure SetString(aValue: AnsiString); |
264 |
|
procedure Changed; virtual; |
265 |
|
procedure RowChange; virtual; |
266 |
|
function GetAsArray(Array_ID: TISC_QUAD): IArray; virtual; abstract; |
271 |
|
procedure Initialize; virtual; |
272 |
|
|
273 |
|
public |
274 |
< |
property AliasName: string read GetAliasName; |
275 |
< |
property FieldName: string read GetFieldName; |
276 |
< |
property OwnerName: string read GetOwnerName; |
277 |
< |
property RelationName: string read GetRelationName; |
274 |
> |
property AliasName: AnsiString read GetAliasName; |
275 |
> |
property FieldName: AnsiString read GetFieldName; |
276 |
> |
property OwnerName: AnsiString read GetOwnerName; |
277 |
> |
property RelationName: AnsiString read GetRelationName; |
278 |
|
property Parent: TSQLDataArea read FParent; |
279 |
|
property Index: integer read FIndex; |
280 |
< |
property Name: string read FName write SetName; |
280 |
> |
property Name: AnsiString read FName write SetName; |
281 |
|
property CharSetID: cardinal read GetCharSetID write SetCharSetID; |
282 |
|
property SQLType: cardinal read GetSQLType write SetSQLType; |
283 |
|
property SQLSubtype: integer read GetSubtype; |
284 |
< |
property SQLData: PChar read GetSQLData; |
284 |
> |
property SQLData: PByte read GetSQLData; |
285 |
|
property DataLength: cardinal read GetDataLength write SetDataLength; |
286 |
|
property IsNull: Boolean read GetIsNull write SetIsNull; |
287 |
|
property IsNullable: Boolean read GetIsNullable write SetIsNullable; |
303 |
|
FChangeSeqNo: integer; |
304 |
|
protected |
305 |
|
procedure CheckActive; override; |
306 |
< |
function SQLData: PChar; override; |
306 |
> |
function SQLData: PByte; override; |
307 |
|
function GetDataLength: cardinal; override; |
308 |
|
function GetCodePage: TSystemCodePage; override; |
309 |
|
|
318 |
|
function GetIndex: integer; |
319 |
|
function GetSQLType: cardinal; override; |
320 |
|
function getSubtype: integer; |
321 |
< |
function getRelationName: string; |
322 |
< |
function getOwnerName: string; |
323 |
< |
function getSQLName: string; {Name of the column} |
324 |
< |
function getAliasName: string; {Alias Name of column or Column Name if not alias} |
325 |
< |
function GetName: string; override; {Disambiguated uppercase Field Name} |
321 |
> |
function getRelationName: AnsiString; |
322 |
> |
function getOwnerName: AnsiString; |
323 |
> |
function getSQLName: AnsiString; {Name of the column} |
324 |
> |
function getAliasName: AnsiString; {Alias Name of column or Column Name if not alias} |
325 |
> |
function GetName: AnsiString; override; {Disambiguated uppercase Field Name} |
326 |
|
function GetScale: integer; override; |
327 |
|
function getCharSetID: cardinal; override; |
328 |
|
function GetIsNullable: boolean; override; |
329 |
|
function GetSize: cardinal; |
330 |
|
function GetArrayMetaData: IArrayMetaData; |
331 |
|
function GetBlobMetaData: IBlobMetaData; |
332 |
< |
property Name: string read GetName; |
332 |
> |
property Name: AnsiString read GetName; |
333 |
|
property Size: cardinal read GetSize; |
334 |
|
property CharSetID: cardinal read getCharSetID; |
335 |
|
property SQLSubtype: integer read getSubtype; |
346 |
|
function GetAsArray: IArray; |
347 |
|
function GetAsBlob: IBlob; overload; |
348 |
|
function GetAsBlob(BPB: IBPB): IBlob; overload; |
349 |
< |
function GetAsString: String; override; |
349 |
> |
function GetAsString: AnsiString; override; |
350 |
|
property AsBlob: IBlob read GetAsBlob; |
351 |
|
end; |
352 |
|
|
356 |
|
protected |
357 |
|
procedure CheckActive; override; |
358 |
|
procedure Changed; override; |
359 |
< |
procedure InternalSetAsString(Value: String); override; |
359 |
> |
procedure InternalSetAsString(Value: AnsiString); override; |
360 |
|
procedure SetScale(aValue: integer); override; |
361 |
|
procedure SetDataLength(len: cardinal); override; |
362 |
|
procedure SetSQLType(aValue: cardinal); override; |
364 |
|
procedure Clear; |
365 |
|
function GetModified: boolean; override; |
366 |
|
function GetAsPointer: Pointer; |
367 |
< |
procedure SetName(Value: string); override; |
367 |
> |
procedure SetName(Value: AnsiString); override; |
368 |
|
procedure SetIsNull(Value: Boolean); override; |
369 |
|
procedure SetIsNullable(Value: Boolean); override; |
370 |
|
procedure SetAsArray(anArray: IArray); |
381 |
|
procedure SetAsFloat(AValue: Float); |
382 |
|
procedure SetAsPointer(AValue: Pointer); |
383 |
|
procedure SetAsShort(AValue: Short); |
384 |
< |
procedure SetAsString(AValue: String); override; |
384 |
> |
procedure SetAsString(AValue: AnsiString); override; |
385 |
|
procedure SetAsVariant(AValue: Variant); |
386 |
|
procedure SetAsBlob(aValue: IBlob); |
387 |
|
procedure SetAsQuad(AValue: TISC_QUAD); |
404 |
|
destructor Destroy; override; |
405 |
|
public |
406 |
|
{IMetaData} |
407 |
< |
function GetUniqueRelationName: string; |
407 |
> |
function GetUniqueRelationName: AnsiString; |
408 |
|
function getCount: integer; |
409 |
|
function getColumnMetaData(index: integer): IColumnMetaData; |
410 |
< |
function ByName(Idx: String): IColumnMetaData; |
410 |
> |
function ByName(Idx: AnsiString): IColumnMetaData; |
411 |
|
end; |
412 |
|
|
413 |
|
{ TSQLParams } |
426 |
|
{ISQLParams} |
427 |
|
function getCount: integer; |
428 |
|
function getSQLParam(index: integer): ISQLParam; |
429 |
< |
function ByName(Idx: String): ISQLParam ; |
429 |
> |
function ByName(Idx: AnsiString): ISQLParam ; |
430 |
|
function GetModified: Boolean; |
431 |
|
end; |
432 |
|
|
446 |
|
constructor Create(aResults: TSQLDataArea); |
447 |
|
{IResults} |
448 |
|
function getCount: integer; |
449 |
< |
function ByName(Idx: String): ISQLData; |
449 |
> |
function ByName(Idx: AnsiString): ISQLData; |
450 |
|
function getSQLData(index: integer): ISQLData; |
451 |
< |
procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PChar); |
451 |
> |
procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PByte); |
452 |
|
function GetTransaction: ITransaction; virtual; |
453 |
|
procedure SetRetainInterfaces(aValue: boolean); |
454 |
|
end; |
457 |
|
|
458 |
|
uses FBMessages, FBClientAPI, variants, IBUtils, FBTransaction; |
459 |
|
|
460 |
+ |
|
461 |
|
{ TSQLDataArea } |
462 |
|
|
463 |
|
function TSQLDataArea.GetColumn(index: integer): TSQLVarData; |
476 |
|
var |
477 |
|
i: Integer; |
478 |
|
bUnique: Boolean; |
479 |
< |
RelationName: string; |
479 |
> |
RelationName: AnsiString; |
480 |
|
begin |
481 |
|
bUnique := True; |
482 |
|
for i := 0 to ColumnsInUseCount - 1 do |
507 |
|
Column[i].Initialize; |
508 |
|
end; |
509 |
|
|
510 |
< |
procedure TSQLDataArea.PreprocessSQL(sSQL: string; GenerateParamNames: boolean; |
511 |
< |
var sProcessedSQL: string); |
510 |
> |
procedure TSQLDataArea.PreprocessSQL(sSQL: AnsiString; GenerateParamNames: boolean; |
511 |
> |
var sProcessedSQL: AnsiString); |
512 |
|
var |
513 |
< |
cCurChar, cNextChar, cQuoteChar: Char; |
514 |
< |
sParamName: String; |
513 |
> |
cCurChar, cNextChar, cQuoteChar: AnsiChar; |
514 |
> |
sParamName: AnsiString; |
515 |
|
j, i, iLenSQL, iSQLPos: Integer; |
516 |
|
iCurState {$ifdef ALLOWDIALECT3PARAMNAMES}, iCurParamState {$endif}: Integer; |
517 |
|
iParamSuffix: Integer; |
518 |
|
slNames: TStrings; |
519 |
< |
StrBuffer: PChar; |
519 |
> |
StrBuffer: PByte; |
520 |
|
found: boolean; |
521 |
|
|
522 |
|
const |
530 |
|
ParamQuoteState = 1; |
531 |
|
{$endif} |
532 |
|
|
533 |
< |
procedure AddToProcessedSQL(cChar: Char); |
533 |
> |
procedure AddToProcessedSQL(cChar: AnsiChar); |
534 |
|
begin |
535 |
< |
StrBuffer[iSQLPos] := cChar; |
535 |
> |
StrBuffer[iSQLPos] := byte(cChar); |
536 |
|
Inc(iSQLPos); |
537 |
|
end; |
538 |
|
|
688 |
|
Inc(i); |
689 |
|
end; |
690 |
|
AddToProcessedSQL(#0); |
691 |
< |
sProcessedSQL := strpas(StrBuffer); |
691 |
> |
sProcessedSQL := strpas(PAnsiChar(StrBuffer)); |
692 |
|
SetCount(slNames.Count); |
693 |
|
for i := 0 to slNames.Count - 1 do |
694 |
|
begin |
720 |
|
Result := Count; |
721 |
|
end; |
722 |
|
|
723 |
< |
function TSQLDataArea.ColumnByName(Idx: string): TSQLVarData; |
723 |
> |
function TSQLDataArea.ColumnByName(Idx: AnsiString): TSQLVarData; |
724 |
|
var |
725 |
< |
s: String; |
725 |
> |
s: AnsiString; |
726 |
|
i: Integer; |
727 |
|
begin |
728 |
|
{$ifdef UseCaseInSensitiveParamName} |
740 |
|
end; |
741 |
|
|
742 |
|
procedure TSQLDataArea.GetData(index: integer; var IsNull: boolean; |
743 |
< |
var len: short; var data: PChar); |
743 |
> |
var len: short; var data: PByte); |
744 |
|
begin |
745 |
|
//Do Nothing |
746 |
|
end; |
759 |
|
Result := FParent.Statement; |
760 |
|
end; |
761 |
|
|
762 |
< |
procedure TSQLVarData.SetName(AValue: string); |
762 |
> |
procedure TSQLVarData.SetName(AValue: AnsiString); |
763 |
|
begin |
764 |
|
if FName = AValue then Exit; |
765 |
|
{$ifdef UseCaseInSensitiveParamName} |
778 |
|
FUniqueName := true; |
779 |
|
end; |
780 |
|
|
781 |
< |
procedure TSQLVarData.SetString(aValue: string); |
781 |
> |
procedure TSQLVarData.SetString(aValue: AnsiString); |
782 |
|
begin |
783 |
|
{we take full advantage here of reference counted strings. When setting a string |
784 |
|
value, a reference is kept in FVarString and a pointer to it placed in the |
785 |
< |
SQLVar. This avoids string copies. Note that PChar is guaranteed to point to |
785 |
> |
SQLVar. This avoids string copies. Note that PAnsiChar is guaranteed to point to |
786 |
|
a zero byte when the string is empty, neatly avoiding a nil pointer error.} |
787 |
|
|
788 |
|
FVarString := aValue; |
789 |
|
SQLType := SQL_TEXT; |
790 |
< |
SetSQLData(PChar(FVarString),Length(aValue)); |
790 |
> |
SetSQLData(PByte(PAnsiChar(FVarString)),Length(aValue)); |
791 |
|
end; |
792 |
|
|
793 |
|
procedure TSQLVarData.Changed; |
803 |
|
|
804 |
|
procedure TSQLVarData.Initialize; |
805 |
|
|
806 |
< |
function FindVarByName(idx: string; limit: integer): TSQLVarData; |
806 |
> |
function FindVarByName(idx: AnsiString; limit: integer): TSQLVarData; |
807 |
|
var |
808 |
|
k: integer; |
809 |
|
begin |
818 |
|
|
819 |
|
var |
820 |
|
j, j_len: Integer; |
821 |
< |
st: String; |
822 |
< |
sBaseName: string; |
821 |
> |
st: AnsiString; |
822 |
> |
sBaseName: AnsiString; |
823 |
|
begin |
824 |
|
RowChange; |
825 |
|
|
906 |
|
var |
907 |
|
Scaling : Int64; |
908 |
|
i : Integer; |
909 |
< |
FractionText, PadText, CurrText: string; |
909 |
> |
FractionText, PadText, CurrText: AnsiString; |
910 |
|
begin |
911 |
|
Result := 0; |
912 |
|
Scaling := 1; |
925 |
|
FractionText := IntToStr(abs(Value mod Scaling)); |
926 |
|
for i := Length(FractionText) to -aScale -1 do |
927 |
|
PadText := '0' + PadText; |
928 |
+ |
{$IF declared(DefaultFormatSettings)} |
929 |
+ |
with DefaultFormatSettings do |
930 |
+ |
{$ELSE} |
931 |
+ |
{$IF declared(FormatSettings)} |
932 |
+ |
with FormatSettings do |
933 |
+ |
{$IFEND} |
934 |
+ |
{$IFEND} |
935 |
|
if Value < 0 then |
936 |
< |
CurrText := '-' + IntToStr(Abs(Value div Scaling)) + DefaultFormatSettings.DecimalSeparator + PadText + FractionText |
936 |
> |
CurrText := '-' + IntToStr(Abs(Value div Scaling)) + DecimalSeparator + PadText + FractionText |
937 |
|
else |
938 |
< |
CurrText := IntToStr(Abs(Value div Scaling)) + DefaultFormatSettings.DecimalSeparator + PadText + FractionText; |
938 |
> |
CurrText := IntToStr(Abs(Value div Scaling)) + DecimalSeparator + PadText + FractionText; |
939 |
|
try |
940 |
|
result := StrToCurr(CurrText); |
941 |
|
except |
1017 |
|
//Do nothing by default |
1018 |
|
end; |
1019 |
|
|
1020 |
< |
procedure TSQLDataItem.InternalSetAsString(Value: String); |
1020 |
> |
procedure TSQLDataItem.InternalSetAsString(Value: AnsiString); |
1021 |
|
begin |
1022 |
|
//Do nothing by default |
1023 |
|
end; |
1024 |
|
|
1025 |
< |
function TSQLDataItem.Transliterate(s: string; CodePage: TSystemCodePage |
1025 |
> |
function TSQLDataItem.Transliterate(s: AnsiString; CodePage: TSystemCodePage |
1026 |
|
): RawByteString; |
1027 |
|
begin |
1028 |
|
Result := s; |
1045 |
|
//Do nothing by default |
1046 |
|
end; |
1047 |
|
|
1048 |
< |
function TSQLDataItem.GetSQLTypeName: string; |
1048 |
> |
function TSQLDataItem.GetSQLTypeName: AnsiString; |
1049 |
|
begin |
1050 |
|
Result := GetSQLTypeName(GetSQLType); |
1051 |
|
end; |
1052 |
|
|
1053 |
< |
class function TSQLDataItem.GetSQLTypeName(SQLType: short): string; |
1053 |
> |
class function TSQLDataItem.GetSQLTypeName(SQLType: short): AnsiString; |
1054 |
|
begin |
1055 |
|
Result := 'Unknown'; |
1056 |
|
case SQLType of |
1281 |
|
end; |
1282 |
|
|
1283 |
|
|
1284 |
< |
function TSQLDataItem.GetAsString: String; |
1284 |
> |
function TSQLDataItem.GetAsString: AnsiString; |
1285 |
|
var |
1286 |
< |
sz: PChar; |
1286 |
> |
sz: PByte; |
1287 |
|
str_len: Integer; |
1288 |
|
rs: RawByteString; |
1289 |
|
begin |
1308 |
|
str_len := DecodeInteger(SQLData, 2); |
1309 |
|
Inc(sz, 2); |
1310 |
|
end; |
1311 |
< |
SetString(rs, sz, str_len); |
1311 |
> |
SetString(rs, PAnsiChar(sz), str_len); |
1312 |
|
SetCodePage(rs,GetCodePage,false); |
1313 |
|
if (SQLType = SQL_TEXT) and (GetCharSetID <> 1) then |
1314 |
|
Result := TrimRight(rs) |
1323 |
|
SQL_TYPE_TIME : |
1324 |
|
result := TimeToStr(AsDateTime); |
1325 |
|
SQL_TIMESTAMP: |
1326 |
< |
result := FormatDateTime(FormatSettings.ShortDateFormat + ' ' + |
1327 |
< |
FormatSettings.LongTimeFormat+'.zzz',AsDateTime); |
1326 |
> |
{$IF declared(DefaultFormatSettings)} |
1327 |
> |
with DefaultFormatSettings do |
1328 |
> |
{$ELSE} |
1329 |
> |
{$IF declared(FormatSettings)} |
1330 |
> |
with FormatSettings do |
1331 |
> |
{$IFEND} |
1332 |
> |
{$IFEND} |
1333 |
> |
result := FormatDateTime(ShortDateFormat + ' ' + |
1334 |
> |
LongTimeFormat+'.zzz',AsDateTime); |
1335 |
|
SQL_SHORT, SQL_LONG: |
1336 |
|
if Scale = 0 then |
1337 |
|
result := IntToStr(AsLong) |
1418 |
|
//ignore unless overridden |
1419 |
|
end; |
1420 |
|
|
1421 |
< |
procedure TSQLDataItem.SetName(aValue: string); |
1421 |
> |
procedure TSQLDataItem.SetName(aValue: AnsiString); |
1422 |
|
begin |
1423 |
|
//ignore unless overridden |
1424 |
|
end; |
1594 |
|
Changed; |
1595 |
|
end; |
1596 |
|
|
1597 |
< |
procedure TSQLDataItem.SetAsString(Value: String); |
1597 |
> |
procedure TSQLDataItem.SetAsString(Value: AnsiString); |
1598 |
|
begin |
1599 |
|
InternalSetAsString(Value); |
1600 |
|
end; |
1659 |
|
IBError(ibxeStatementNotPrepared, [nil]); |
1660 |
|
end; |
1661 |
|
|
1662 |
< |
function TColumnMetaData.SQLData: PChar; |
1662 |
> |
function TColumnMetaData.SQLData: PByte; |
1663 |
|
begin |
1664 |
|
Result := FIBXSQLVAR.SQLData; |
1665 |
|
end; |
1712 |
|
result := FIBXSQLVAR.SQLSubtype; |
1713 |
|
end; |
1714 |
|
|
1715 |
< |
function TColumnMetaData.getRelationName: string; |
1715 |
> |
function TColumnMetaData.getRelationName: AnsiString; |
1716 |
|
begin |
1717 |
|
CheckActive; |
1718 |
|
result := FIBXSQLVAR.RelationName; |
1719 |
|
end; |
1720 |
|
|
1721 |
< |
function TColumnMetaData.getOwnerName: string; |
1721 |
> |
function TColumnMetaData.getOwnerName: AnsiString; |
1722 |
|
begin |
1723 |
|
CheckActive; |
1724 |
|
result := FIBXSQLVAR.OwnerName; |
1725 |
|
end; |
1726 |
|
|
1727 |
< |
function TColumnMetaData.getSQLName: string; |
1727 |
> |
function TColumnMetaData.getSQLName: AnsiString; |
1728 |
|
begin |
1729 |
|
CheckActive; |
1730 |
|
result := FIBXSQLVAR.FieldName; |
1731 |
|
end; |
1732 |
|
|
1733 |
< |
function TColumnMetaData.getAliasName: string; |
1733 |
> |
function TColumnMetaData.getAliasName: AnsiString; |
1734 |
|
begin |
1735 |
|
CheckActive; |
1736 |
|
result := FIBXSQLVAR.AliasName; |
1737 |
|
end; |
1738 |
|
|
1739 |
< |
function TColumnMetaData.GetName: string; |
1739 |
> |
function TColumnMetaData.GetName: AnsiString; |
1740 |
|
begin |
1741 |
|
CheckActive; |
1742 |
|
Result := FIBXSQLVAR. Name; |
1821 |
|
result := FIBXSQLVAR.GetAsBlob(AsQuad,BPB); |
1822 |
|
end; |
1823 |
|
|
1824 |
< |
function TIBSQLData.GetAsString: String; |
1824 |
> |
function TIBSQLData.GetAsString: AnsiString; |
1825 |
|
begin |
1826 |
|
CheckActive; |
1827 |
|
Result := ''; |
1839 |
|
|
1840 |
|
{ TSQLParam } |
1841 |
|
|
1842 |
< |
procedure TSQLParam.InternalSetAsString(Value: String); |
1842 |
> |
procedure TSQLParam.InternalSetAsString(Value: AnsiString); |
1843 |
|
var b: IBlob; |
1844 |
|
begin |
1845 |
|
CheckActive; |
1847 |
|
IsNull := False; |
1848 |
|
case SQLTYPE of |
1849 |
|
SQL_BOOLEAN: |
1850 |
< |
if CompareText(Value,STrue) = 0 then |
1850 |
> |
if AnsiCompareText(Value,STrue) = 0 then |
1851 |
|
AsBoolean := true |
1852 |
|
else |
1853 |
< |
if CompareText(Value,SFalse) = 0 then |
1853 |
> |
if AnsiCompareText(Value,SFalse) = 0 then |
1854 |
|
AsBoolean := false |
1855 |
|
else |
1856 |
|
IBError(ibxeInvalidDataConversion,[nil]); |
1943 |
|
Result := inherited GetAsPointer; |
1944 |
|
end; |
1945 |
|
|
1946 |
< |
procedure TSQLParam.SetName(Value: string); |
1946 |
> |
procedure TSQLParam.SetName(Value: AnsiString); |
1947 |
|
begin |
1948 |
|
CheckActive; |
1949 |
|
FIBXSQLVAR.Name := Value; |
2249 |
|
end; |
2250 |
|
end; |
2251 |
|
|
2252 |
< |
procedure TSQLParam.SetAsString(AValue: String); |
2252 |
> |
procedure TSQLParam.SetAsString(AValue: AnsiString); |
2253 |
|
var i: integer; |
2254 |
|
OldSQLVar: TSQLVarData; |
2255 |
|
begin |
2362 |
|
inherited Destroy; |
2363 |
|
end; |
2364 |
|
|
2365 |
< |
function TMetaData.GetUniqueRelationName: string; |
2365 |
> |
function TMetaData.GetUniqueRelationName: AnsiString; |
2366 |
|
begin |
2367 |
|
CheckActive; |
2368 |
|
Result := FMetaData.UniqueRelationName; |
2390 |
|
end; |
2391 |
|
end; |
2392 |
|
|
2393 |
< |
function TMetaData.ByName(Idx: String): IColumnMetaData; |
2393 |
> |
function TMetaData.ByName(Idx: AnsiString): IColumnMetaData; |
2394 |
|
var aIBXSQLVAR: TSQLVarData; |
2395 |
|
begin |
2396 |
|
CheckActive; |
2450 |
|
end; |
2451 |
|
end; |
2452 |
|
|
2453 |
< |
function TSQLParams.ByName(Idx: String): ISQLParam; |
2453 |
> |
function TSQLParams.ByName(Idx: AnsiString): ISQLParam; |
2454 |
|
var aIBXSQLVAR: TSQLVarData; |
2455 |
|
begin |
2456 |
|
CheckActive; |
2518 |
|
Result := FResults.Count; |
2519 |
|
end; |
2520 |
|
|
2521 |
< |
function TResults.ByName(Idx: String): ISQLData; |
2521 |
> |
function TResults.ByName(Idx: AnsiString): ISQLData; |
2522 |
|
var col: TSQLVarData; |
2523 |
|
begin |
2524 |
|
Result := nil; |
2550 |
|
end; |
2551 |
|
|
2552 |
|
procedure TResults.GetData(index: integer; var IsNull: boolean; var len: short; |
2553 |
< |
var data: PChar); |
2553 |
> |
var data: PByte); |
2554 |
|
begin |
2555 |
|
CheckActive; |
2556 |
|
FResults.GetData(index,IsNull, len,data); |
2566 |
|
RetainInterfaces := aValue; |
2567 |
|
end; |
2568 |
|
|
2551 |
– |
|
2569 |
|
end. |
2570 |
|
|