76 |
|
methods are needed for SQL parameters only. The string getters and setters |
77 |
|
are virtual as SQLVar and Array encodings of string data is different.} |
78 |
|
|
79 |
– |
{ Note on SQL Parameter Names |
80 |
– |
-------------------------------------------- |
81 |
– |
|
82 |
– |
IBX processes parameter names case insensitive. This does result in some additional |
83 |
– |
overhead due to a call to "AnsiUpperCase". This can be avoided by undefining |
84 |
– |
"UseCaseInSensitiveParamName" below. |
85 |
– |
|
86 |
– |
} |
87 |
– |
{$define UseCaseInSensitiveParamName} |
79 |
|
|
80 |
|
interface |
81 |
|
|
82 |
|
uses |
83 |
< |
Classes, SysUtils, IBExternals, IBHeader, IB, FBActivityMonitor, FBClientAPI; |
83 |
> |
Classes, SysUtils, IBExternals, IBHeader, {$IFDEF WINDOWS} Windows, {$ENDIF} IB, FBActivityMonitor, FBClientAPI; |
84 |
|
|
85 |
|
type |
86 |
|
|
92 |
|
function AdjustScale(Value: Int64; aScale: Integer): Double; |
93 |
|
function AdjustScaleToInt64(Value: Int64; aScale: Integer): Int64; |
94 |
|
function AdjustScaleToCurrency(Value: Int64; aScale: Integer): Currency; |
95 |
+ |
function GetTimestampFormatStr: AnsiString; |
96 |
+ |
function GetDateFormatStr(IncludeTime: boolean): AnsiString; |
97 |
+ |
function GetTimeFormatStr: AnsiString; |
98 |
|
procedure SetAsInteger(AValue: Integer); |
99 |
|
protected |
100 |
|
function AdjustScaleFromCurrency(Value: Currency; aScale: Integer): Int64; |
119 |
|
function GetSQLType: cardinal; virtual; abstract; |
120 |
|
function GetSQLTypeName: AnsiString; overload; |
121 |
|
class function GetSQLTypeName(SQLType: short): AnsiString; overload; |
122 |
+ |
function GetStrDataLength: short; |
123 |
|
function GetName: AnsiString; virtual; abstract; |
124 |
|
function GetScale: integer; virtual; abstract; |
125 |
|
function GetAsBoolean: boolean; |
137 |
|
function GetIsNullable: boolean; virtual; |
138 |
|
function GetAsVariant: Variant; |
139 |
|
function GetModified: boolean; virtual; |
140 |
+ |
function GetDateTimeStrLength(DateTimeFormat: TIBDateTimeFormats): integer; |
141 |
+ |
function GetSize: cardinal; virtual; abstract; |
142 |
+ |
function GetCharSetWidth: integer; virtual; abstract; |
143 |
|
procedure SetAsBoolean(AValue: boolean); virtual; |
144 |
|
procedure SetAsCurrency(Value: Currency); virtual; |
145 |
|
procedure SetAsInt64(Value: Int64); virtual; |
188 |
|
|
189 |
|
TSQLDataArea = class |
190 |
|
private |
191 |
+ |
FCaseSensitiveParams: boolean; |
192 |
|
function GetColumn(index: integer): TSQLVarData; |
193 |
|
function GetCount: integer; |
194 |
|
protected |
211 |
|
var data: PByte); virtual; |
212 |
|
procedure RowChange; |
213 |
|
function StateChanged(var ChangeSeqNo: integer): boolean; virtual; abstract; |
214 |
+ |
property CaseSensitiveParams: boolean read FCaseSensitiveParams |
215 |
+ |
write FCaseSensitiveParams; {Only used when IsInputDataArea true} |
216 |
|
property Count: integer read GetCount; |
217 |
|
property Column[index: integer]: TSQLVarData read GetColumn; |
218 |
|
property UniqueRelationName: AnsiString read FUniqueRelationName; |
242 |
|
function GetRelationName: AnsiString; virtual; abstract; |
243 |
|
function GetScale: integer; virtual; abstract; |
244 |
|
function GetCharSetID: cardinal; virtual; abstract; |
245 |
+ |
function GetCharSetWidth: integer; virtual; abstract; |
246 |
|
function GetCodePage: TSystemCodePage; virtual; abstract; |
247 |
|
function GetIsNull: Boolean; virtual; abstract; |
248 |
|
function GetIsNullable: boolean; virtual; abstract; |
296 |
|
FIBXSQLVAR: TSQLVarData; |
297 |
|
FOwner: IUnknown; {Keep reference to ensure Metadata/statement not discarded} |
298 |
|
FPrepareSeqNo: integer; |
297 |
– |
FStatement: IStatement; |
299 |
|
FChangeSeqNo: integer; |
300 |
|
protected |
301 |
|
procedure CheckActive; override; |
307 |
|
constructor Create(aOwner: IUnknown; aIBXSQLVAR: TSQLVarData); |
308 |
|
destructor Destroy; override; |
309 |
|
function GetSQLDialect: integer; override; |
309 |
– |
property Statement: IStatement read FStatement; |
310 |
|
|
311 |
|
public |
312 |
|
{IColumnMetaData} |
321 |
|
function GetScale: integer; override; |
322 |
|
function getCharSetID: cardinal; override; |
323 |
|
function GetIsNullable: boolean; override; |
324 |
< |
function GetSize: cardinal; |
324 |
> |
function GetSize: cardinal; override; |
325 |
> |
function GetCharSetWidth: integer; override; |
326 |
|
function GetArrayMetaData: IArrayMetaData; |
327 |
|
function GetBlobMetaData: IBlobMetaData; |
328 |
+ |
function GetStatement: IStatement; |
329 |
+ |
function GetTransaction: ITransaction; virtual; |
330 |
|
property Name: AnsiString read GetName; |
331 |
|
property Size: cardinal read GetSize; |
332 |
|
property CharSetID: cardinal read getCharSetID; |
333 |
|
property SQLSubtype: integer read getSubtype; |
334 |
|
property IsNullable: Boolean read GetIsNullable; |
335 |
+ |
public |
336 |
+ |
property Statement: IStatement read GetStatement; |
337 |
|
end; |
338 |
|
|
339 |
|
{ TIBSQLData } |
340 |
|
|
341 |
|
TIBSQLData = class(TColumnMetaData,ISQLData) |
342 |
+ |
private |
343 |
+ |
FTransaction: ITransaction; |
344 |
|
protected |
345 |
|
procedure CheckActive; override; |
346 |
|
public |
347 |
+ |
function GetTransaction: ITransaction; override; |
348 |
|
function GetIsNull: Boolean; override; |
349 |
|
function GetAsArray: IArray; |
350 |
|
function GetAsBlob: IBlob; overload; |
431 |
|
function getSQLParam(index: integer): ISQLParam; |
432 |
|
function ByName(Idx: AnsiString): ISQLParam ; |
433 |
|
function GetModified: Boolean; |
434 |
+ |
function GetHasCaseSensitiveParams: Boolean; |
435 |
|
end; |
436 |
|
|
437 |
|
{ TResults } |
453 |
|
function ByName(Idx: AnsiString): ISQLData; |
454 |
|
function getSQLData(index: integer): ISQLData; |
455 |
|
procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PByte); |
456 |
+ |
function GetStatement: IStatement; |
457 |
|
function GetTransaction: ITransaction; virtual; |
458 |
|
procedure SetRetainInterfaces(aValue: boolean); |
459 |
|
end; |
460 |
|
|
461 |
|
implementation |
462 |
|
|
463 |
< |
uses FBMessages, variants, IBUtils, FBTransaction; |
454 |
< |
|
455 |
< |
type |
456 |
< |
|
457 |
< |
{ TSQLParamProcessor } |
458 |
< |
|
459 |
< |
TSQLParamProcessor = class(TSQLwithNamedParamsTokeniser) |
460 |
< |
private |
461 |
< |
const |
462 |
< |
sIBXParam = 'IBXParam'; {do not localize} |
463 |
< |
private |
464 |
< |
FInString: AnsiString; |
465 |
< |
FIndex: integer; |
466 |
< |
function DoExecute(GenerateParamNames: boolean; |
467 |
< |
var slNames: TStrings): AnsiString; |
468 |
< |
protected |
469 |
< |
function GetChar: AnsiChar; override; |
470 |
< |
public |
471 |
< |
class function Execute(sSQL: AnsiString; GenerateParamNames: boolean; |
472 |
< |
var slNames: TStrings): AnsiString; |
473 |
< |
end; |
474 |
< |
|
475 |
< |
{ TSQLParamProcessor } |
476 |
< |
|
477 |
< |
function TSQLParamProcessor.DoExecute(GenerateParamNames: boolean; |
478 |
< |
var slNames: TStrings): AnsiString; |
479 |
< |
var token: TSQLTokens; |
480 |
< |
iParamSuffix: Integer; |
481 |
< |
begin |
482 |
< |
Result := ''; |
483 |
< |
iParamSuffix := 0; |
484 |
< |
|
485 |
< |
while not EOF do |
486 |
< |
begin |
487 |
< |
token := GetNextToken; |
488 |
< |
case token of |
489 |
< |
sqltParam, |
490 |
< |
sqltQuotedParam: |
491 |
< |
begin |
492 |
< |
Result := Result + '?'; |
493 |
< |
slNames.Add(TokenText); |
494 |
< |
end; |
495 |
< |
|
496 |
< |
sqltPlaceHolder: |
497 |
< |
if GenerateParamNames then |
498 |
< |
begin |
499 |
< |
Inc(iParamSuffix); |
500 |
< |
slNames.AddObject(sIBXParam + IntToStr(iParamSuffix),self); //Note local convention |
501 |
< |
//add pointer to self to mark entry |
502 |
< |
Result := Result + '?'; |
503 |
< |
end |
504 |
< |
else |
505 |
< |
IBError(ibxeSQLParseError, [SParamNameExpected]); |
506 |
< |
|
507 |
< |
sqltQuotedString: |
508 |
< |
Result := Result + '''' + SQLSafeString(TokenText) + ''''; |
509 |
< |
|
510 |
< |
sqltIdentifierInDoubleQuotes: |
511 |
< |
Result := Result + '"' + StringReplace(TokenText,'"','""',[rfReplaceAll]) + '"'; |
512 |
< |
|
513 |
< |
sqltComment: |
514 |
< |
Result := Result + '/*' + TokenText + '*/'; |
515 |
< |
|
516 |
< |
sqltCommentLine: |
517 |
< |
Result := Result + '//' + TokenText + LineEnding; |
518 |
< |
|
519 |
< |
sqltEOL: |
520 |
< |
Result := Result + LineEnding; |
521 |
< |
|
522 |
< |
else |
523 |
< |
Result := Result + TokenText; |
524 |
< |
end; |
525 |
< |
end; |
526 |
< |
end; |
527 |
< |
|
528 |
< |
function TSQLParamProcessor.GetChar: AnsiChar; |
529 |
< |
begin |
530 |
< |
if FIndex <= Length(FInString) then |
531 |
< |
begin |
532 |
< |
Result := FInString[FIndex]; |
533 |
< |
Inc(FIndex); |
534 |
< |
end |
535 |
< |
else |
536 |
< |
Result := #0; |
537 |
< |
end; |
538 |
< |
|
539 |
< |
class function TSQLParamProcessor.Execute(sSQL: AnsiString; |
540 |
< |
GenerateParamNames: boolean; var slNames: TStrings): AnsiString; |
541 |
< |
begin |
542 |
< |
with self.Create do |
543 |
< |
try |
544 |
< |
FInString := sSQL; |
545 |
< |
FIndex := 1; |
546 |
< |
Result := DoExecute(GenerateParamNames,slNames); |
547 |
< |
finally |
548 |
< |
Free; |
549 |
< |
end; |
550 |
< |
end; |
551 |
< |
|
463 |
> |
uses FBMessages, variants, IBUtils, FBTransaction, DateUtils; |
464 |
|
|
465 |
|
{ TSQLDataArea } |
466 |
|
|
566 |
|
s: AnsiString; |
567 |
|
i: Integer; |
568 |
|
begin |
569 |
< |
{$ifdef UseCaseInSensitiveParamName} |
570 |
< |
s := AnsiUpperCase(Idx); |
571 |
< |
{$else} |
569 |
> |
if not IsInputDataArea or not CaseSensitiveParams then |
570 |
> |
s := AnsiUpperCase(Idx) |
571 |
> |
else |
572 |
|
s := Idx; |
573 |
< |
{$endif} |
573 |
> |
|
574 |
|
for i := 0 to Count - 1 do |
575 |
|
if Column[i].Name = s then |
576 |
|
begin |
602 |
|
|
603 |
|
procedure TSQLVarData.SetName(AValue: AnsiString); |
604 |
|
begin |
605 |
< |
if FName = AValue then Exit; |
694 |
< |
{$ifdef UseCaseInSensitiveParamName} |
695 |
< |
if Parent.IsInputDataArea then |
605 |
> |
if not Parent.IsInputDataArea or not Parent.CaseSensitiveParams then |
606 |
|
FName := AnsiUpperCase(AValue) |
607 |
|
else |
698 |
– |
{$endif} |
608 |
|
FName := AValue; |
609 |
|
end; |
610 |
|
|
625 |
|
|
626 |
|
FVarString := aValue; |
627 |
|
SQLType := SQL_TEXT; |
628 |
+ |
Scale := 0; |
629 |
|
SetSQLData(PByte(PAnsiChar(FVarString)),Length(aValue)); |
630 |
|
end; |
631 |
|
|
786 |
|
result := Value; |
787 |
|
end; |
788 |
|
|
789 |
+ |
function TSQLDataItem.GetDateFormatStr(IncludeTime: boolean): AnsiString; |
790 |
+ |
begin |
791 |
+ |
{$IF declared(DefaultFormatSettings)} |
792 |
+ |
with DefaultFormatSettings do |
793 |
+ |
{$ELSE} |
794 |
+ |
{$IF declared(FormatSettings)} |
795 |
+ |
with FormatSettings do |
796 |
+ |
{$IFEND} |
797 |
+ |
{$IFEND} |
798 |
+ |
case GetSQLDialect of |
799 |
+ |
1: |
800 |
+ |
if IncludeTime then |
801 |
+ |
result := ShortDateFormat + ' ' + LongTimeFormat |
802 |
+ |
else |
803 |
+ |
result := ShortDateFormat; |
804 |
+ |
3: |
805 |
+ |
result := ShortDateFormat; |
806 |
+ |
end; |
807 |
+ |
end; |
808 |
+ |
|
809 |
+ |
function TSQLDataItem.GetTimeFormatStr: AnsiString; |
810 |
+ |
begin |
811 |
+ |
{$IF declared(DefaultFormatSettings)} |
812 |
+ |
with DefaultFormatSettings do |
813 |
+ |
{$ELSE} |
814 |
+ |
{$IF declared(FormatSettings)} |
815 |
+ |
with FormatSettings do |
816 |
+ |
{$IFEND} |
817 |
+ |
{$IFEND} |
818 |
+ |
Result := LongTimeFormat; |
819 |
+ |
end; |
820 |
+ |
|
821 |
+ |
function TSQLDataItem.GetTimestampFormatStr: AnsiString; |
822 |
+ |
begin |
823 |
+ |
{$IF declared(DefaultFormatSettings)} |
824 |
+ |
with DefaultFormatSettings do |
825 |
+ |
{$ELSE} |
826 |
+ |
{$IF declared(FormatSettings)} |
827 |
+ |
with FormatSettings do |
828 |
+ |
{$IFEND} |
829 |
+ |
{$IFEND} |
830 |
+ |
Result := ShortDateFormat + ' ' + LongTimeFormat + '.zzz'; |
831 |
+ |
end; |
832 |
+ |
|
833 |
|
procedure TSQLDataItem.SetAsInteger(AValue: Integer); |
834 |
|
begin |
835 |
|
SetAsLong(aValue); |
960 |
|
end; |
961 |
|
end; |
962 |
|
|
963 |
+ |
function TSQLDataItem.GetStrDataLength: short; |
964 |
+ |
begin |
965 |
+ |
with FFirebirdClientAPI do |
966 |
+ |
if SQLType = SQL_VARYING then |
967 |
+ |
Result := DecodeInteger(SQLData, 2) |
968 |
+ |
else |
969 |
+ |
Result := DataLength; |
970 |
+ |
end; |
971 |
+ |
|
972 |
|
function TSQLDataItem.GetAsBoolean: boolean; |
973 |
|
begin |
974 |
|
CheckActive; |
1178 |
|
end; |
1179 |
|
end; |
1180 |
|
|
1181 |
+ |
{Copied from LazUTF8} |
1182 |
+ |
|
1183 |
+ |
function UTF8CodepointSizeFull(p: PAnsiChar): integer; |
1184 |
+ |
const TopBitSetMask = $80; {%10000000} |
1185 |
+ |
Top2BitsSetMask = $C0; {%11000000} |
1186 |
+ |
Top3BitsSetMask = $E0; {%11100000} |
1187 |
+ |
Top4BitsSetMask = $F0; {%11110000} |
1188 |
+ |
Top5BitsSetMask = $F8; {%11111000} |
1189 |
+ |
begin |
1190 |
+ |
case p^ of |
1191 |
+ |
#0..#191: // %11000000 |
1192 |
+ |
// regular single byte character (#0 is a character, this is Pascal ;) |
1193 |
+ |
Result:=1; |
1194 |
+ |
#192..#223: // p^ and %11100000 = %11000000 |
1195 |
+ |
begin |
1196 |
+ |
// could be 2 byte character |
1197 |
+ |
if (ord(p[1]) and Top2BitsSetMask) = TopBitSetMask then |
1198 |
+ |
Result:=2 |
1199 |
+ |
else |
1200 |
+ |
Result:=1; |
1201 |
+ |
end; |
1202 |
+ |
#224..#239: // p^ and %11110000 = %11100000 |
1203 |
+ |
begin |
1204 |
+ |
// could be 3 byte character |
1205 |
+ |
if ((ord(p[1]) and Top2BitsSetMask) = TopBitSetMask) |
1206 |
+ |
and ((ord(p[2]) and Top2BitsSetMask) = TopBitSetMask) then |
1207 |
+ |
Result:=3 |
1208 |
+ |
else |
1209 |
+ |
Result:=1; |
1210 |
+ |
end; |
1211 |
+ |
#240..#247: // p^ and %11111000 = %11110000 |
1212 |
+ |
begin |
1213 |
+ |
// could be 4 byte character |
1214 |
+ |
if ((ord(p[1]) and Top2BitsSetMask) = TopBitSetMask) |
1215 |
+ |
and ((ord(p[2]) and Top2BitsSetMask) = TopBitSetMask) |
1216 |
+ |
and ((ord(p[3]) and Top2BitsSetMask) = TopBitSetMask) then |
1217 |
+ |
Result:=4 |
1218 |
+ |
else |
1219 |
+ |
Result:=1; |
1220 |
+ |
end; |
1221 |
+ |
else |
1222 |
+ |
Result:=1; |
1223 |
+ |
end; |
1224 |
+ |
end; |
1225 |
+ |
|
1226 |
+ |
{Returns the byte length of a UTF8 string with a fixed charwidth} |
1227 |
+ |
|
1228 |
+ |
function GetStrLen(p: PAnsiChar; CharWidth, MaxDataLength: cardinal): integer; |
1229 |
+ |
var i: integer; |
1230 |
+ |
cplen: integer; |
1231 |
+ |
s: AnsiString; |
1232 |
+ |
begin |
1233 |
+ |
Result := 0; |
1234 |
+ |
s := strpas(p); |
1235 |
+ |
for i := 1 to CharWidth do |
1236 |
+ |
begin |
1237 |
+ |
cplen := UTF8CodepointSizeFull(p); |
1238 |
+ |
Inc(p,cplen); |
1239 |
+ |
Inc(Result,cplen); |
1240 |
+ |
if Result >= MaxDataLength then |
1241 |
+ |
begin |
1242 |
+ |
Result := MaxDataLength; |
1243 |
+ |
Exit; |
1244 |
+ |
end; |
1245 |
+ |
end; |
1246 |
+ |
end; |
1247 |
|
|
1248 |
|
function TSQLDataItem.GetAsString: AnsiString; |
1249 |
|
var |
1267 |
|
begin |
1268 |
|
sz := SQLData; |
1269 |
|
if (SQLType = SQL_TEXT) then |
1270 |
< |
str_len := DataLength |
1270 |
> |
begin |
1271 |
> |
if GetCodePage = cp_utf8 then |
1272 |
> |
str_len := GetStrLen(PAnsiChar(sz),GetSize div GetCharSetWidth,DataLength) |
1273 |
> |
else |
1274 |
> |
str_len := DataLength |
1275 |
> |
end |
1276 |
|
else begin |
1277 |
< |
str_len := DecodeInteger(SQLData, 2); |
1277 |
> |
str_len := DecodeInteger(sz, 2); |
1278 |
|
Inc(sz, 2); |
1279 |
|
end; |
1280 |
|
SetString(rs, PAnsiChar(sz), str_len); |
1281 |
|
SetCodePage(rs,GetCodePage,false); |
1282 |
< |
if (SQLType = SQL_TEXT) and (GetCharSetID <> 1) then |
1249 |
< |
Result := TrimRight(rs) |
1250 |
< |
else |
1251 |
< |
Result := rs |
1282 |
> |
Result := rs; |
1283 |
|
end; |
1284 |
|
SQL_TYPE_DATE: |
1285 |
< |
case GetSQLDialect of |
1255 |
< |
1 : result := DateTimeToStr(AsDateTime); |
1256 |
< |
3 : result := DateToStr(AsDateTime); |
1257 |
< |
end; |
1285 |
> |
result := FormatDateTime(GetDateFormatStr(TimeOf(AsDateTime)<>0),AsDateTime); |
1286 |
|
SQL_TYPE_TIME : |
1287 |
< |
result := TimeToStr(AsDateTime); |
1287 |
> |
result := FormatDateTime(GetTimeFormatStr,AsDateTime); |
1288 |
|
SQL_TIMESTAMP: |
1289 |
< |
{$IF declared(DefaultFormatSettings)} |
1262 |
< |
with DefaultFormatSettings do |
1263 |
< |
{$ELSE} |
1264 |
< |
{$IF declared(FormatSettings)} |
1265 |
< |
with FormatSettings do |
1266 |
< |
{$IFEND} |
1267 |
< |
{$IFEND} |
1268 |
< |
result := FormatDateTime(ShortDateFormat + ' ' + |
1269 |
< |
LongTimeFormat+'.zzz',AsDateTime); |
1289 |
> |
result := FormatDateTime(GetTimestampFormatStr,AsDateTime); |
1290 |
|
SQL_SHORT, SQL_LONG: |
1291 |
|
if Scale = 0 then |
1292 |
|
result := IntToStr(AsLong) |
1314 |
|
Result := false; |
1315 |
|
end; |
1316 |
|
|
1317 |
< |
function TSQLDataItem.getIsNullable: boolean; |
1317 |
> |
function TSQLDataItem.GetIsNullable: boolean; |
1318 |
|
begin |
1319 |
|
CheckActive; |
1320 |
|
Result := false; |
1362 |
|
Result := false; |
1363 |
|
end; |
1364 |
|
|
1365 |
+ |
function TSQLDataItem.GetDateTimeStrLength(DateTimeFormat: TIBDateTimeFormats |
1366 |
+ |
): integer; |
1367 |
+ |
begin |
1368 |
+ |
case DateTimeFormat of |
1369 |
+ |
dfTimestamp: |
1370 |
+ |
Result := Length(GetTimestampFormatStr); |
1371 |
+ |
dfDateTime: |
1372 |
+ |
Result := Length(GetDateFormatStr(true)); |
1373 |
+ |
dfTime: |
1374 |
+ |
Result := Length(GetTimeFormatStr); |
1375 |
+ |
else |
1376 |
+ |
Result := 0; |
1377 |
+ |
end; |
1378 |
+ |
end; |
1379 |
+ |
|
1380 |
|
|
1381 |
|
procedure TSQLDataItem.SetIsNull(Value: Boolean); |
1382 |
|
begin |
1750 |
|
result := FIBXSQLVAR.DataLength; |
1751 |
|
end; |
1752 |
|
|
1753 |
+ |
function TColumnMetaData.GetCharSetWidth: integer; |
1754 |
+ |
begin |
1755 |
+ |
CheckActive; |
1756 |
+ |
result := FIBXSQLVAR.GetCharSetWidth; |
1757 |
+ |
end; |
1758 |
+ |
|
1759 |
|
function TColumnMetaData.GetArrayMetaData: IArrayMetaData; |
1760 |
|
begin |
1761 |
|
CheckActive; |
1768 |
|
result := FIBXSQLVAR.GetBlobMetaData; |
1769 |
|
end; |
1770 |
|
|
1771 |
+ |
function TColumnMetaData.GetStatement: IStatement; |
1772 |
+ |
begin |
1773 |
+ |
Result := FIBXSQLVAR.GetStatement; |
1774 |
+ |
end; |
1775 |
+ |
|
1776 |
+ |
function TColumnMetaData.GetTransaction: ITransaction; |
1777 |
+ |
begin |
1778 |
+ |
Result := GetStatement.GetTransaction; |
1779 |
+ |
end; |
1780 |
+ |
|
1781 |
|
{ TIBSQLData } |
1782 |
|
|
1783 |
|
procedure TIBSQLData.CheckActive; |
1797 |
|
IBError(ibxeBOF,[nil]); |
1798 |
|
end; |
1799 |
|
|
1800 |
+ |
function TIBSQLData.GetTransaction: ITransaction; |
1801 |
+ |
begin |
1802 |
+ |
if FTransaction = nil then |
1803 |
+ |
Result := inherited GetTransaction |
1804 |
+ |
else |
1805 |
+ |
Result := FTransaction; |
1806 |
+ |
end; |
1807 |
+ |
|
1808 |
|
function TIBSQLData.GetIsNull: Boolean; |
1809 |
|
begin |
1810 |
|
CheckActive; |
1848 |
|
{ TSQLParam } |
1849 |
|
|
1850 |
|
procedure TSQLParam.InternalSetAsString(Value: AnsiString); |
1851 |
+ |
|
1852 |
+ |
procedure DoSetString; |
1853 |
+ |
begin |
1854 |
+ |
Changing; |
1855 |
+ |
FIBXSQLVar.SetString(Transliterate(Value,GetCodePage)); |
1856 |
+ |
Changed; |
1857 |
+ |
end; |
1858 |
+ |
|
1859 |
|
var b: IBlob; |
1860 |
|
dt: TDateTime; |
1861 |
+ |
CurrValue: Currency; |
1862 |
+ |
FloatValue: single; |
1863 |
|
begin |
1864 |
|
CheckActive; |
1865 |
|
if IsNullable then |
1885 |
|
|
1886 |
|
SQL_VARYING, |
1887 |
|
SQL_TEXT: |
1888 |
< |
begin |
1820 |
< |
Changing; |
1821 |
< |
FIBXSQLVar.SetString(Transliterate(Value,GetCodePage)); |
1822 |
< |
Changed; |
1823 |
< |
end; |
1888 |
> |
DoSetString; |
1889 |
|
|
1890 |
|
SQL_SHORT, |
1891 |
|
SQL_LONG, |
1892 |
|
SQL_INT64: |
1893 |
< |
SetAsNumeric(AdjustScaleFromCurrency(StrToCurr(Value),GetScale),GetScale); |
1893 |
> |
if TryStrToCurr(Value,CurrValue) then |
1894 |
> |
SetAsNumeric(AdjustScaleFromCurrency(CurrValue,GetScale),GetScale) |
1895 |
> |
else |
1896 |
> |
DoSetString; |
1897 |
|
|
1898 |
|
SQL_D_FLOAT, |
1899 |
|
SQL_DOUBLE, |
1900 |
|
SQL_FLOAT: |
1901 |
< |
SetAsDouble(StrToFloat(Value)); |
1901 |
> |
if TryStrToFloat(Value,FloatValue) then |
1902 |
> |
SetAsDouble(FloatValue) |
1903 |
> |
else |
1904 |
> |
DoSetString; |
1905 |
|
|
1906 |
|
SQL_TIMESTAMP: |
1907 |
|
if TryStrToDateTime(Value,dt) then |
1908 |
|
SetAsDateTime(dt) |
1909 |
|
else |
1910 |
< |
FIBXSQLVar.SetString(Value); |
1910 |
> |
DoSetString; |
1911 |
|
|
1912 |
|
SQL_TYPE_DATE: |
1913 |
|
if TryStrToDateTime(Value,dt) then |
1914 |
|
SetAsDate(dt) |
1915 |
|
else |
1916 |
< |
FIBXSQLVar.SetString(Value); |
1916 |
> |
DoSetString; |
1917 |
|
|
1918 |
|
SQL_TYPE_TIME: |
1919 |
|
if TryStrToDateTime(Value,dt) then |
1920 |
|
SetAsTime(dt) |
1921 |
|
else |
1922 |
< |
FIBXSQLVar.SetString(Value); |
1922 |
> |
DoSetString; |
1923 |
|
|
1924 |
|
else |
1925 |
|
IBError(ibxeInvalidDataConversion,[nil]); |
2505 |
|
end; |
2506 |
|
end; |
2507 |
|
|
2508 |
+ |
function TSQLParams.GetHasCaseSensitiveParams: Boolean; |
2509 |
+ |
begin |
2510 |
+ |
Result := FSQLParams.CaseSensitiveParams; |
2511 |
+ |
end; |
2512 |
+ |
|
2513 |
|
{ TResults } |
2514 |
|
|
2515 |
|
procedure TResults.CheckActive; |
2528 |
|
end; |
2529 |
|
|
2530 |
|
function TResults.GetISQLData(aIBXSQLVAR: TSQLVarData): ISQLData; |
2531 |
+ |
var col: TIBSQLData; |
2532 |
|
begin |
2533 |
|
if (aIBXSQLVAR.Index < 0) or (aIBXSQLVAR.Index >= getCount) then |
2534 |
|
IBError(ibxeInvalidColumnIndex,[nil]); |
2535 |
|
|
2536 |
|
if not HasInterface(aIBXSQLVAR.Index) then |
2537 |
|
AddInterface(aIBXSQLVAR.Index, TIBSQLData.Create(self,aIBXSQLVAR)); |
2538 |
< |
Result := TIBSQLData(GetInterface(aIBXSQLVAR.Index)); |
2538 |
> |
col := TIBSQLData(GetInterface(aIBXSQLVAR.Index)); |
2539 |
> |
col.FTransaction := GetTransaction; |
2540 |
> |
Result := col; |
2541 |
|
end; |
2542 |
|
|
2543 |
|
constructor TResults.Create(aResults: TSQLDataArea); |
2594 |
|
FResults.GetData(index,IsNull, len,data); |
2595 |
|
end; |
2596 |
|
|
2597 |
+ |
function TResults.GetStatement: IStatement; |
2598 |
+ |
begin |
2599 |
+ |
Result := FStatement; |
2600 |
+ |
end; |
2601 |
+ |
|
2602 |
|
function TResults.GetTransaction: ITransaction; |
2603 |
|
begin |
2604 |
|
Result := FStatement.GetTransaction; |