ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/fbintf/client/FBSQLData.pas
(Generate patch)

Comparing ibx/trunk/fbintf/client/FBSQLData.pas (file contents):
Revision 47 by tony, Mon Jan 9 15:31:51 2017 UTC vs.
Revision 59 by tony, Mon Mar 13 09:51:56 2017 UTC

# Line 60 | Line 60
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}
# Line 113 | Line 116 | type
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;
# Line 126 | Line 129 | type
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;
# Line 140 | Line 143 | type
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;
# Line 157 | Line 160 | type
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 SetAsNumeric(Value: Int64; aScale: integer);
166       procedure SetIsNull(Value: Boolean); virtual;
167       procedure SetIsNullable(Value: Boolean); virtual;
168 <     procedure SetName(aValue: string); virtual;
168 >     procedure SetName(aValue: AnsiString); virtual;
169       property AsDate: TDateTime read GetAsDateTime write SetAsDate;
170       property AsBoolean:boolean read GetAsBoolean write SetAsBoolean;
171       property AsTime: TDateTime read GetAsDateTime write SetAsTime;
# Line 175 | Line 179 | type
179       property AsPointer: Pointer read GetAsPointer write SetAsPointer;
180       property AsQuad: TISC_QUAD read GetAsQuad write SetAsQuad;
181       property AsShort: short read GetAsShort write SetAsShort;
182 <     property AsString: String read GetAsString write SetAsString;
182 >     property AsString: AnsiString read GetAsString write SetAsString;
183       property AsVariant: Variant read GetAsVariant write SetAsVariant;
184       property Modified: Boolean read getModified;
185       property IsNull: Boolean read GetIsNull write SetIsNull;
# Line 195 | Line 199 | type
199      function GetColumn(index: integer): TSQLVarData;
200      function GetCount: integer;
201    protected
202 <    FUniqueRelationName: string;
202 >    FUniqueRelationName: AnsiString;
203      FColumnList: array of TSQLVarData;
204      function GetStatement: IStatement; virtual; abstract;
205      function GetPrepareSeqNo: integer; virtual; abstract;
# Line 205 | Line 209 | type
209    public
210      procedure Initialize; virtual;
211      function IsInputDataArea: boolean; virtual; abstract; {Input to Database}
212 <    procedure PreprocessSQL(sSQL: string; GenerateParamNames: boolean;
213 <      var sProcessedSQL: string);
212 >    procedure PreprocessSQL(sSQL: AnsiString; GenerateParamNames: boolean;
213 >      var sProcessedSQL: AnsiString);
214      function ColumnsInUseCount: integer; virtual;
215 <    function ColumnByName(Idx: string): TSQLVarData;
215 >    function ColumnByName(Idx: AnsiString): TSQLVarData;
216      function CheckStatementStatus(Request: TStatementStatus): boolean; virtual; abstract;
217      procedure GetData(index: integer; var IsNull: boolean; var len: short;
218 <      var data: PChar); virtual;
218 >      var data: PByte); virtual;
219      procedure RowChange;
220      function StateChanged(var ChangeSeqNo: integer): boolean; virtual; abstract;
221      property Count: integer read GetCount;
222      property Column[index: integer]: TSQLVarData read GetColumn;
223 <    property UniqueRelationName: string read FUniqueRelationName;
223 >    property UniqueRelationName: AnsiString read FUniqueRelationName;
224      property Statement: IStatement read GetStatement;
225      property PrepareSeqNo: integer read GetPrepareSeqNo;
226      property TransactionSeqNo: integer read GetTransactionSeqNo;
# Line 227 | Line 231 | type
231    TSQLVarData = class
232    private
233      FParent: TSQLDataArea;
234 <    FName: string;
234 >    FName: AnsiString;
235      FIndex: integer;
236      FModified: boolean;
237      FUniqueName: boolean;
238      FVarString: RawByteString;
239      function GetStatement: IStatement;
240 <    procedure SetName(AValue: string);
240 >    procedure SetName(AValue: AnsiString);
241    protected
242      function GetSQLType: cardinal; virtual; abstract;
243      function GetSubtype: integer; virtual; abstract;
244 <    function GetAliasName: string;  virtual; abstract;
245 <    function GetFieldName: string; virtual; abstract;
246 <    function GetOwnerName: string;  virtual; abstract;
247 <    function GetRelationName: string;  virtual; abstract;
244 >    function GetAliasName: AnsiString;  virtual; abstract;
245 >    function GetFieldName: AnsiString; virtual; abstract;
246 >    function GetOwnerName: AnsiString;  virtual; abstract;
247 >    function GetRelationName: AnsiString;  virtual; abstract;
248      function GetScale: integer; virtual; abstract;
249      function GetCharSetID: cardinal; virtual; abstract;
250      function GetCodePage: TSystemCodePage; virtual; abstract;
251      function GetIsNull: Boolean;   virtual; abstract;
252      function GetIsNullable: boolean; virtual; abstract;
253 <    function GetSQLData: PChar;  virtual; abstract;
253 >    function GetSQLData: PByte;  virtual; abstract;
254      function GetDataLength: cardinal; virtual; abstract;
255      procedure SetIsNull(Value: Boolean); virtual; abstract;
256      procedure SetIsNullable(Value: Boolean);  virtual; abstract;
257 <    procedure SetSQLData(AValue: PChar; len: cardinal); virtual; abstract;
257 >    procedure SetSQLData(AValue: PByte; len: cardinal); virtual; abstract;
258      procedure SetScale(aValue: integer); virtual; abstract;
259      procedure SetDataLength(len: cardinal); virtual; abstract;
260      procedure SetSQLType(aValue: cardinal); virtual; abstract;
261      procedure SetCharSetID(aValue: cardinal); virtual; abstract;
262    public
263      constructor Create(aParent: TSQLDataArea; aIndex: integer);
264 <    procedure SetString(aValue: string);
264 >    procedure SetString(aValue: AnsiString);
265      procedure Changed; virtual;
266      procedure RowChange; virtual;
267      function GetAsArray(Array_ID: TISC_QUAD): IArray; virtual; abstract;
# Line 268 | Line 272 | type
272      procedure Initialize; virtual;
273  
274    public
275 <    property AliasName: string read GetAliasName;
276 <    property FieldName: string read GetFieldName;
277 <    property OwnerName: string read GetOwnerName;
278 <    property RelationName: string read GetRelationName;
275 >    property AliasName: AnsiString read GetAliasName;
276 >    property FieldName: AnsiString read GetFieldName;
277 >    property OwnerName: AnsiString read GetOwnerName;
278 >    property RelationName: AnsiString read GetRelationName;
279      property Parent: TSQLDataArea read FParent;
280      property Index: integer read FIndex;
281 <    property Name: string read FName write SetName;
281 >    property Name: AnsiString read FName write SetName;
282      property CharSetID: cardinal read GetCharSetID write SetCharSetID;
283      property SQLType: cardinal read GetSQLType write SetSQLType;
284      property SQLSubtype: integer read GetSubtype;
285 <    property SQLData: PChar read GetSQLData;
285 >    property SQLData: PByte read GetSQLData;
286      property DataLength: cardinal read GetDataLength write SetDataLength;
287      property IsNull: Boolean read GetIsNull write SetIsNull;
288      property IsNullable: Boolean read GetIsNullable write SetIsNullable;
# Line 300 | Line 304 | type
304      FChangeSeqNo: integer;
305    protected
306      procedure CheckActive; override;
307 <    function SQLData: PChar; override;
307 >    function SQLData: PByte; override;
308      function GetDataLength: cardinal; override;
309      function GetCodePage: TSystemCodePage; override;
310  
# Line 315 | Line 319 | type
319      function GetIndex: integer;
320      function GetSQLType: cardinal; override;
321      function getSubtype: integer;
322 <    function getRelationName: string;
323 <    function getOwnerName: string;
324 <    function getSQLName: string;    {Name of the column}
325 <    function getAliasName: string;  {Alias Name of column or Column Name if not alias}
326 <    function GetName: string; override;      {Disambiguated uppercase Field Name}
322 >    function getRelationName: AnsiString;
323 >    function getOwnerName: AnsiString;
324 >    function getSQLName: AnsiString;    {Name of the column}
325 >    function getAliasName: AnsiString;  {Alias Name of column or Column Name if not alias}
326 >    function GetName: AnsiString; override;      {Disambiguated uppercase Field Name}
327      function GetScale: integer; override;
328      function getCharSetID: cardinal; override;
329      function GetIsNullable: boolean; override;
330      function GetSize: cardinal;
331      function GetArrayMetaData: IArrayMetaData;
332      function GetBlobMetaData: IBlobMetaData;
333 <    property Name: string read GetName;
333 >    property Name: AnsiString read GetName;
334      property Size: cardinal read GetSize;
335      property CharSetID: cardinal read getCharSetID;
336      property SQLSubtype: integer read getSubtype;
# Line 343 | Line 347 | type
347      function GetAsArray: IArray;
348      function GetAsBlob: IBlob; overload;
349      function GetAsBlob(BPB: IBPB): IBlob; overload;
350 <    function GetAsString: String; override;
350 >    function GetAsString: AnsiString; override;
351      property AsBlob: IBlob read GetAsBlob;
352   end;
353  
# Line 353 | Line 357 | type
357    protected
358      procedure CheckActive; override;
359      procedure Changed; override;
360 <    procedure InternalSetAsString(Value: String); override;
360 >    procedure InternalSetAsString(Value: AnsiString); override;
361      procedure SetScale(aValue: integer); override;
362      procedure SetDataLength(len: cardinal); override;
363      procedure SetSQLType(aValue: cardinal); override;
# Line 361 | Line 365 | type
365      procedure Clear;
366      function GetModified: boolean; override;
367      function GetAsPointer: Pointer;
368 <    procedure SetName(Value: string); override;
368 >    procedure SetName(Value: AnsiString); override;
369      procedure SetIsNull(Value: Boolean);  override;
370      procedure SetIsNullable(Value: Boolean); override;
371      procedure SetAsArray(anArray: IArray);
# Line 378 | Line 382 | type
382      procedure SetAsFloat(AValue: Float);
383      procedure SetAsPointer(AValue: Pointer);
384      procedure SetAsShort(AValue: Short);
385 <    procedure SetAsString(AValue: String); override;
385 >    procedure SetAsString(AValue: AnsiString); override;
386      procedure SetAsVariant(AValue: Variant);
387      procedure SetAsBlob(aValue: IBlob);
388      procedure SetAsQuad(AValue: TISC_QUAD);
# Line 401 | Line 405 | type
405      destructor Destroy; override;
406    public
407      {IMetaData}
408 <    function GetUniqueRelationName: string;
408 >    function GetUniqueRelationName: AnsiString;
409      function getCount: integer;
410      function getColumnMetaData(index: integer): IColumnMetaData;
411 <    function ByName(Idx: String): IColumnMetaData;
411 >    function ByName(Idx: AnsiString): IColumnMetaData;
412    end;
413  
414    { TSQLParams }
# Line 423 | Line 427 | type
427      {ISQLParams}
428      function getCount: integer;
429      function getSQLParam(index: integer): ISQLParam;
430 <    function ByName(Idx: String): ISQLParam ;
430 >    function ByName(Idx: AnsiString): ISQLParam ;
431      function GetModified: Boolean;
432    end;
433  
# Line 443 | Line 447 | type
447       constructor Create(aResults: TSQLDataArea);
448        {IResults}
449       function getCount: integer;
450 <     function ByName(Idx: String): ISQLData;
450 >     function ByName(Idx: AnsiString): ISQLData;
451       function getSQLData(index: integer): ISQLData;
452 <     procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PChar);
452 >     procedure GetData(index: integer; var IsNull:boolean; var len: short; var data: PByte);
453       function GetTransaction: ITransaction; virtual;
454       procedure SetRetainInterfaces(aValue: boolean);
455   end;
# Line 454 | Line 458 | implementation
458  
459   uses FBMessages, FBClientAPI, variants, IBUtils, FBTransaction;
460  
461 +
462   { TSQLDataArea }
463  
464   function TSQLDataArea.GetColumn(index: integer): TSQLVarData;
# Line 472 | Line 477 | procedure TSQLDataArea.SetUniqueRelation
477   var
478    i: Integer;
479    bUnique: Boolean;
480 <  RelationName: string;
480 >  RelationName: AnsiString;
481   begin
482    bUnique := True;
483    for i := 0 to ColumnsInUseCount - 1 do
# Line 503 | Line 508 | begin
508      Column[i].Initialize;
509   end;
510  
511 < procedure TSQLDataArea.PreprocessSQL(sSQL: string; GenerateParamNames: boolean;
512 <  var sProcessedSQL: string);
511 > procedure TSQLDataArea.PreprocessSQL(sSQL: AnsiString; GenerateParamNames: boolean;
512 >  var sProcessedSQL: AnsiString);
513   var
514 <  cCurChar, cNextChar, cQuoteChar: Char;
515 <  sParamName: String;
514 >  cCurChar, cNextChar, cQuoteChar: AnsiChar;
515 >  sParamName: AnsiString;
516    j, i, iLenSQL, iSQLPos: Integer;
517    iCurState {$ifdef ALLOWDIALECT3PARAMNAMES}, iCurParamState {$endif}: Integer;
518    iParamSuffix: Integer;
519    slNames: TStrings;
520 <  StrBuffer: PChar;
520 >  StrBuffer: PByte;
521    found: boolean;
522  
523   const
# Line 526 | Line 531 | const
531    ParamQuoteState = 1;
532    {$endif}
533  
534 <  procedure AddToProcessedSQL(cChar: Char);
534 >  procedure AddToProcessedSQL(cChar: AnsiChar);
535    begin
536 <    StrBuffer[iSQLPos] := cChar;
536 >    StrBuffer[iSQLPos] := byte(cChar);
537      Inc(iSQLPos);
538    end;
539  
# Line 684 | Line 689 | begin
689        Inc(i);
690      end;
691      AddToProcessedSQL(#0);
692 <    sProcessedSQL := strpas(StrBuffer);
692 >    sProcessedSQL := strpas(PAnsiChar(StrBuffer));
693      SetCount(slNames.Count);
694      for i := 0 to slNames.Count - 1 do
695      begin
# Line 716 | Line 721 | begin
721    Result := Count;
722   end;
723  
724 < function TSQLDataArea.ColumnByName(Idx: string): TSQLVarData;
724 > function TSQLDataArea.ColumnByName(Idx: AnsiString): TSQLVarData;
725   var
726 <  s: String;
726 >  s: AnsiString;
727    i: Integer;
728   begin
729    {$ifdef UseCaseInSensitiveParamName}
# Line 736 | Line 741 | begin
741   end;
742  
743   procedure TSQLDataArea.GetData(index: integer; var IsNull: boolean;
744 <  var len: short; var data: PChar);
744 >  var len: short; var data: PByte);
745   begin
746    //Do Nothing
747   end;
# Line 755 | Line 760 | begin
760    Result := FParent.Statement;
761   end;
762  
763 < procedure TSQLVarData.SetName(AValue: string);
763 > procedure TSQLVarData.SetName(AValue: AnsiString);
764   begin
765    if FName = AValue then Exit;
766    {$ifdef UseCaseInSensitiveParamName}
# Line 774 | Line 779 | begin
779    FUniqueName := true;
780   end;
781  
782 < procedure TSQLVarData.SetString(aValue: string);
782 > procedure TSQLVarData.SetString(aValue: AnsiString);
783   begin
784    {we take full advantage here of reference counted strings. When setting a string
785     value, a reference is kept in FVarString and a pointer to it placed in the
786 <   SQLVar. This avoids string copies. Note that PChar is guaranteed to point to
786 >   SQLVar. This avoids string copies. Note that PAnsiChar is guaranteed to point to
787     a zero byte when the string is empty, neatly avoiding a nil pointer error.}
788  
789    FVarString := aValue;
790    SQLType := SQL_TEXT;
791 <  SetSQLData(PChar(FVarString),Length(aValue));
791 >  SetSQLData(PByte(PAnsiChar(FVarString)),Length(aValue));
792   end;
793  
794   procedure TSQLVarData.Changed;
# Line 799 | Line 804 | end;
804  
805   procedure TSQLVarData.Initialize;
806  
807 <  function FindVarByName(idx: string; limit: integer): TSQLVarData;
807 >  function FindVarByName(idx: AnsiString; limit: integer): TSQLVarData;
808    var
809      k: integer;
810    begin
# Line 814 | Line 819 | procedure TSQLVarData.Initialize;
819  
820   var
821    j, j_len: Integer;
822 <  st: String;
823 <  sBaseName: string;
822 >  st: AnsiString;
823 >  sBaseName: AnsiString;
824   begin
825    RowChange;
826  
# Line 902 | Line 907 | function TSQLDataItem.AdjustScaleToCurre
907   var
908    Scaling : Int64;
909    i : Integer;
910 <  FractionText, PadText, CurrText: string;
910 >  FractionText, PadText, CurrText: AnsiString;
911   begin
912    Result := 0;
913    Scaling := 1;
# Line 921 | Line 926 | begin
926        FractionText := IntToStr(abs(Value mod Scaling));
927        for i := Length(FractionText) to -aScale -1 do
928          PadText := '0' + PadText;
929 +      {$IF declared(DefaultFormatSettings)}
930 +      with DefaultFormatSettings do
931 +      {$ELSE}
932 +      {$IF declared(FormatSettings)}
933 +      with FormatSettings do
934 +      {$IFEND}
935 +      {$IFEND}
936        if Value < 0 then
937 <        CurrText := '-' + IntToStr(Abs(Value div Scaling)) + DefaultFormatSettings.DecimalSeparator + PadText + FractionText
937 >        CurrText := '-' + IntToStr(Abs(Value div Scaling)) + DecimalSeparator + PadText + FractionText
938        else
939 <        CurrText := IntToStr(Abs(Value div Scaling)) + DefaultFormatSettings.DecimalSeparator + PadText + FractionText;
939 >        CurrText := IntToStr(Abs(Value div Scaling)) + DecimalSeparator + PadText + FractionText;
940        try
941          result := StrToCurr(CurrText);
942        except
# Line 1006 | Line 1018 | begin
1018    //Do nothing by default
1019   end;
1020  
1021 < procedure TSQLDataItem.InternalSetAsString(Value: String);
1021 > procedure TSQLDataItem.InternalSetAsString(Value: AnsiString);
1022   begin
1023    //Do nothing by default
1024   end;
1025  
1026 < function TSQLDataItem.Transliterate(s: string; CodePage: TSystemCodePage
1026 > function TSQLDataItem.Transliterate(s: AnsiString; CodePage: TSystemCodePage
1027    ): RawByteString;
1028   begin
1029    Result := s;
# Line 1034 | Line 1046 | begin
1046     //Do nothing by default
1047   end;
1048  
1049 < function TSQLDataItem.GetSQLTypeName: string;
1049 > function TSQLDataItem.GetSQLTypeName: AnsiString;
1050   begin
1051    Result := GetSQLTypeName(GetSQLType);
1052   end;
1053  
1054 < class function TSQLDataItem.GetSQLTypeName(SQLType: short): string;
1054 > class function TSQLDataItem.GetSQLTypeName(SQLType: short): AnsiString;
1055   begin
1056    Result := 'Unknown';
1057    case SQLType of
# Line 1270 | Line 1282 | begin
1282   end;
1283  
1284  
1285 < function TSQLDataItem.GetAsString: String;
1285 > function TSQLDataItem.GetAsString: AnsiString;
1286   var
1287 <  sz: PChar;
1287 >  sz: PByte;
1288    str_len: Integer;
1289    rs: RawByteString;
1290   begin
# Line 1297 | Line 1309 | begin
1309            str_len := DecodeInteger(SQLData, 2);
1310            Inc(sz, 2);
1311          end;
1312 <        SetString(rs, sz, str_len);
1312 >        SetString(rs, PAnsiChar(sz), str_len);
1313          SetCodePage(rs,GetCodePage,false);
1314          if (SQLType = SQL_TEXT) and (GetCharSetID <> 1) then
1315            Result := TrimRight(rs)
# Line 1312 | Line 1324 | begin
1324        SQL_TYPE_TIME :
1325          result := TimeToStr(AsDateTime);
1326        SQL_TIMESTAMP:
1327 <        result := FormatDateTime(FormatSettings.ShortDateFormat + ' ' +
1328 <                            FormatSettings.LongTimeFormat+'.zzz',AsDateTime);
1327 >      {$IF declared(DefaultFormatSettings)}
1328 >      with DefaultFormatSettings do
1329 >      {$ELSE}
1330 >      {$IF declared(FormatSettings)}
1331 >      with FormatSettings do
1332 >      {$IFEND}
1333 >      {$IFEND}
1334 >        result := FormatDateTime(ShortDateFormat + ' ' +
1335 >                            LongTimeFormat+'.zzz',AsDateTime);
1336        SQL_SHORT, SQL_LONG:
1337          if Scale = 0 then
1338            result := IntToStr(AsLong)
# Line 1400 | Line 1419 | begin
1419    //ignore unless overridden
1420   end;
1421  
1422 < procedure TSQLDataItem.SetName(aValue: string);
1422 > procedure TSQLDataItem.SetName(aValue: AnsiString);
1423   begin
1424    //ignore unless overridden
1425   end;
# Line 1576 | Line 1595 | begin
1595    Changed;
1596   end;
1597  
1598 < procedure TSQLDataItem.SetAsString(Value: String);
1598 > procedure TSQLDataItem.SetAsString(Value: AnsiString);
1599   begin
1600    InternalSetAsString(Value);
1601   end;
# Line 1611 | Line 1630 | begin
1630    end;
1631   end;
1632  
1633 + procedure TSQLDataItem.SetAsNumeric(Value: Int64; aScale: integer);
1634 + begin
1635 +  CheckActive;
1636 +  Changing;
1637 +  if IsNullable then
1638 +    IsNull := False;
1639 +
1640 +  SQLType := SQL_INT64;
1641 +  Scale := aScale;
1642 +  DataLength := SizeOf(Int64);
1643 +  PInt64(SQLData)^ := Value;
1644 +  Changed;
1645 + end;
1646 +
1647   procedure TSQLDataItem.SetAsBoolean(AValue: boolean);
1648   begin
1649    CheckActive;
# Line 1641 | Line 1674 | begin
1674      IBError(ibxeStatementNotPrepared, [nil]);
1675   end;
1676  
1677 < function TColumnMetaData.SQLData: PChar;
1677 > function TColumnMetaData.SQLData: PByte;
1678   begin
1679    Result := FIBXSQLVAR.SQLData;
1680   end;
# Line 1694 | Line 1727 | begin
1727    result := FIBXSQLVAR.SQLSubtype;
1728   end;
1729  
1730 < function TColumnMetaData.getRelationName: string;
1730 > function TColumnMetaData.getRelationName: AnsiString;
1731   begin
1732    CheckActive;
1733     result :=  FIBXSQLVAR.RelationName;
1734   end;
1735  
1736 < function TColumnMetaData.getOwnerName: string;
1736 > function TColumnMetaData.getOwnerName: AnsiString;
1737   begin
1738    CheckActive;
1739    result :=  FIBXSQLVAR.OwnerName;
1740   end;
1741  
1742 < function TColumnMetaData.getSQLName: string;
1742 > function TColumnMetaData.getSQLName: AnsiString;
1743   begin
1744    CheckActive;
1745    result :=  FIBXSQLVAR.FieldName;
1746   end;
1747  
1748 < function TColumnMetaData.getAliasName: string;
1748 > function TColumnMetaData.getAliasName: AnsiString;
1749   begin
1750    CheckActive;
1751    result := FIBXSQLVAR.AliasName;
1752   end;
1753  
1754 < function TColumnMetaData.GetName: string;
1754 > function TColumnMetaData.GetName: AnsiString;
1755   begin
1756    CheckActive;
1757    Result := FIBXSQLVAR. Name;
# Line 1803 | Line 1836 | begin
1836    result := FIBXSQLVAR.GetAsBlob(AsQuad,BPB);
1837   end;
1838  
1839 < function TIBSQLData.GetAsString: String;
1839 > function TIBSQLData.GetAsString: AnsiString;
1840   begin
1841    CheckActive;
1842    Result := '';
# Line 1821 | Line 1854 | end;
1854  
1855   { TSQLParam }
1856  
1857 < procedure TSQLParam.InternalSetAsString(Value: String);
1857 > procedure TSQLParam.InternalSetAsString(Value: AnsiString);
1858   var b: IBlob;
1859 +    dt: TDateTime;
1860   begin
1861    CheckActive;
1862    if IsNullable then
1863      IsNull := False;
1864    case SQLTYPE of
1865    SQL_BOOLEAN:
1866 <    if CompareText(Value,STrue) = 0 then
1866 >    if AnsiCompareText(Value,STrue) = 0 then
1867        AsBoolean := true
1868      else
1869 <    if CompareText(Value,SFalse) = 0 then
1869 >    if AnsiCompareText(Value,SFalse) = 0 then
1870        AsBoolean := false
1871      else
1872        IBError(ibxeInvalidDataConversion,[nil]);
# Line 1857 | Line 1891 | begin
1891      SQL_SHORT,
1892      SQL_LONG,
1893      SQL_INT64:
1894 <      SetAsInt64(StrToInt(Value));
1894 >      SetAsNumeric(AdjustScaleFromCurrency(StrToCurr(Value),GetScale),GetScale);
1895  
1896      SQL_D_FLOAT,
1897      SQL_DOUBLE,
# Line 1865 | Line 1899 | begin
1899        SetAsDouble(StrToFloat(Value));
1900  
1901      SQL_TIMESTAMP:
1902 <      SetAsDateTime(StrToDateTime(Value));
1902 >      if TryStrToDateTime(Value,dt) then
1903 >        SetAsDateTime(dt)
1904 >      else
1905 >        FIBXSQLVar.SetString(Value);
1906  
1907      SQL_TYPE_DATE:
1908 <      SetAsDate(StrToDateTime(Value));
1908 >      if TryStrToDateTime(Value,dt) then
1909 >        SetAsDate(dt)
1910 >      else
1911 >        FIBXSQLVar.SetString(Value);
1912  
1913      SQL_TYPE_TIME:
1914 <      SetAsTime(StrToDateTime(Value));
1914 >      if TryStrToDateTime(Value,dt) then
1915 >        SetAsTime(dt)
1916 >      else
1917 >        FIBXSQLVar.SetString(Value);
1918  
1919      else
1920        IBError(ibxeInvalidDataConversion,[nil]);
# Line 1925 | Line 1968 | begin
1968    Result := inherited GetAsPointer;
1969   end;
1970  
1971 < procedure TSQLParam.SetName(Value: string);
1971 > procedure TSQLParam.SetName(Value: AnsiString);
1972   begin
1973    CheckActive;
1974    FIBXSQLVAR.Name := Value;
# Line 2231 | Line 2274 | begin
2274    end;
2275   end;
2276  
2277 < procedure TSQLParam.SetAsString(AValue: String);
2277 > procedure TSQLParam.SetAsString(AValue: AnsiString);
2278   var i: integer;
2279      OldSQLVar: TSQLVarData;
2280   begin
# Line 2344 | Line 2387 | begin
2387    inherited Destroy;
2388   end;
2389  
2390 < function TMetaData.GetUniqueRelationName: string;
2390 > function TMetaData.GetUniqueRelationName: AnsiString;
2391   begin
2392    CheckActive;
2393    Result := FMetaData.UniqueRelationName;
# Line 2372 | Line 2415 | begin
2415    end;
2416   end;
2417  
2418 < function TMetaData.ByName(Idx: String): IColumnMetaData;
2418 > function TMetaData.ByName(Idx: AnsiString): IColumnMetaData;
2419   var aIBXSQLVAR: TSQLVarData;
2420   begin
2421    CheckActive;
# Line 2432 | Line 2475 | begin
2475    end;
2476   end;
2477  
2478 < function TSQLParams.ByName(Idx: String): ISQLParam;
2478 > function TSQLParams.ByName(Idx: AnsiString): ISQLParam;
2479   var aIBXSQLVAR: TSQLVarData;
2480   begin
2481    CheckActive;
# Line 2500 | Line 2543 | begin
2543    Result := FResults.Count;
2544   end;
2545  
2546 < function TResults.ByName(Idx: String): ISQLData;
2546 > function TResults.ByName(Idx: AnsiString): ISQLData;
2547   var col: TSQLVarData;
2548   begin
2549    Result := nil;
# Line 2532 | Line 2575 | begin
2575   end;
2576  
2577   procedure TResults.GetData(index: integer; var IsNull: boolean; var len: short;
2578 <  var data: PChar);
2578 >  var data: PByte);
2579   begin
2580    CheckActive;
2581    FResults.GetData(index,IsNull, len,data);
# Line 2548 | Line 2591 | begin
2591    RetainInterfaces := aValue;
2592   end;
2593  
2551
2594   end.
2595  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines