28 |
|
* |
29 |
|
*) |
30 |
|
unit FBStatement; |
31 |
+ |
{$IFDEF MSWINDOWS} |
32 |
+ |
{$DEFINE WINDOWS} |
33 |
+ |
{$ENDIF} |
34 |
|
|
35 |
|
{$IFDEF FPC} |
36 |
< |
{$mode objfpc}{$H+} |
36 |
> |
{$mode delphi} |
37 |
|
{$codepage UTF8} |
38 |
|
{$interfaces COM} |
39 |
|
{$ENDIF} |
60 |
|
FOpen: boolean; |
61 |
|
FPrepared: boolean; |
62 |
|
FPrepareSeqNo: integer; {used to check for out of date references from interfaces} |
63 |
< |
FSQL: string; |
64 |
< |
FProcessedSQL: string; |
63 |
> |
FSQL: AnsiString; |
64 |
> |
FProcessedSQL: AnsiString; |
65 |
|
FHasParamNames: boolean; |
66 |
|
FBOF: boolean; |
67 |
|
FEOF: boolean; |
80 |
|
function InternalOpenCursor(aTransaction: ITransaction): IResultSet; virtual; abstract; |
81 |
|
procedure FreeHandle; virtual; abstract; |
82 |
|
procedure InternalClose(Force: boolean); virtual; abstract; |
83 |
+ |
function TimeStampToMSecs(const TimeStamp: TTimeStamp): Int64; |
84 |
|
public |
85 |
|
constructor Create(Attachment: IAttachment; Transaction: ITransaction; |
86 |
< |
sql: string; SQLDialect: integer); |
86 |
> |
sql: AnsiString; SQLDialect: integer); |
87 |
|
constructor CreateWithParameterNames(Attachment: IAttachment; Transaction: ITransaction; |
88 |
< |
sql: string; SQLDialect: integer; GenerateParamNames: boolean =false); |
88 |
> |
sql: AnsiString; SQLDialect: integer; GenerateParamNames: boolean =false); |
89 |
|
destructor Destroy; override; |
90 |
|
procedure Close; |
91 |
|
procedure TransactionEnding(aTransaction: ITransaction; Force: boolean); |
97 |
|
function GetRowsAffected(var SelectCount, InsertCount, UpdateCount, |
98 |
|
DeleteCount: integer): boolean; |
99 |
|
function GetSQLStatementType: TIBSQLStatementTypes; |
100 |
< |
function GetSQLText: string; |
100 |
> |
function GetSQLText: AnsiString; |
101 |
|
function GetSQLDialect: integer; |
102 |
|
|
103 |
|
{GetDSQLInfo only supports isc_info_sql_stmt_type, isc_info_sql_get_plan, isc_info_sql_records} |
104 |
|
procedure Prepare(aTransaction: ITransaction=nil); virtual; |
105 |
|
function Execute(aTransaction: ITransaction=nil): IResults; |
106 |
|
function OpenCursor(aTransaction: ITransaction=nil): IResultSet; |
107 |
< |
function CreateBlob(paramName: string): IBlob; overload; |
107 |
> |
function CreateBlob(paramName: AnsiString): IBlob; overload; |
108 |
|
function CreateBlob(index: integer): IBlob; overload; |
109 |
|
function CreateBlob(column: TColumnMetaData): IBlob; overload; virtual; abstract; |
110 |
< |
function CreateArray(paramName: string): IArray; overload; |
110 |
> |
function CreateArray(paramName: AnsiString): IArray; overload; |
111 |
|
function CreateArray(index: integer): IArray; overload; |
112 |
|
function CreateArray(column: TColumnMetaData): IArray; overload; virtual; abstract; |
113 |
|
function GetAttachment: IAttachment; |
136 |
|
IBError(ibxeNotInTransaction,[]); |
137 |
|
end; |
138 |
|
|
139 |
+ |
function TFBStatement.TimeStampToMSecs(const TimeStamp: TTimeStamp): Int64; |
140 |
+ |
begin |
141 |
+ |
Result := TimeStamp.Time + Int64(timestamp.date)*msecsperday; |
142 |
+ |
end; |
143 |
+ |
|
144 |
|
constructor TFBStatement.Create(Attachment: IAttachment; |
145 |
< |
Transaction: ITransaction; sql: string; SQLDialect: integer); |
145 |
> |
Transaction: ITransaction; sql: AnsiString; SQLDialect: integer); |
146 |
|
begin |
147 |
|
inherited Create(Transaction as TFBTransaction,2); |
148 |
|
FAttachmentIntf := Attachment; |
152 |
|
end; |
153 |
|
|
154 |
|
constructor TFBStatement.CreateWithParameterNames(Attachment: IAttachment; |
155 |
< |
Transaction: ITransaction; sql: string; SQLDialect: integer; |
155 |
> |
Transaction: ITransaction; sql: AnsiString; SQLDialect: integer; |
156 |
|
GenerateParamNames: boolean); |
157 |
|
begin |
158 |
|
FHasParamNames := true; |
223 |
|
Result := FSQLStatementType; |
224 |
|
end; |
225 |
|
|
226 |
< |
function TFBStatement.GetSQLText: string; |
226 |
> |
function TFBStatement.GetSQLText: AnsiString; |
227 |
|
begin |
228 |
|
Result := FSQL; |
229 |
|
end; |
262 |
|
Result := InternalOpenCursor(aTransaction); |
263 |
|
end; |
264 |
|
|
265 |
< |
function TFBStatement.CreateBlob(paramName: string): IBlob; |
265 |
> |
function TFBStatement.CreateBlob(paramName: AnsiString): IBlob; |
266 |
|
var column: TColumnMetaData; |
267 |
|
begin |
268 |
|
InternalPrepare; |
278 |
|
Result := CreateBlob(SQLParams[index] as TSQLParam); |
279 |
|
end; |
280 |
|
|
281 |
< |
function TFBStatement.CreateArray(paramName: string): IArray; |
281 |
> |
function TFBStatement.CreateArray(paramName: AnsiString): IArray; |
282 |
|
var column: TColumnMetaData; |
283 |
|
begin |
284 |
|
InternalPrepare; |