1 {*********************************************************}
3 { Zeos Database Objects }
4 { Abstract Database Connectivity Classes }
6 { Originally written by Sergey Seroukhov }
8 {*********************************************************}
10 {@********************************************************}
11 { Copyright (c) 1999-2012 Zeos Development Group }
13 { License Agreement: }
15 { This library is distributed in the hope that it will be }
16 { useful, but WITHOUT ANY WARRANTY; without even the }
17 { implied warranty of MERCHANTABILITY or FITNESS FOR }
18 { A PARTICULAR PURPOSE. See the GNU Lesser General }
19 { Public License for more details. }
21 { The source code of the ZEOS Libraries and packages are }
22 { distributed under the Library GNU General Public }
23 { License (see the file COPYING / COPYING.ZEOS) }
24 { with the following modification: }
25 { As a special exception, the copyright holders of this }
26 { library give you permission to link this library with }
27 { independent modules to produce an executable, }
28 { regardless of the license terms of these independent }
29 { modules, and to copy and distribute the resulting }
30 { executable under terms of your choice, provided that }
31 { you also meet, for each linked independent module, }
32 { the terms and conditions of the license of that module. }
33 { An independent module is a module which is not derived }
34 { from or based on this library. If you modify this }
35 { library, you may extend this exception to your version }
36 { of the library, but you are not obligated to do so. }
37 { If you do not wish to do so, delete this exception }
38 { statement from your version. }
41 { The project web site is located on: }
42 { http://zeos.firmos.at (FORUM) }
43 { http://sourceforge.net/p/zeoslib/tickets/ (BUGTRACKER)}
44 { svn://svn.code.sf.net/p/zeoslib/code-0/trunk (SVN) }
46 { http://www.sourceforge.net/projects/zeoslib. }
49 { Zeos Development Group. }
50 {********************************************************@}
67 Types, Classes, {$IFDEF MSEgui}mclasses,{$ENDIF} SysUtils, Contnrs,
68 ZDbcIntfs, ZClasses, ZCollections, ZSysUtils, ZCompatibility, ZVariant;
71 {$HINTS OFF} //suppress not used params
74 {** Implements Abstract ResultSet. }
75 TZAbstractResultSet = class(TZCodePagedObject, IZResultSet)
82 FFetchDirection: TZFetchDirection;
84 FResultSetType: TZResultSetType;
85 FResultSetConcurrency: TZResultSetConcurrency;
86 FPostUpdates: TZPostUpdatesMode;
87 FLocateUpdates: TZLocateUpdatesMode;
88 FColumnsInfo: TObjectList;
89 FMetadata: TContainedObject;
90 FStatement: IZStatement;
94 function InternalGetString(ColumnIndex: Integer): RawByteString; virtual;
96 procedure RaiseUnsupportedException;
97 procedure RaiseForwardOnlyException;
98 procedure RaiseReadOnlyException;
99 procedure CheckClosed;
100 procedure CheckColumnConvertion(ColumnIndex: Integer; ResultType: TZSQLType);
101 procedure CheckBlobColumn(ColumnIndex: Integer);
102 procedure Open; virtual;
103 function GetColumnIndex(const ColumnName: string): Integer;
104 property RowNo: Integer read FRowNo write FRowNo;
105 property LastRowNo: Integer read FLastRowNo write FLastRowNo;
106 property MaxRows: Integer read FMaxRows write FMaxRows;
107 property Closed: Boolean read FClosed write FClosed;
108 property FetchDirection: TZFetchDirection
109 read FFetchDirection write FFetchDirection;
110 property FetchSize: Integer read FFetchSize write FFetchSize;
111 property ResultSetType: TZResultSetType
112 read FResultSetType write FResultSetType;
113 property ResultSetConcurrency: TZResultSetConcurrency
114 read FResultSetConcurrency write FResultSetConcurrency;
115 property Statement: IZStatement read FStatement;
116 property Metadata: TContainedObject read FMetadata write FMetadata;
119 constructor Create(Statement: IZStatement; SQL: string;
120 Metadata: TContainedObject; ConSettings: PZConSettings);
121 destructor Destroy; override;
123 procedure SetType(Value: TZResultSetType);
124 procedure SetConcurrency(Value: TZResultSetConcurrency);
126 function Next: Boolean; virtual;
127 procedure Close; virtual;
128 function WasNull: Boolean; virtual;
130 //======================================================================
131 // Methods for accessing results by column index
132 //======================================================================
134 function IsNull(ColumnIndex: Integer): Boolean; virtual;
135 function GetPChar(ColumnIndex: Integer): PChar; virtual;
136 function GetString(ColumnIndex: Integer): String; virtual;
137 function GetBinaryString(ColumnIndex: Integer): RawByteString;
138 function GetUnicodeString(ColumnIndex: Integer): WideString; virtual;
139 function GetBoolean(ColumnIndex: Integer): Boolean; virtual;
140 function GetByte(ColumnIndex: Integer): Byte; virtual;
141 function GetShort(ColumnIndex: Integer): SmallInt; virtual;
142 function GetInt(ColumnIndex: Integer): Integer; virtual;
143 function GetLong(ColumnIndex: Integer): Int64; virtual;
144 function GetFloat(ColumnIndex: Integer): Single; virtual;
145 function GetDouble(ColumnIndex: Integer): Double; virtual;
146 function GetBigDecimal(ColumnIndex: Integer): Extended; virtual;
147 function GetBytes(ColumnIndex: Integer): TByteDynArray; virtual;
148 function GetDate(ColumnIndex: Integer): TDateTime; virtual;
149 function GetTime(ColumnIndex: Integer): TDateTime; virtual;
150 function GetTimestamp(ColumnIndex: Integer): TDateTime; virtual;
151 function GetAsciiStream(ColumnIndex: Integer): TStream; virtual;
152 function GetUnicodeStream(ColumnIndex: Integer): TStream; virtual;
153 function GetBinaryStream(ColumnIndex: Integer): TStream; virtual;
154 function GetBlob(ColumnIndex: Integer): IZBlob; virtual;
155 function GetDataSet(ColumnIndex: Integer): IZDataSet; virtual;
156 function GetValue(ColumnIndex: Integer): TZVariant; virtual;
157 function GetDefaultExpression(ColumnIndex: Integer): String; virtual;
159 //======================================================================
160 // Methods for accessing results by column name
161 //======================================================================
163 function IsNullByName(const ColumnName: string): Boolean; virtual;
164 function GetPCharByName(const ColumnName: string): PChar; virtual;
165 function GetStringByName(const ColumnName: string): String; virtual;
166 function GetBinaryStringByName(const ColumnName: string): RawByteString;
167 function GetUnicodeStringByName(const ColumnName: string): WideString; virtual;
168 function GetBooleanByName(const ColumnName: string): Boolean; virtual;
169 function GetByteByName(const ColumnName: string): Byte; virtual;
170 function GetShortByName(const ColumnName: string): SmallInt; virtual;
171 function GetIntByName(const ColumnName: string): Integer; virtual;
172 function GetLongByName(const ColumnName: string): Int64; virtual;
173 function GetFloatByName(const ColumnName: string): Single; virtual;
174 function GetDoubleByName(const ColumnName: string): Double; virtual;
175 function GetBigDecimalByName(const ColumnName: string): Extended; virtual;
176 function GetBytesByName(const ColumnName: string): TByteDynArray; virtual;
177 function GetDateByName(const ColumnName: string): TDateTime; virtual;
178 function GetTimeByName(const ColumnName: string): TDateTime; virtual;
179 function GetTimestampByName(const ColumnName: string): TDateTime; virtual;
180 function GetAsciiStreamByName(const ColumnName: string): TStream; virtual;
181 function GetUnicodeStreamByName(const ColumnName: string): TStream; virtual;
182 function GetBinaryStreamByName(const ColumnName: string): TStream; virtual;
183 function GetBlobByName(const ColumnName: string): IZBlob; virtual;
184 function GetDataSetByName(const ColumnName: String): IZDataSet; virtual;
185 function GetValueByName(const ColumnName: string): TZVariant; virtual;
187 //=====================================================================
188 // Advanced features:
189 //=====================================================================
191 function GetWarnings: EZSQLWarning; virtual;
192 procedure ClearWarnings; virtual;
194 function GetCursorName: AnsiString; virtual;
195 function GetMetaData: IZResultSetMetaData; virtual;
196 function FindColumn(const ColumnName: string): Integer; virtual;
198 //---------------------------------------------------------------------
199 // Traversal/Positioning
200 //---------------------------------------------------------------------
202 function IsBeforeFirst: Boolean; virtual;
203 function IsAfterLast: Boolean; virtual;
204 function IsFirst: Boolean; virtual;
205 function IsLast: Boolean; virtual;
206 procedure BeforeFirst; virtual;
207 procedure AfterLast; virtual;
208 function First: Boolean; virtual;
209 function Last: Boolean; virtual;
210 function GetRow: Integer; virtual;
211 function MoveAbsolute(Row: Integer): Boolean; virtual;
212 function MoveRelative(Rows: Integer): Boolean; virtual;
213 function Previous: Boolean; virtual;
215 //---------------------------------------------------------------------
217 //---------------------------------------------------------------------
219 procedure SetFetchDirection(Direction: TZFetchDirection); virtual;
220 function GetFetchDirection: TZFetchDirection; virtual;
222 procedure SetFetchSize(Rows: Integer); virtual;
223 function GetFetchSize: Integer; virtual;
225 function GetType: TZResultSetType; virtual;
226 function GetConcurrency: TZResultSetConcurrency; virtual;
228 function GetPostUpdates: TZPostUpdatesMode;
229 function GetLocateUpdates: TZLocateUpdatesMode;
231 //---------------------------------------------------------------------
233 //---------------------------------------------------------------------
235 function RowUpdated: Boolean; virtual;
236 function RowInserted: Boolean; virtual;
237 function RowDeleted: Boolean; virtual;
239 procedure UpdateNull(ColumnIndex: Integer); virtual;
240 procedure UpdateBoolean(ColumnIndex: Integer; Value: Boolean); virtual;
241 procedure UpdateByte(ColumnIndex: Integer; Value: ShortInt); virtual;
242 procedure UpdateShort(ColumnIndex: Integer; Value: SmallInt); virtual;
243 procedure UpdateInt(ColumnIndex: Integer; Value: Integer); virtual;
244 procedure UpdateLong(ColumnIndex: Integer; Value: Int64); virtual;
245 procedure UpdateFloat(ColumnIndex: Integer; Value: Single); virtual;
246 procedure UpdateDouble(ColumnIndex: Integer; Value: Double); virtual;
247 procedure UpdateBigDecimal(ColumnIndex: Integer; Value: Extended); virtual;
248 procedure UpdatePChar(ColumnIndex: Integer; Value: PChar); virtual;
249 procedure UpdateString(ColumnIndex: Integer; const Value: String); virtual;
250 procedure UpdateBinaryString(ColumnIndex: Integer; const Value: RawByteString);
251 procedure UpdateUnicodeString(ColumnIndex: Integer; const Value: WideString); virtual;
252 procedure UpdateBytes(ColumnIndex: Integer; const Value: TByteDynArray); virtual;
253 procedure UpdateDate(ColumnIndex: Integer; Value: TDateTime); virtual;
254 procedure UpdateTime(ColumnIndex: Integer; Value: TDateTime); virtual;
255 procedure UpdateTimestamp(ColumnIndex: Integer; Value: TDateTime); virtual;
256 procedure UpdateAsciiStream(ColumnIndex: Integer; Value: TStream); virtual;
257 procedure UpdateUnicodeStream(ColumnIndex: Integer; Value: TStream); virtual;
258 procedure UpdateBinaryStream(ColumnIndex: Integer; Value: TStream); virtual;
259 procedure UpdateDataSet(ColumnIndex: Integer; Value: IZDataSet); virtual;
260 procedure UpdateValue(ColumnIndex: Integer; const Value: TZVariant); virtual;
261 procedure UpdateDefaultExpression(ColumnIndex: Integer; const Value: string); virtual;
263 //======================================================================
264 // Methods for accessing results by column name
265 //======================================================================
267 procedure UpdateNullByName(const ColumnName: string); virtual;
268 procedure UpdateBooleanByName(const ColumnName: string; Value: Boolean); virtual;
269 procedure UpdateByteByName(const ColumnName: string; Value: ShortInt); virtual;
270 procedure UpdateShortByName(const ColumnName: string; Value: SmallInt); virtual;
271 procedure UpdateIntByName(const ColumnName: string; Value: Integer); virtual;
272 procedure UpdateLongByName(const ColumnName: string; Value: Int64); virtual;
273 procedure UpdateFloatByName(const ColumnName: string; Value: Single); virtual;
274 procedure UpdateDoubleByName(const ColumnName: string; Value: Double); virtual;
275 procedure UpdateBigDecimalByName(const ColumnName: string; Value: Extended); virtual;
276 procedure UpdatePCharByName(const ColumnName: string; Value: PChar); virtual;
277 procedure UpdateStringByName(const ColumnName: string; const Value: String); virtual;
278 procedure UpdateBinaryStringByName(const ColumnName: string; const Value: RawByteString);
279 procedure UpdateUnicodeStringByName(const ColumnName: string; const Value: WideString); virtual;
280 procedure UpdateBytesByName(const ColumnName: string; const Value: TByteDynArray); virtual;
281 procedure UpdateDateByName(const ColumnName: string; Value: TDateTime); virtual;
282 procedure UpdateTimeByName(const ColumnName: string; Value: TDateTime); virtual;
283 procedure UpdateTimestampByName(const ColumnName: string; Value: TDateTime); virtual;
284 procedure UpdateAsciiStreamByName(const ColumnName: string; Value: TStream); virtual;
285 procedure UpdateUnicodeStreamByName(const ColumnName: string; Value: TStream); virtual;
286 procedure UpdateBinaryStreamByName(const ColumnName: string; Value: TStream); virtual;
287 procedure UpdateDataSetByName(const ColumnName: string; Value: IZDataSet); virtual;
288 procedure UpdateValueByName(const ColumnName: string; const Value: TZVariant); virtual;
290 procedure InsertRow; virtual;
291 procedure UpdateRow; virtual;
292 procedure DeleteRow; virtual;
293 procedure RefreshRow; virtual;
294 procedure CancelRowUpdates; virtual;
295 procedure MoveToInsertRow; virtual;
296 procedure MoveToCurrentRow; virtual;
298 function CompareRows(Row1, Row2: Integer; const ColumnIndices: TIntegerDynArray;
299 const ColumnDirs: TBooleanDynArray): Integer; virtual;
301 function GetStatement: IZStatement; virtual;
303 function GetConSettings: PZConsettings;
304 property ColumnsInfo: TObjectList read FColumnsInfo write FColumnsInfo;
307 {** Implements external or internal blob wrapper object. }
308 TZAbstractBlob = class(TInterfacedObject, IZBlob)
314 FConnection: IZConnection;
316 property BlobData: Pointer read FBlobData write FBlobData;
317 property BlobSize: Integer read FBlobSize write FBlobSize;
318 property Updated: Boolean read FUpdated write FUpdated;
320 constructor CreateWithStream(Stream: TStream; Connection: IZConnection = nil;
321 Decoded: Boolean = False);
322 constructor CreateWithData(Data: Pointer; Size: Integer;
323 Connection: IZConnection = nil; Decoded: Boolean = False);
324 destructor Destroy; override;
326 function WasDecoded: Boolean;
327 function Connection: IZConnection;
328 function IsEmpty: Boolean; virtual;
329 function IsUpdated: Boolean; virtual;
330 function Length: LongInt; virtual;
332 function GetString: RawByteString; virtual;
333 procedure SetString(const Value: RawByteString); virtual;
334 function GetUnicodeString: WideString; virtual;
335 procedure SetUnicodeString(const Value: WideString); virtual;
336 function GetBytes: TByteDynArray; virtual;
337 procedure SetBytes(const Value: TByteDynArray); virtual;
338 function GetUnicodeStream: TStream; virtual;
339 function GetStream: TStream; virtual;
340 procedure SetStream(Value: TStream; Decoded: Boolean = False); virtual;
341 function GetBuffer: Pointer;
342 procedure SetBuffer(Buffer: Pointer; Length: Integer);
344 procedure Clear; virtual;
345 function Clone: IZBlob; virtual;
350 uses ZMessages, ZDbcUtils, ZDbcResultSetMetadata, ZEncoding
351 {$IFDEF WITH_ANSISTRCOMP_DEPRECATED}, AnsiStrings{$ENDIF};
353 { TZAbstractResultSet }
356 Creates this object and assignes the main properties.
357 @param Statement an SQL statement object.
358 @param SQL an SQL query string.
359 @param Metadata a resultset metadata object.
361 constructor TZAbstractResultSet.Create(Statement: IZStatement; SQL: string;
362 Metadata: TContainedObject; ConSettings: PZConSettings);
364 DatabaseMetadata: IZDatabaseMetadata;
366 Self.ConSettings := ConSettings;
372 if Statement = nil then
374 FResultSetType := rtForwardOnly;
375 FResultSetConcurrency := rcReadOnly;
376 FPostUpdates := poColumnsAll;
377 FLocateUpdates := loWhereAll;
382 FFetchDirection := Statement.GetFetchDirection;
383 FFetchSize := Statement.GetFetchSize;
384 FResultSetType := Statement.GetResultSetType;
385 FResultSetConcurrency := Statement.GetResultSetConcurrency;
386 FPostUpdates := Statement.GetPostUpdates;
387 FLocateUpdates := Statement.GetLocateUpdates;
388 FStatement := Statement;
389 FMaxRows := Statement.GetMaxRows;
392 if Metadata = nil then
394 if Statement <> nil then
395 DatabaseMetadata := GetStatement.GetConnection.GetMetadata
397 DatabaseMetadata := nil;
398 FMetadata := TZAbstractResultSetMetadata.Create(DatabaseMetadata, SQL, Self);
401 FMetadata := Metadata;
403 FColumnsInfo := TObjectList.Create(True); //Free the MemoryLeaks of TZColumnInfo
407 Destroys this object and cleanups the memory.
409 destructor TZAbstractResultSet.Destroy;
414 if FMetadata <> nil then
423 function TZAbstractResultSet.InternalGetString(ColumnIndex: Integer): RawByteString;
425 {$IFNDEF DISABLE_CHECKING}
426 CheckColumnConvertion(ColumnIndex, stString);
432 Raises unsupported operation exception.
434 procedure TZAbstractResultSet.RaiseUnsupportedException;
436 raise EZSQLException.Create(SUnsupportedOperation);
440 Raises operation is not allowed in FORWARD ONLY mode exception.
442 procedure TZAbstractResultSet.RaiseForwardOnlyException;
444 raise EZSQLException.Create(SOperationIsNotAllowed1);
448 Raises operation is not allowed in READ ONLY mode exception.
450 procedure TZAbstractResultSet.RaiseReadOnlyException;
452 raise EZSQLException.Create(SOperationIsNotAllowed2);
456 Checks if result set is open and operation is allowed.
458 procedure TZAbstractResultSet.CheckClosed;
461 raise EZSQLException.Create(SOperationIsNotAllowed4);
465 Checks is the column convertion from one type to another type allowed.
466 @param ColumnIndex an index of column.
467 @param ResultType a requested data type.
469 procedure TZAbstractResultSet.CheckColumnConvertion(ColumnIndex: Integer;
470 ResultType: TZSQLType);
472 InitialType: TZSQLType;
473 Metadata: TZAbstractResultSetMetadata;
476 Metadata := TZAbstractResultSetMetadata(FMetadata);
477 if (Metadata = nil) or (ColumnIndex <= 0)
478 or (ColumnIndex > Metadata.GetColumnCount) then
480 raise EZSQLException.Create(
481 Format(SColumnIsNotAccessable, [ColumnIndex]));
484 InitialType := Metadata.GetColumnType(ColumnIndex);
485 if not CheckConvertion(InitialType, ResultType) then
487 raise EZSQLException.Create(Format(SConvertionIsNotPossible, [ColumnIndex,
488 DefineColumnTypeName(InitialType), DefineColumnTypeName(ResultType)]));
493 Checks for blob expected column.
494 @param ColumnIndex an index of column.
496 procedure TZAbstractResultSet.CheckBlobColumn(ColumnIndex: Integer);
498 InitialType: TZSQLType;
499 Metadata: TZAbstractResultSetMetadata;
502 Metadata := TZAbstractResultSetMetadata(FMetadata);
503 if (Metadata = nil) or (ColumnIndex <= 0)
504 or (ColumnIndex > Metadata.GetColumnCount) then
506 raise EZSQLException.Create(
507 Format(SColumnIsNotAccessable, [ColumnIndex]));
510 InitialType := Metadata.GetColumnType(ColumnIndex);
511 if not (InitialType in [stAsciiStream, stBinaryStream, stUnicodeStream]) then
513 raise EZSQLException.Create(
514 Format(SCanNotAccessBlobRecord,
515 [ColumnIndex, DefineColumnTypeName(InitialType)]));
520 Set the concurrency mode of this <code>ResultSet</code> object.
521 The concurrency used is determined by the
522 <code>Statement</code> object that created the result set.
524 @param the concurrency type, either <code>CONCUR_READ_ONLY</code>
525 or <code>CONCUR_UPDATABLE</code>
527 procedure TZAbstractResultSet.SetConcurrency(Value: TZResultSetConcurrency);
529 ResultSetConcurrency := Value;
533 Set the type of this <code>ResultSet</code> object.
534 The type is determined by the <code>Statement</code> object
535 that created the result set.
537 @param <code>TYPE_FORWARD_ONLY</code>,
538 <code>TYPE_SCROLL_INSENSITIVE</code>,
539 or <code>TYPE_SCROLL_SENSITIVE</code>
541 procedure TZAbstractResultSet.SetType(Value: TZResultSetType);
543 ResultSetType := Value;
547 Opens this recordset.
549 procedure TZAbstractResultSet.Open;
555 Releases this <code>ResultSet</code> object's database and
556 JDBC resources immediately instead of waiting for
557 this to happen when it is automatically closed.
559 <P><B>Note:</B> A <code>ResultSet</code> object
560 is automatically closed by the
561 <code>Statement</code> object that generated it when
562 that <code>Statement</code> object is closed,
563 re-executed, or is used to retrieve the next result from a
564 sequence of multiple results. A <code>ResultSet</code> object
565 is also automatically closed when it is garbage collected.
567 procedure TZAbstractResultSet.Close;
570 FColumnInfo: TZColumnInfo;
576 for I := FColumnsInfo.Count - 1 downto 0 do
578 FColumnInfo:=TZColumnInfo(FColumnsInfo.Extract(FColumnsInfo.Items[I]));
587 the last column read had a value of SQL <code>NULL</code>.
588 Note that you must first call one of the <code>getXXX</code> methods
589 on a column to try to read its value and then call
590 the method <code>wasNull</code> to see if the value read was
591 SQL <code>NULL</code>.
593 @return <code>true</code> if the last column value read was SQL
594 <code>NULL</code> and <code>false</code> otherwise
596 function TZAbstractResultSet.WasNull: Boolean;
598 Result := LastWasNull;
601 //======================================================================
602 // Methods for accessing results by column index
603 //======================================================================
606 Indicates if the value of the designated column in the current row
607 of this <code>ResultSet</code> object is Null.
609 @param columnIndex the first column is 1, the second is 2, ...
610 @return if the value is SQL <code>NULL</code>, the
611 value returned is <code>true</code>. <code>false</code> otherwise.
613 function TZAbstractResultSet.IsNull(ColumnIndex: Integer): Boolean;
619 Gets the value of the designated column in the current row
620 of this <code>ResultSet</code> object as
621 a <code>PAnsiChar</code> in the Delphi programming language.
623 @param columnIndex the first column is 1, the second is 2, ...
624 @return the column value; if the value is SQL <code>NULL</code>, the
625 value returned is <code>null</code>
628 function TZAbstractResultSet.GetPChar(ColumnIndex: Integer): PChar;
630 FTemp := GetString(ColumnIndex);
631 Result := PChar(FTemp);
635 Gets the value of the designated column in the current row
636 of this <code>ResultSet</code> object as
637 a <code>String</code> in the Java programming language.
639 @param columnIndex the first column is 1, the second is 2, ...
640 @return the column value; if the value is SQL <code>NULL</code>, the
641 value returned is <code>null</code>
643 function TZAbstractResultSet.GetString(ColumnIndex: Integer): String;
645 Result := ZDbcString(InternalGetString(ColumnIndex));
649 Gets the value of the designated column in the current row
650 of this <code>ResultSet</code> object as
651 a <code>String</code> in the Java programming language.
653 @param columnIndex the first column is 1, the second is 2, ...
654 @return the column value; if the value is SQL <code>NULL</code>, the
655 value returned is <code>null</code>
657 function TZAbstractResultSet.GetBinaryString(ColumnIndex: Integer): RawByteString;
659 Result := InternalGetString(ColumnIndex);
663 Gets the value of the designated column in the current row
664 of this <code>ResultSet</code> object as
665 a <code>WideString</code> in the Delphi programming language.
667 @param columnIndex the first column is 1, the second is 2, ...
668 @return the column value; if the value is SQL <code>NULL</code>, the
669 value returned is <code>null</code>
671 function TZAbstractResultSet.GetUnicodeString(ColumnIndex: Integer): WideString;
673 {$IFNDEF DISABLE_CHECKING}
674 CheckColumnConvertion(ColumnIndex, stUnicodeString);
676 Result := ZDbcUnicodeString(InternalGetString(ColumnIndex));
680 Gets the value of the designated column in the current row
681 of this <code>ResultSet</code> object as
682 a <code>boolean</code> in the Java programming language.
684 @param columnIndex the first column is 1, the second is 2, ...
685 @return the column value; if the value is SQL <code>NULL</code>, the
686 value returned is <code>false</code>
688 function TZAbstractResultSet.GetBoolean(ColumnIndex: Integer): Boolean;
690 {$IFNDEF DISABLE_CHECKING}
691 CheckColumnConvertion(ColumnIndex, stBoolean);
697 Gets the value of the designated column in the current row
698 of this <code>ResultSet</code> object as
699 a <code>byte</code> in the Java programming language.
701 @param columnIndex the first column is 1, the second is 2, ...
702 @return the column value; if the value is SQL <code>NULL</code>, the
703 value returned is <code>0</code>
705 function TZAbstractResultSet.GetByte(ColumnIndex: Integer): Byte;
707 {$IFNDEF DISABLE_CHECKING}
708 CheckColumnConvertion(ColumnIndex, stByte);
714 Gets the value of the designated column in the current row
715 of this <code>ResultSet</code> object as
716 a <code>short</code> in the Java programming language.
718 @param columnIndex the first column is 1, the second is 2, ...
719 @return the column value; if the value is SQL <code>NULL</code>, the
720 value returned is <code>0</code>
722 function TZAbstractResultSet.GetShort(ColumnIndex: Integer): SmallInt;
724 {$IFNDEF DISABLE_CHECKING}
725 CheckColumnConvertion(ColumnIndex, stShort);
731 Gets the value of the designated column in the current row
732 of this <code>ResultSet</code> object as
733 an <code>int</code> in the Java programming language.
735 @param columnIndex the first column is 1, the second is 2, ...
736 @return the column value; if the value is SQL <code>NULL</code>, the
737 value returned is <code>0</code>
739 function TZAbstractResultSet.GetInt(ColumnIndex: Integer): Integer;
741 {$IFNDEF DISABLE_CHECKING}
742 CheckColumnConvertion(ColumnIndex, stInteger);
748 Gets the value of the designated column in the current row
749 of this <code>ResultSet</code> object as
750 a <code>long</code> in the Java programming language.
752 @param columnIndex the first column is 1, the second is 2, ...
753 @return the column value; if the value is SQL <code>NULL</code>, the
754 value returned is <code>0</code>
756 function TZAbstractResultSet.GetLong(ColumnIndex: Integer): Int64;
758 {$IFNDEF DISABLE_CHECKING}
759 CheckColumnConvertion(ColumnIndex, stLong);
765 Gets the value of the designated column in the current row
766 of this <code>ResultSet</code> object as
767 a <code>float</code> in the Java programming language.
769 @param columnIndex the first column is 1, the second is 2, ...
770 @return the column value; if the value is SQL <code>NULL</code>, the
771 value returned is <code>0</code>
773 function TZAbstractResultSet.GetFloat(ColumnIndex: Integer): Single;
775 {$IFNDEF DISABLE_CHECKING}
776 CheckColumnConvertion(ColumnIndex, stFloat);
782 Gets the value of the designated column in the current row
783 of this <code>ResultSet</code> object as
784 a <code>double</code> in the Java programming language.
786 @param columnIndex the first column is 1, the second is 2, ...
787 @return the column value; if the value is SQL <code>NULL</code>, the
788 value returned is <code>0</code>
790 function TZAbstractResultSet.GetDouble(ColumnIndex: Integer): Double;
792 {$IFNDEF DISABLE_CHECKING}
793 CheckColumnConvertion(ColumnIndex, stDouble);
799 Gets the value of the designated column in the current row
800 of this <code>ResultSet</code> object as
801 a <code>java.sql.BigDecimal</code> in the Java programming language.
803 @param columnIndex the first column is 1, the second is 2, ...
804 @param scale the number of digits to the right of the decimal point
805 @return the column value; if the value is SQL <code>NULL</code>, the
806 value returned is <code>null</code>
808 function TZAbstractResultSet.GetBigDecimal(ColumnIndex: Integer): Extended;
810 {$IFNDEF DISABLE_CHECKING}
811 CheckColumnConvertion(ColumnIndex, stBigDecimal);
817 Gets the value of the designated column in the current row
818 of this <code>ResultSet</code> object as
819 a <code>byte</code> array in the Java programming language.
820 The bytes represent the raw values returned by the driver.
822 @param columnIndex the first column is 1, the second is 2, ...
823 @return the column value; if the value is SQL <code>NULL</code>, the
824 value returned is <code>null</code>
826 function TZAbstractResultSet.GetBytes(ColumnIndex: Integer): TByteDynArray;
828 {$IFNDEF DISABLE_CHECKING}
829 CheckColumnConvertion(ColumnIndex, stBytes);
835 Gets the value of the designated column in the current row
836 of this <code>ResultSet</code> object as
837 a <code>java.sql.Date</code> object in the Java programming language.
839 @param columnIndex the first column is 1, the second is 2, ...
840 @return the column value; if the value is SQL <code>NULL</code>, the
841 value returned is <code>null</code>
843 function TZAbstractResultSet.GetDate(ColumnIndex: Integer): TDateTime;
845 {$IFNDEF DISABLE_CHECKING}
846 CheckColumnConvertion(ColumnIndex, stDate);
852 Gets the value of the designated column in the current row
853 of this <code>ResultSet</code> object as
854 a <code>java.sql.Time</code> object in the Java programming language.
856 @param columnIndex the first column is 1, the second is 2, ...
857 @return the column value; if the value is SQL <code>NULL</code>, the
858 value returned is <code>null</code>
860 function TZAbstractResultSet.GetTime(ColumnIndex: Integer): TDateTime;
862 {$IFNDEF DISABLE_CHECKING}
863 CheckColumnConvertion(ColumnIndex, stTime);
869 Gets the value of the designated column in the current row
870 of this <code>ResultSet</code> object as
871 a <code>java.sql.Timestamp</code> object in the Java programming language.
873 @param columnIndex the first column is 1, the second is 2, ...
874 @return the column value; if the value is SQL <code>NULL</code>, the
875 value returned is <code>null</code>
876 @exception SQLException if a database access error occurs
878 function TZAbstractResultSet.GetTimestamp(ColumnIndex: Integer): TDateTime;
880 {$IFNDEF DISABLE_CHECKING}
881 CheckColumnConvertion(ColumnIndex, stTimestamp);
887 Gets the value of the designated column in the current row
888 of this <code>ResultSet</code> object as
889 a stream of ASCII characters. The value can then be read in chunks from the
890 stream. This method is particularly
891 suitable for retrieving large <char>LONGVARCHAR</char> values.
893 do any necessary conversion from the database format into ASCII.
895 <P><B>Note:</B> All the data in the returned stream must be
896 read prior to getting the value of any other column. The next
897 call to a <code>getXXX</code> method implicitly closes the stream. Also, a
898 stream may return <code>0</code> when the method
899 <code>InputStream.available</code>
900 is called whether there is data available or not.
902 @param columnIndex the first column is 1, the second is 2, ...
903 @return a Java input stream that delivers the database column value
904 as a stream of one-byte ASCII characters; if the value is SQL
905 <code>NULL</code>, the value returned is <code>null</code>
907 function TZAbstractResultSet.GetAsciiStream(ColumnIndex: Integer): TStream;
911 {$IFNDEF DISABLE_CHECKING}
912 CheckColumnConvertion(ColumnIndex, stAsciiStream);
915 if not IsNull(ColumnIndex) then
917 Blob := GetBlob(ColumnIndex);
919 if Self.GetMetaData.GetColumnType(ColumnIndex) = stUnicodeStream then
920 Result := TStringStream.Create(GetValidatedAnsiStringFromBuffer(Blob.GetBuffer,
921 Blob.Length, ConSettings, ConSettings.CTRL_CP))
923 Result := Blob.GetStream;
925 LastWasNull := (Result = nil);
929 Gets the value of a column in the current row as a stream of
930 Gets the value of the designated column in the current row
931 of this <code>ResultSet</code> object as
932 as a stream of Unicode characters.
933 The value can then be read in chunks from the
934 stream. This method is particularly
935 suitable for retrieving large<code>LONGVARCHAR</code>values. The JDBC driver will
936 do any necessary conversion from the database format into Unicode.
937 The byte format of the Unicode stream must be Java UTF-8,
938 as specified in the Java virtual machine specification.
940 <P><B>Note:</B> All the data in the returned stream must be
941 read prior to getting the value of any other column. The next
942 call to a <code>getXXX</code> method implicitly closes the stream. Also, a
943 stream may return <code>0</code> when the method
944 <code>InputStream.available</code>
945 is called whether there is data available or not.
947 @param columnIndex the first column is 1, the second is 2, ...
948 @return a Java input stream that delivers the database column value
949 as a stream in Java UTF-8 byte format; if the value is SQL
950 <code>NULL</code>, the value returned is <code>null</code>
952 function TZAbstractResultSet.GetUnicodeStream(ColumnIndex: Integer): TStream;
956 {$IFNDEF DISABLE_CHECKING}
957 CheckColumnConvertion(ColumnIndex, stUnicodeStream);
960 if not IsNull(ColumnIndex) then
962 Blob := GetBlob(ColumnIndex);
964 Result := Blob.GetUnicodeStream;
966 LastWasNull := (Result = nil);
970 Gets the value of a column in the current row as a stream of
971 Gets the value of the designated column in the current row
972 of this <code>ResultSet</code> object as a binary stream of
973 uninterpreted bytes. The value can then be read in chunks from the
974 stream. This method is particularly
975 suitable for retrieving large <code>LONGVARBINARY</code> values.
977 <P><B>Note:</B> All the data in the returned stream must be
978 read prior to getting the value of any other column. The next
979 call to a <code>getXXX</code> method implicitly closes the stream. Also, a
980 stream may return <code>0</code> when the method
981 <code>InputStream.available</code>
982 is called whether there is data available or not.
984 @param columnIndex the first column is 1, the second is 2, ...
985 @return a Java input stream that delivers the database column value
986 as a stream of uninterpreted bytes;
987 if the value is SQL <code>NULL</code>, the value returned is <code>null</code>
989 function TZAbstractResultSet.GetBinaryStream(ColumnIndex: Integer): TStream;
993 {$IFNDEF DISABLE_CHECKING}
994 CheckColumnConvertion(ColumnIndex, stBinaryStream);
997 if not IsNull(ColumnIndex) then
999 Blob := GetBlob(ColumnIndex);
1001 Result := Blob.GetStream;
1003 LastWasNull := (Result = nil);
1007 Returns the value of the designated column in the current row
1008 of this <code>ResultSet</code> object as a <code>Blob</code> object
1009 in the Java programming language.
1011 @param ColumnIndex the first column is 1, the second is 2, ...
1012 @return a <code>Blob</code> object representing the SQL <code>BLOB</code> value in
1013 the specified column
1015 function TZAbstractResultSet.GetBlob(ColumnIndex: Integer): IZBlob;
1017 {$IFNDEF DISABLE_CHECKING}
1018 CheckBlobColumn(ColumnIndex);
1021 Result := TZAbstractBlob.CreateWithStream(nil, GetStatement.GetConnection);
1025 Returns the value of the designated column in the current row
1026 of this <code>ResultSet</code> object as a <code>IZResultSet</code> object
1027 in the Java programming language.
1029 @param ColumnIndex the first column is 1, the second is 2, ...
1030 @return a <code>IZResultSet</code> object representing the SQL
1031 <code>IZResultSet</code> value in the specified column
1033 function TZAbstractResultSet.GetDataSet(ColumnIndex: Integer): IZDataSet;
1039 Returns the value of the designated column in the current row
1040 of this <code>ResultSet</code> object as a <code>Variant</code> object.
1042 @param ColumnIndex the first column is 1, the second is 2, ...
1043 @return a <code>Variant</code> object representing the SQL
1044 any value in the specified column
1046 function TZAbstractResultSet.GetValue(ColumnIndex: Integer): TZVariant;
1048 Metadata: TZAbstractResultSetMetadata;
1050 {$IFNDEF DISABLE_CHECKING}
1053 Metadata := TZAbstractResultSetMetadata(FMetadata);
1054 {$IFNDEF DISABLE_CHECKING}
1055 if (Metadata = nil) or (ColumnIndex <= 0)
1056 or (ColumnIndex > Metadata.GetColumnCount) then
1058 raise EZSQLException.Create(
1059 Format(SColumnIsNotAccessable, [ColumnIndex]));
1063 case Metadata.GetColumnType(ColumnIndex) of
1066 Result.VType := vtBoolean;
1067 Result.VBoolean := GetBoolean(ColumnIndex);
1069 stByte, stShort, stInteger, stLong:
1071 Result.VType := vtInteger;
1072 Result.VInteger := GetLong(ColumnIndex);
1074 stFloat, stDouble, stBigDecimal:
1076 Result.VType := vtFloat;
1077 Result.VFloat := GetBigDecimal(ColumnIndex);
1079 stDate, stTime, stTimestamp:
1081 Result.VType := vtDateTime;
1082 Result.VDateTime := GetTimestamp(ColumnIndex);
1084 stString, stBytes, stAsciiStream, stBinaryStream:
1086 Result.VType := vtString;
1087 Result.VString := String(GetString(ColumnIndex));
1089 stUnicodeString, stUnicodeStream:
1091 Result.VType := vtUnicodeString;
1092 Result.VUnicodeString := GetUnicodeString(ColumnIndex);
1095 Result.VType := vtNull;
1099 Result.VType := vtNull;
1103 Gets the DefaultExpression value of the designated column in the current row
1104 of this <code>ResultSet</code> object as
1105 a <code>String</code>.
1107 @param columnIndex the first column is 1, the second is 2, ...
1108 @return the DefaultExpression value
1110 function TZAbstractResultSet.GetDefaultExpression(ColumnIndex: Integer): string;
1112 {$IFNDEF DISABLE_CHECKING}
1113 CheckColumnConvertion(ColumnIndex, stString);
1118 //======================================================================
1119 // Methods for accessing results by column name
1120 //======================================================================
1123 Indicates if the value of the designated column in the current row
1124 of this <code>ResultSet</code> object is Null.
1126 @param columnName the SQL name of the column
1127 @return if the value is SQL <code>NULL</code>, the
1128 value returned is <code>true</code>. <code>false</code> otherwise.
1130 function TZAbstractResultSet.IsNullByName(const ColumnName: string): Boolean;
1132 Result := IsNull(GetColumnIndex(ColumnName));
1136 Gets the value of the designated column in the current row
1137 of this <code>ResultSet</code> object as
1138 a <code>PAnsiChar</code> in the Delphi programming language.
1140 @param columnName the SQL name of the column
1141 @return the column value; if the value is SQL <code>NULL</code>, the
1142 value returned is <code>null</code>
1144 function TZAbstractResultSet.GetPCharByName(const ColumnName: string): PChar;
1146 Result := GetPChar(GetColumnIndex(ColumnName));
1150 Gets the value of the designated column in the current row
1151 of this <code>ResultSet</code> object as
1152 a <code>String</code> in the Java programming language.
1154 @param columnName the SQL name of the column
1155 @return the column value; if the value is SQL <code>NULL</code>, the
1156 value returned is <code>null</code>
1158 function TZAbstractResultSet.GetStringByName(const ColumnName: string): String;
1160 Result := GetString(GetColumnIndex(ColumnName));
1164 Gets the value of the designated column in the current row
1165 of this <code>ResultSet</code> object as
1166 a <code>String</code> in the Java programming language.
1168 @param columnName the SQL name of the column
1169 @return the column value; if the value is SQL <code>NULL</code>, the
1170 value returned is <code>null</code>
1172 function TZAbstractResultSet.GetBinaryStringByName(const ColumnName: string): RawByteString;
1174 Result := GetBinaryString(GetColumnIndex(ColumnName));
1178 Gets the value of the designated column in the current row
1179 of this <code>ResultSet</code> object as
1180 a <code>WideString</code> in the Object Pascal programming language.
1182 @param columnName the SQL name of the column
1183 @return the column value; if the value is SQL <code>NULL</code>, the
1184 value returned is <code>null</code>
1186 function TZAbstractResultSet.GetUnicodeStringByName(const ColumnName: string):
1189 Result := GetUnicodeString(GetColumnIndex(ColumnName));
1193 Gets the value of the designated column in the current row
1194 of this <code>ResultSet</code> object as
1195 a <code>boolean</code> in the Java programming language.
1197 @param columnName the SQL name of the column
1198 @return the column value; if the value is SQL <code>NULL</code>, the
1199 value returned is <code>false</code>
1201 function TZAbstractResultSet.GetBooleanByName(const ColumnName: string): Boolean;
1203 Result := GetBoolean(GetColumnIndex(ColumnName));
1207 Gets the value of the designated column in the current row
1208 of this <code>ResultSet</code> object as
1209 a <code>byte</code> in the Java programming language.
1211 @param columnName the SQL name of the column
1212 @return the column value; if the value is SQL <code>NULL</code>, the
1213 value returned is <code>0</code>
1215 function TZAbstractResultSet.GetByteByName(const ColumnName: string): Byte;
1217 Result := GetByte(GetColumnIndex(ColumnName));
1221 Gets the value of the designated column in the current row
1222 of this <code>ResultSet</code> object as
1223 a <code>short</code> in the Java programming language.
1225 @param columnName the SQL name of the column
1226 @return the column value; if the value is SQL <code>NULL</code>, the
1227 value returned is <code>0</code>
1229 function TZAbstractResultSet.GetShortByName(const ColumnName: string): SmallInt;
1231 Result := GetShort(GetColumnIndex(ColumnName));
1235 Gets the value of the designated column in the current row
1236 of this <code>ResultSet</code> object as
1237 an <code>int</code> in the Java programming language.
1239 @param columnName the SQL name of the column
1240 @return the column value; if the value is SQL <code>NULL</code>, the
1241 value returned is <code>0</code>
1243 function TZAbstractResultSet.GetIntByName(const ColumnName: string): Integer;
1245 Result := GetInt(GetColumnIndex(ColumnName));
1249 Gets the value of the designated column in the current row
1250 of this <code>ResultSet</code> object as
1251 a <code>long</code> in the Java programming language.
1253 @param columnName the SQL name of the column
1254 @return the column value; if the value is SQL <code>NULL</code>, the
1255 value returned is <code>0</code>
1257 function TZAbstractResultSet.GetLongByName(const ColumnName: string): Int64;
1259 Result := GetLong(GetColumnIndex(ColumnName));
1263 Gets the value of the designated column in the current row
1264 of this <code>ResultSet</code> object as
1265 a <code>float</code> in the Java programming language.
1267 @param columnName the SQL name of the column
1268 @return the column value; if the value is SQL <code>NULL</code>, the
1269 value returned is <code>0</code>
1271 function TZAbstractResultSet.GetFloatByName(const ColumnName: string): Single;
1273 Result := GetFloat(GetColumnIndex(ColumnName));
1277 Gets the value of the designated column in the current row
1278 of this <code>ResultSet</code> object as
1279 a <code>double</code> in the Java programming language.
1281 @param columnName the SQL name of the column
1282 @return the column value; if the value is SQL <code>NULL</code>, the
1283 value returned is <code>0</code>
1285 function TZAbstractResultSet.GetDoubleByName(const ColumnName: string): Double;
1287 Result := GetDouble(GetColumnIndex(ColumnName));
1291 Gets the value of the designated column in the current row
1292 of this <code>ResultSet</code> object as
1293 a <code>java.math.BigDecimal</code> in the Java programming language.
1295 @param columnName the SQL name of the column
1296 @return the column value; if the value is SQL <code>NULL</code>, the
1297 value returned is <code>null</code>
1299 function TZAbstractResultSet.GetBigDecimalByName(const ColumnName: string): Extended;
1301 Result := GetBigDecimal(GetColumnIndex(ColumnName));
1305 Gets the value of the designated column in the current row
1306 of this <code>ResultSet</code> object as
1307 a <code>byte</code> array in the Java programming language.
1308 The bytes represent the raw values returned by the driver.
1310 @param columnName the SQL name of the column
1311 @return the column value; if the value is SQL <code>NULL</code>, the
1312 value returned is <code>null</code>
1314 function TZAbstractResultSet.GetBytesByName(const ColumnName: string): TByteDynArray;
1316 Result := GetBytes(GetColumnIndex(ColumnName));
1320 Gets the value of the designated column in the current row
1321 of this <code>ResultSet</code> object as
1322 a <code>java.sql.Date</code> object in the Java programming language.
1324 @param columnName the SQL name of the column
1325 @return the column value; if the value is SQL <code>NULL</code>, the
1326 value returned is <code>null</code>
1328 function TZAbstractResultSet.GetDateByName(const ColumnName: string): TDateTime;
1330 Result := GetDate(GetColumnIndex(ColumnName));
1334 Gets the value of the designated column in the current row
1335 of this <code>ResultSet</code> object as
1336 a <code>java.sql.Time</code> object in the Java programming language.
1338 @param columnName the SQL name of the column
1339 @return the column value; if the value is SQL <code>NULL</code>,
1340 the value returned is <code>null</code>
1342 function TZAbstractResultSet.GetTimeByName(const ColumnName: string): TDateTime;
1344 Result := GetTime(GetColumnIndex(ColumnName));
1348 Gets the value of the designated column in the current row
1349 of this <code>ResultSet</code> object as
1350 a <code>java.sql.Timestamp</code> object.
1352 @param columnName the SQL name of the column
1353 @return the column value; if the value is SQL <code>NULL</code>, the
1354 value returned is <code>null</code>
1356 function TZAbstractResultSet.GetTimestampByName(const ColumnName: string): TDateTime;
1358 Result := GetTimestamp(GetColumnIndex(ColumnName));
1362 Gets the value of the designated column in the current row
1363 of this <code>ResultSet</code> object as a stream of
1364 ASCII characters. The value can then be read in chunks from the
1365 stream. This method is particularly
1366 suitable for retrieving large <code>LONGVARCHAR</code> values.
1367 The JDBC driver will
1368 do any necessary conversion from the database format into ASCII.
1370 <P><B>Note:</B> All the data in the returned stream must be
1371 read prior to getting the value of any other column. The next
1372 call to a <code>getXXX</code> method implicitly closes the stream. Also, a
1373 stream may return <code>0</code> when the method <code>available</code>
1374 is called whether there is data available or not.
1376 @param columnName the SQL name of the column
1377 @return a Java input stream that delivers the database column value
1378 as a stream of one-byte ASCII characters.
1379 If the value is SQL <code>NULL</code>,
1380 the value returned is <code>null</code>.
1382 function TZAbstractResultSet.GetAsciiStreamByName(const ColumnName: string): TStream;
1384 Result := GetAsciiStream(GetColumnIndex(ColumnName));
1388 Gets the value of the designated column in the current row
1389 of this <code>ResultSet</code> object as a stream of
1390 Unicode characters. The value can then be read in chunks from the
1391 stream. This method is particularly
1392 suitable for retrieving large <code>LONGVARCHAR</code> values.
1393 The JDBC driver will
1394 do any necessary conversion from the database format into Unicode.
1395 The byte format of the Unicode stream must be Java UTF-8,
1396 as defined in the Java virtual machine specification.
1398 <P><B>Note:</B> All the data in the returned stream must be
1399 read prior to getting the value of any other column. The next
1400 call to a <code>getXXX</code> method implicitly closes the stream. Also, a
1401 stream may return <code>0</code> when the method <code>available</code>
1402 is called whether there is data available or not.
1404 @param columnName the SQL name of the column
1405 @return a Java input stream that delivers the database column value
1406 as a stream of two-byte Unicode characters.
1407 If the value is SQL <code>NULL</code>, the value returned is <code>null</code>.
1409 function TZAbstractResultSet.GetUnicodeStreamByName(const ColumnName: string): TStream;
1411 Result := GetUnicodeStream(GetColumnIndex(ColumnName));
1415 Gets the value of the designated column in the current row
1416 of this <code>ResultSet</code> object as a stream of uninterpreted
1418 The value can then be read in chunks from the
1419 stream. This method is particularly
1420 suitable for retrieving large <code>LONGVARBINARY</code>
1423 <P><B>Note:</B> All the data in the returned stream must be
1424 read prior to getting the value of any other column. The next
1425 call to a <code>getXXX</code> method implicitly closes the stream. Also, a
1426 stream may return <code>0</code> when the method <code>available</code>
1427 is called whether there is data available or not.
1429 @param columnName the SQL name of the column
1430 @return a Java input stream that delivers the database column value
1431 as a stream of uninterpreted bytes;
1432 if the value is SQL <code>NULL</code>, the result is <code>null</code>
1434 function TZAbstractResultSet.GetBinaryStreamByName(const ColumnName: string): TStream;
1436 Result := GetBinaryStream(GetColumnIndex(ColumnName));
1440 Returns the value of the designated column in the current row
1441 of this <code>ResultSet</code> object as a <code>Blob</code> object
1442 in the Java programming language.
1444 @param colName the name of the column from which to retrieve the value
1445 @return a <code>Blob</code> object representing the SQL <code>BLOB</code> value in
1446 the specified column
1448 function TZAbstractResultSet.GetBlobByName(const ColumnName: string): IZBlob;
1450 Result := GetBlob(GetColumnIndex(ColumnName));
1453 function TZAbstractResultSet.GetDataSetByName(const ColumnName: string): IZDataSet;
1455 Result := GetDataSet(GetColumnIndex(ColumnName));
1459 Returns the value of the designated column in the current row
1460 of this <code>ResultSet</code> object as a <code>Variant</code> object.
1462 @param colName the name of the column from which to retrieve the value
1463 @return a <code>Blob</code> object representing the SQL <code>Any</code>
1464 value in the specified column
1466 function TZAbstractResultSet.GetValueByName(const ColumnName: string): TZVariant;
1468 Result := GetValue(GetColumnIndex(ColumnName));
1471 //=====================================================================
1472 // Advanced features:
1473 //=====================================================================
1476 Returns the first warning reported by calls on this
1477 <code>ResultSet</code> object.
1478 Subsequent warnings on this <code>ResultSet</code> object
1479 will be chained to the <code>SQLWarning</code> object that
1480 this method returns.
1482 <P>The warning chain is automatically cleared each time a new
1485 <P><B>Note:</B> This warning chain only covers warnings caused
1486 by <code>ResultSet</code> methods. Any warning caused by
1487 <code>Statement</code> methods
1488 (such as reading OUT parameters) will be chained on the
1489 <code>Statement</code> object.
1491 @return the first <code>SQLWarning</code> object reported or <code>null</code>
1493 function TZAbstractResultSet.GetWarnings: EZSQLWarning;
1499 Clears all warnings reported on this <code>ResultSet</code> object.
1500 After this method is called, the method <code>getWarnings</code>
1501 returns <code>null</code> until a new warning is
1502 reported for this <code>ResultSet</code> object.
1504 procedure TZAbstractResultSet.ClearWarnings;
1509 Gets the name of the SQL cursor used by this <code>ResultSet</code>
1512 <P>In SQL, a result table is retrieved through a cursor that is
1513 named. The current row of a result set can be updated or deleted
1514 using a positioned update/delete statement that references the
1515 cursor name. To insure that the cursor has the proper isolation
1516 level to support update, the cursor's <code>select</code> statement should be
1517 of the form 'select for update'. If the 'for update' clause is
1518 omitted, the positioned updates may fail.
1520 <P>The JDBC API supports this SQL feature by providing the name of the
1521 SQL cursor used by a <code>ResultSet</code> object.
1522 The current row of a <code>ResultSet</code> object
1523 is also the current row of this SQL cursor.
1525 <P><B>Note:</B> If positioned update is not supported, a
1526 <code>SQLException</code> is thrown.
1528 @return the SQL name for this <code>ResultSet</code> object's cursor
1530 function TZAbstractResultSet.GetCursorName: AnsiString;
1536 Retrieves the number, types and properties of
1537 this <code>ResultSet</code> object's columns.
1538 @return the description of this <code>ResultSet</code> object's columns
1540 function TZAbstractResultSet.GetMetaData: IZResultSetMetaData;
1542 Result := TZAbstractResultSetMetadata(FMetadata);
1546 Maps the given <code>ResultSet</code> column name to its
1547 <code>ResultSet</code> column index.
1549 @param columnName the name of the column
1550 @return the column index of the given column name
1552 function TZAbstractResultSet.GetColumnIndex(const ColumnName: string): Integer;
1554 Result := FindColumn(ColumnName);
1557 raise EZSQLException.Create(Format(SColumnWasNotFound, [ColumnName]));
1561 Maps the given <code>ResultSet</code> column name to its
1562 <code>ResultSet</code> column index.
1564 @param columnName the name of the column
1565 @return the column index of the given column name
1567 function TZAbstractResultSet.FindColumn(const ColumnName: string): Integer;
1570 Metadata: TZAbstractResultSetMetadata;
1573 Metadata := TZAbstractResultSetMetadata(FMetadata);
1576 { Search for case sensitive columns. }
1577 for I := 1 to Metadata.GetColumnCount do
1579 if Metadata.GetColumnLabel(I) = ColumnName then
1586 { Search for case insensitive columns. }
1587 for I := 1 to Metadata.GetColumnCount do
1589 if AnsiUpperCase(Metadata.GetColumnLabel(I)) = AnsiUpperCase(ColumnName) then
1597 //---------------------------------------------------------------------
1598 // Traversal/Positioning
1599 //---------------------------------------------------------------------
1602 Indicates whether the cursor is before the first row in
1603 this <code>ResultSet</code> object.
1605 @return <code>true</code> if the cursor is before the first row;
1606 <code>false</code> if the cursor is at any other position or the
1607 result set contains no rows
1609 function TZAbstractResultSet.IsBeforeFirst: Boolean;
1611 Result := (FRowNo = 0);
1615 Indicates whether the cursor is after the last row in
1616 this <code>ResultSet</code> object.
1618 @return <code>true</code> if the cursor is after the last row;
1619 <code>false</code> if the cursor is at any other position or the
1620 result set contains no rows
1622 function TZAbstractResultSet.IsAfterLast: Boolean;
1624 Result := {(FLastRowNo > 0) and} (FRowNo > FLastRowNo);
1628 Indicates whether the cursor is on the first row of
1629 this <code>ResultSet</code> object.
1631 @return <code>true</code> if the cursor is on the first row;
1632 <code>false</code> otherwise
1634 function TZAbstractResultSet.IsFirst: Boolean;
1636 Result := (FRowNo = 1);
1640 Indicates whether the cursor is on the last row of
1641 this <code>ResultSet</code> object.
1642 Note: Calling the method <code>isLast</code> may be expensive
1643 because the JDBC driver
1644 might need to fetch ahead one row in order to determine
1645 whether the current row is the last row in the result set.
1647 @return <code>true</code> if the cursor is on the last row;
1648 <code>false</code> otherwise
1650 function TZAbstractResultSet.IsLast: Boolean;
1652 Result := {(FLastRowNo > 0) and} (FRowNo = FLastRowNo);
1656 Moves the cursor to the front of
1657 this <code>ResultSet</code> object, just before the
1658 first row. This method has no effect if the result set contains no rows.
1660 procedure TZAbstractResultSet.BeforeFirst;
1666 Moves the cursor to the end of
1667 this <code>ResultSet</code> object, just after the
1668 last row. This method has no effect if the result set contains no rows.
1670 procedure TZAbstractResultSet.AfterLast;
1677 Moves the cursor to the first row in
1678 this <code>ResultSet</code> object.
1680 @return <code>true</code> if the cursor is on a valid row;
1681 <code>false</code> if there are no rows in the result set
1683 function TZAbstractResultSet.First: Boolean;
1685 Result := MoveAbsolute(1);
1689 Moves the cursor to the last row in
1690 this <code>ResultSet</code> object.
1692 @return <code>true</code> if the cursor is on a valid row;
1693 <code>false</code> if there are no rows in the result set
1695 function TZAbstractResultSet.Last: Boolean;
1697 Result := MoveAbsolute(FLastRowNo);
1701 Retrieves the current row number. The first row is number 1, the
1702 second number 2, and so on.
1703 @return the current row number; <code>0</code> if there is no current row
1705 function TZAbstractResultSet.GetRow: Integer;
1711 Moves the cursor to the given row number in
1712 this <code>ResultSet</code> object.
1714 <p>If the row number is positive, the cursor moves to
1715 the given row number with respect to the
1716 beginning of the result set. The first row is row 1, the second
1717 is row 2, and so on.
1719 <p>If the given row number is negative, the cursor moves to
1720 an absolute row position with respect to
1721 the end of the result set. For example, calling the method
1722 <code>absolute(-1)</code> positions the
1723 cursor on the last row; calling the method <code>absolute(-2)</code>
1724 moves the cursor to the next-to-last row, and so on.
1726 <p>An attempt to position the cursor beyond the first/last row in
1727 the result set leaves the cursor before the first row or after
1730 <p><B>Note:</B> Calling <code>absolute(1)</code> is the same
1731 as calling <code>first()</code>. Calling <code>absolute(-1)</code>
1732 is the same as calling <code>last()</code>.
1734 @return <code>true</code> if the cursor is on the result set;
1735 <code>false</code> otherwise
1737 function TZAbstractResultSet.MoveAbsolute(Row: Integer): Boolean;
1740 RaiseForwardOnlyException;
1744 Moves the cursor a relative number of rows, either positive or negative.
1745 Attempting to move beyond the first/last row in the
1746 result set positions the cursor before/after the
1747 the first/last row. Calling <code>relative(0)</code> is valid, but does
1748 not change the cursor position.
1750 <p>Note: Calling the method <code>relative(1)</code>
1751 is different from calling the method <code>next()</code>
1752 because is makes sense to call <code>next()</code> when there
1754 for example, when the cursor is positioned before the first row
1755 or after the last row of the result set.
1757 @return <code>true</code> if the cursor is on a row;
1758 <code>false</code> otherwise
1760 function TZAbstractResultSet.MoveRelative(Rows: Integer): Boolean;
1762 Result := MoveAbsolute(FRowNo + Rows);
1766 Moves the cursor to the previous row in this
1767 <code>ResultSet</code> object.
1769 <p><B>Note:</B> Calling the method <code>previous()</code> is not the same as
1770 calling the method <code>relative(-1)</code> because it
1771 makes sense to call</code>previous()</code> when there is no current row.
1773 @return <code>true</code> if the cursor is on a valid row;
1774 <code>false</code> if it is off the result set
1776 function TZAbstractResultSet.Previous: Boolean;
1778 Result := MoveAbsolute(FRowNo - 1);
1782 Moves the cursor down one row from its current position.
1783 A <code>ResultSet</code> cursor is initially positioned
1784 before the first row; the first call to the method
1785 <code>next</code> makes the first row the current row; the
1786 second call makes the second row the current row, and so on.
1788 <P>If an input stream is open for the current row, a call
1789 to the method <code>next</code> will
1790 implicitly close it. A <code>ResultSet</code> object's
1791 warning chain is cleared when a new row is read.
1793 @return <code>true</code> if the new current row is valid;
1794 <code>false</code> if there are no more rows
1796 function TZAbstractResultSet.Next: Boolean;
1798 Result := MoveAbsolute(FRowNo + 1);
1801 //---------------------------------------------------------------------
1803 //---------------------------------------------------------------------
1806 Returns the fetch direction for this
1807 <code>ResultSet</code> object.
1808 @return the current fetch direction for this <code>ResultSet</code> object
1810 function TZAbstractResultSet.GetFetchDirection: TZFetchDirection;
1812 Result := FFetchDirection;
1816 Gives a hint as to the direction in which the rows in this
1817 <code>ResultSet</code> object will be processed.
1818 The initial value is determined by the
1819 <code>Statement</code> object
1820 that produced this <code>ResultSet</code> object.
1821 The fetch direction may be changed at any time.
1823 procedure TZAbstractResultSet.SetFetchDirection(Direction: TZFetchDirection);
1825 if Direction <> fdForward then
1826 RaiseUnsupportedException;
1830 Returns the fetch size for this
1831 <code>ResultSet</code> object.
1832 @return the current fetch size for this <code>ResultSet</code> object
1834 function TZAbstractResultSet.GetFetchSize: Integer;
1836 Result := FFetchSize;
1840 Gives the JDBC driver a hint as to the number of rows that should
1841 be fetched from the database when more rows are needed for this
1842 <code>ResultSet</code> object.
1843 If the fetch size specified is zero, the JDBC driver
1844 ignores the value and is free to make its own best guess as to what
1845 the fetch size should be. The default value is set by the
1846 <code>Statement</code> object
1847 that created the result set. The fetch size may be changed at any time.
1849 @param rows the number of rows to fetch
1851 procedure TZAbstractResultSet.SetFetchSize(Rows: Integer);
1857 Returns the type of this <code>ResultSet</code> object.
1858 The type is determined by the <code>Statement</code> object
1859 that created the result set.
1861 @return <code>TYPE_FORWARD_ONLY</code>,
1862 <code>TYPE_SCROLL_INSENSITIVE</code>,
1863 or <code>TYPE_SCROLL_SENSITIVE</code>
1865 function TZAbstractResultSet.GetType: TZResultSetType;
1867 Result := FResultSetType;
1871 Returns the concurrency mode of this <code>ResultSet</code> object.
1872 The concurrency used is determined by the
1873 <code>Statement</code> object that created the result set.
1875 @return the concurrency type, either <code>CONCUR_READ_ONLY</code>
1876 or <code>CONCUR_UPDATABLE</code>
1878 function TZAbstractResultSet.GetConcurrency: TZResultSetConcurrency;
1880 Result := FResultSetConcurrency;
1884 Gets an assigned post locate mode.
1885 @param the assigned post locate mode.
1887 function TZAbstractResultSet.GetLocateUpdates: TZLocateUpdatesMode;
1889 Result := FLocateUpdates;
1892 function TZAbstractResultSet.GetPostUpdates: TZPostUpdatesMode;
1894 Result := FPostUpdates;
1897 //---------------------------------------------------------------------
1899 //---------------------------------------------------------------------
1902 Indicates whether the current row has been updated. The value returned
1903 depends on whether or not the result set can detect updates.
1905 @return <code>true</code> if the row has been visibly updated
1906 by the owner or another, and updates are detected
1908 function TZAbstractResultSet.RowUpdated: Boolean;
1914 Indicates whether the current row has had an insertion.
1915 The value returned depends on whether or not this
1916 <code>ResultSet</code> object can detect visible inserts.
1918 @return <code>true</code> if a row has had an insertion
1919 and insertions are detected; <code>false</code> otherwise
1921 function TZAbstractResultSet.RowInserted: Boolean;
1927 Indicates whether a row has been deleted. A deleted row may leave
1928 a visible "hole" in a result set. This method can be used to
1929 detect holes in a result set. The value returned depends on whether
1930 or not this <code>ResultSet</code> object can detect deletions.
1932 @return <code>true</code> if a row was deleted and deletions are detected;
1933 <code>false</code> otherwise
1935 function TZAbstractResultSet.RowDeleted: Boolean;
1941 Gives a nullable column a null value.
1943 The <code>updateXXX</code> methods are used to update column values in the
1944 current row or the insert row. The <code>updateXXX</code> methods do not
1945 update the underlying database; instead the <code>updateRow</code>
1946 or <code>insertRow</code> methods are called to update the database.
1948 @param columnIndex the first column is 1, the second is 2, ...
1950 procedure TZAbstractResultSet.UpdateNull(ColumnIndex: Integer);
1952 RaiseReadOnlyException;
1956 Updates the designated column with a <code>boolean</code> value.
1957 The <code>updateXXX</code> methods are used to update column values in the
1958 current row or the insert row. The <code>updateXXX</code> methods do not
1959 update the underlying database; instead the <code>updateRow</code> or
1960 <code>insertRow</code> methods are called to update the database.
1962 @param columnIndex the first column is 1, the second is 2, ...
1963 @param x the new column value
1965 procedure TZAbstractResultSet.UpdateBoolean(ColumnIndex: Integer; Value: Boolean);
1967 RaiseReadOnlyException;
1971 Updates the designated column with a <code>byte</code> value.
1972 The <code>updateXXX</code> methods are used to update column values in the
1973 current row or the insert row. The <code>updateXXX</code> methods do not
1974 update the underlying database; instead the <code>updateRow</code> or
1975 <code>insertRow</code> methods are called to update the database.
1978 @param columnIndex the first column is 1, the second is 2, ...
1979 @param x the new column value
1981 procedure TZAbstractResultSet.UpdateByte(ColumnIndex: Integer;
1984 RaiseReadOnlyException;
1988 Updates the designated column with a <code>short</code> value.
1989 The <code>updateXXX</code> methods are used to update column values in the
1990 current row or the insert row. The <code>updateXXX</code> methods do not
1991 update the underlying database; instead the <code>updateRow</code> or
1992 <code>insertRow</code> methods are called to update the database.
1994 @param columnIndex the first column is 1, the second is 2, ...
1995 @param x the new column value
1997 procedure TZAbstractResultSet.UpdateShort(ColumnIndex: Integer; Value: SmallInt);
1999 RaiseReadOnlyException;
2003 Updates the designated column with an <code>int</code> value.
2004 The <code>updateXXX</code> methods are used to update column values in the
2005 current row or the insert row. The <code>updateXXX</code> methods do not
2006 update the underlying database; instead the <code>updateRow</code> or
2007 <code>insertRow</code> methods are called to update the database.
2009 @param columnIndex the first column is 1, the second is 2, ...
2010 @param x the new column value
2012 procedure TZAbstractResultSet.UpdateInt(ColumnIndex: Integer; Value: Integer);
2014 RaiseReadOnlyException;
2018 Updates the designated column with a <code>long</code> value.
2019 The <code>updateXXX</code> methods are used to update column values in the
2020 current row or the insert row. The <code>updateXXX</code> methods do not
2021 update the underlying database; instead the <code>updateRow</code> or
2022 <code>insertRow</code> methods are called to update the database.
2024 @param columnIndex the first column is 1, the second is 2, ...
2025 @param x the new column value
2027 procedure TZAbstractResultSet.UpdateLong(ColumnIndex: Integer; Value: Int64);
2029 RaiseReadOnlyException;
2033 Updates the designated column with a <code>float</code> value.
2034 The <code>updateXXX</code> methods are used to update column values in the
2035 current row or the insert row. The <code>updateXXX</code> methods do not
2036 update the underlying database; instead the <code>updateRow</code> or
2037 <code>insertRow</code> methods are called to update the database.
2039 @param columnIndex the first column is 1, the second is 2, ...
2040 @param x the new column value
2042 procedure TZAbstractResultSet.UpdateFloat(ColumnIndex: Integer; Value: Single);
2044 RaiseReadOnlyException;
2048 Updates the designated column with a <code>double</code> value.
2049 The <code>updateXXX</code> methods are used to update column values in the
2050 current row or the insert row. The <code>updateXXX</code> methods do not
2051 update the underlying database; instead the <code>updateRow</code> or
2052 <code>insertRow</code> methods are called to update the database.
2054 @param columnIndex the first column is 1, the second is 2, ...
2055 @param x the new column value
2057 procedure TZAbstractResultSet.UpdateDouble(ColumnIndex: Integer; Value: Double);
2059 RaiseReadOnlyException;
2063 Updates the designated column with a <code>java.math.BigDecimal</code>
2065 The <code>updateXXX</code> methods are used to update column values in the
2066 current row or the insert row. The <code>updateXXX</code> methods do not
2067 update the underlying database; instead the <code>updateRow</code> or
2068 <code>insertRow</code> methods are called to update the database.
2070 @param columnIndex the first column is 1, the second is 2, ...
2071 @param x the new column value
2073 procedure TZAbstractResultSet.UpdateBigDecimal(ColumnIndex: Integer;
2076 RaiseReadOnlyException;
2080 Updates the designated column with a <code>String</code> value.
2081 The <code>updateXXX</code> methods are used to update column values in the
2082 current row or the insert row. The <code>updateXXX</code> methods do not
2083 update the underlying database; instead the <code>updateRow</code> or
2084 <code>insertRow</code> methods are called to update the database.
2086 @param columnIndex the first column is 1, the second is 2, ...
2087 @param x the new column value
2089 procedure TZAbstractResultSet.UpdatePChar(ColumnIndex: Integer; Value: PChar);
2091 UpdateString(ColumnIndex, Value);
2095 Updates the designated column with a <code>String</code> value.
2096 The <code>updateXXX</code> methods are used to update column values in the
2097 current row or the insert row. The <code>updateXXX</code> methods do not
2098 update the underlying database; instead the <code>updateRow</code> or
2099 <code>insertRow</code> methods are called to update the database.
2101 @param columnIndex the first column is 1, the second is 2, ...
2102 @param x the new column value
2104 procedure TZAbstractResultSet.UpdateString(ColumnIndex: Integer; const Value: String);
2106 RaiseReadOnlyException;
2110 Updates the designated column with a <code>String</code> value.
2111 The <code>updateXXX</code> methods are used to update column values in the
2112 current row or the insert row. The <code>updateXXX</code> methods do not
2113 update the underlying database; instead the <code>updateRow</code> or
2114 <code>insertRow</code> methods are called to update the database.
2116 @param columnIndex the first column is 1, the second is 2, ...
2117 @param x the new column value
2119 procedure TZAbstractResultSet.UpdateBinaryString(ColumnIndex: Integer; const Value: RawByteString);
2121 case GetMetaData.GetColumnType(ColumnIndex) of
2122 stBytes: UpdateBytes(ColumnIndex, StrToBytes(Value));
2123 stBinaryStream: GetBlob(ColumnIndex).SetString(Value);
2125 UpdateString(ColumnIndex, ZDbcString(Value));
2130 Updates the designated column with a <code>WideString</code> value.
2131 The <code>updateXXX</code> methods are used to update column values in the
2132 current row or the insert row. The <code>updateXXX</code> methods do not
2133 update the underlying database; instead the <code>updateRow</code> or
2134 <code>insertRow</code> methods are called to update the database.
2136 @param columnIndex the first column is 1, the second is 2, ...
2137 @param x the new column value
2139 procedure TZAbstractResultSet.UpdateUnicodeString(ColumnIndex: Integer;
2140 const Value: WideString);
2142 RaiseReadOnlyException;
2146 Updates the designated column with a <code>byte</code> array value.
2147 The <code>updateXXX</code> methods are used to update column values in the
2148 current row or the insert row. The <code>updateXXX</code> methods do not
2149 update the underlying database; instead the <code>updateRow</code> or
2150 <code>insertRow</code> methods are called to update the database.
2152 @param columnIndex the first column is 1, the second is 2, ...
2153 @param x the new column value
2155 procedure TZAbstractResultSet.UpdateBytes(ColumnIndex: Integer;
2156 const Value: TByteDynArray);
2158 RaiseReadOnlyException;
2162 Updates the designated column with a <code>java.sql.Date</code> value.
2163 The <code>updateXXX</code> methods are used to update column values in the
2164 current row or the insert row. The <code>updateXXX</code> methods do not
2165 update the underlying database; instead the <code>updateRow</code> or
2166 <code>insertRow</code> methods are called to update the database.
2168 @param columnIndex the first column is 1, the second is 2, ...
2169 @param x the new column value
2171 procedure TZAbstractResultSet.UpdateDate(ColumnIndex: Integer; Value: TDateTime);
2173 RaiseReadOnlyException;
2177 Updates the designated column with a <code>java.sql.Time</code> value.
2178 The <code>updateXXX</code> methods are used to update column values in the
2179 current row or the insert row. The <code>updateXXX</code> methods do not
2180 update the underlying database; instead the <code>updateRow</code> or
2181 <code>insertRow</code> methods are called to update the database.
2183 @param columnIndex the first column is 1, the second is 2, ...
2184 @param x the new column value
2186 procedure TZAbstractResultSet.UpdateTime(ColumnIndex: Integer; Value: TDateTime);
2188 RaiseReadOnlyException;
2192 Updates the designated column with a <code>java.sql.Timestamp</code>
2194 The <code>updateXXX</code> methods are used to update column values in the
2195 current row or the insert row. The <code>updateXXX</code> methods do not
2196 update the underlying database; instead the <code>updateRow</code> or
2197 <code>insertRow</code> methods are called to update the database.
2199 @param columnIndex the first column is 1, the second is 2, ...
2200 @param x the new column value
2202 procedure TZAbstractResultSet.UpdateTimestamp(ColumnIndex: Integer;
2205 RaiseReadOnlyException;
2209 Updates the designated column with an ascii stream value.
2210 The <code>updateXXX</code> methods are used to update column values in the
2211 current row or the insert row. The <code>updateXXX</code> methods do not
2212 update the underlying database; instead the <code>updateRow</code> or
2213 <code>insertRow</code> methods are called to update the database.
2215 @param columnIndex the first column is 1, the second is 2, ...
2216 @param x the new column value
2218 procedure TZAbstractResultSet.UpdateAsciiStream(ColumnIndex: Integer;
2221 RaiseReadOnlyException;
2225 Updates the designated column with a binary stream value.
2226 The <code>updateXXX</code> methods are used to update column values in the
2227 current row or the insert row. The <code>updateXXX</code> methods do not
2228 update the underlying database; instead the <code>updateRow</code> or
2229 <code>insertRow</code> methods are called to update the database.
2231 @param columnIndex the first column is 1, the second is 2, ...
2232 @param x the new column value
2233 @param length the length of the stream
2235 procedure TZAbstractResultSet.UpdateBinaryStream(ColumnIndex: Integer;
2238 RaiseReadOnlyException;
2241 procedure TZAbstractResultSet.UpdateDataSet(ColumnIndex: Integer; Value: IZDataSet);
2243 RaiseReadOnlyException;
2246 Updates the designated column with a character stream value.
2247 The <code>updateXXX</code> methods are used to update column values in the
2248 current row or the insert row. The <code>updateXXX</code> methods do not
2249 update the underlying database; instead the <code>updateRow</code> or
2250 <code>insertRow</code> methods are called to update the database.
2252 @param columnIndex the first column is 1, the second is 2, ...
2253 @param x the new column value
2255 procedure TZAbstractResultSet.UpdateUnicodeStream(ColumnIndex: Integer;
2258 RaiseReadOnlyException;
2262 Updates the designated column with a variant value.
2263 The <code>updateXXX</code> methods are used to update column values in the
2264 current row or the insert row. The <code>updateXXX</code> methods do not
2265 update the underlying database; instead the <code>updateRow</code> or
2266 <code>insertRow</code> methods are called to update the database.
2268 @param columnIndex the first column is 1, the second is 2, ...
2269 @param x the new column value
2271 procedure TZAbstractResultSet.UpdateValue(ColumnIndex: Integer;
2272 const Value: TZVariant);
2275 vtBoolean: UpdateBoolean(ColumnIndex, Value.VBoolean);
2276 vtInteger: UpdateLong(ColumnIndex, Value.VInteger);
2277 vtFloat: UpdateBigDecimal(ColumnIndex, Value.VFloat);
2278 vtString: UpdateString(ColumnIndex, Value.VString);
2279 vtDateTime: UpdateTimestamp(ColumnIndex, Value.VDateTime);
2280 vtUnicodeString: UpdateUnicodeString(ColumnIndex, Value.VUnicodeString);
2282 UpdateNull(ColumnIndex);
2287 Updates the DefaultExpression of the designated column with a <code>String</code> value.
2288 This changes the behaviour of the RowAccessor used by the Resultset
2289 @param columnIndex the first column is 1, the second is 2, ...
2290 @param x the new DefaultExpression value for the column
2292 procedure TZAbstractResultSet.UpdateDefaultExpression(ColumnIndex: Integer; const Value: string);
2294 RaiseReadOnlyException;
2298 Updates the designated column with a <code>null</code> value.
2299 The <code>updateXXX</code> methods are used to update column values in the
2300 current row or the insert row. The <code>updateXXX</code> methods do not
2301 update the underlying database; instead the <code>updateRow</code> or
2302 <code>insertRow</code> methods are called to update the database.
2304 @param columnName the name of the column
2306 procedure TZAbstractResultSet.UpdateNullByName(const ColumnName: string);
2308 UpdateNull(GetColumnIndex(ColumnName));
2312 Updates the designated column with a <code>boolean</code> value.
2313 The <code>updateXXX</code> methods are used to update column values in the
2314 current row or the insert row. The <code>updateXXX</code> methods do not
2315 update the underlying database; instead the <code>updateRow</code> or
2316 <code>insertRow</code> methods are called to update the database.
2318 @param columnName the name of the column
2319 @param x the new column value
2321 procedure TZAbstractResultSet.UpdateBooleanByName(const ColumnName: string;
2324 UpdateBoolean(GetColumnIndex(ColumnName), Value);
2328 Updates the designated column with a <code>byte</code> value.
2329 The <code>updateXXX</code> methods are used to update column values in the
2330 current row or the insert row. The <code>updateXXX</code> methods do not
2331 update the underlying database; instead the <code>updateRow</code> or
2332 <code>insertRow</code> methods are called to update the database.
2334 @param columnName the name of the column
2335 @param x the new column value
2337 procedure TZAbstractResultSet.UpdateByteByName(const ColumnName: string;
2340 UpdateByte(GetColumnIndex(ColumnName), Value);
2344 Updates the designated column with a <code>short</code> value.
2345 The <code>updateXXX</code> methods are used to update column values in the
2346 current row or the insert row. The <code>updateXXX</code> methods do not
2347 update the underlying database; instead the <code>updateRow</code> or
2348 <code>insertRow</code> methods are called to update the database.
2350 @param columnName the name of the column
2351 @param x the new column value
2353 procedure TZAbstractResultSet.UpdateShortByName(const ColumnName: string;
2356 UpdateShort(GetColumnIndex(ColumnName), Value);
2360 Updates the designated column with an <code>int</code> value.
2361 The <code>updateXXX</code> methods are used to update column values in the
2362 current row or the insert row. The <code>updateXXX</code> methods do not
2363 update the underlying database; instead the <code>updateRow</code> or
2364 <code>insertRow</code> methods are called to update the database.
2366 @param columnName the name of the column
2367 @param x the new column value
2369 procedure TZAbstractResultSet.UpdateIntByName(const ColumnName: string;
2372 UpdateInt(GetColumnIndex(ColumnName), Value);
2376 Updates the designated column with a <code>long</code> value.
2377 The <code>updateXXX</code> methods are used to update column values in the
2378 current row or the insert row. The <code>updateXXX</code> methods do not
2379 update the underlying database; instead the <code>updateRow</code> or
2380 <code>insertRow</code> methods are called to update the database.
2382 @param columnName the name of the column
2383 @param x the new column value
2385 procedure TZAbstractResultSet.UpdateLongByName(const ColumnName: string;
2388 UpdateLong(GetColumnIndex(ColumnName), Value);
2392 Updates the designated column with a <code>float </code> value.
2393 The <code>updateXXX</code> methods are used to update column values in the
2394 current row or the insert row. The <code>updateXXX</code> methods do not
2395 update the underlying database; instead the <code>updateRow</code> or
2396 <code>insertRow</code> methods are called to update the database.
2398 @param columnName the name of the column
2399 @param x the new column value
2401 procedure TZAbstractResultSet.UpdateFloatByName(const ColumnName: string;
2404 UpdateFloat(GetColumnIndex(ColumnName), Value);
2408 Updates the designated column with a <code>double</code> value.
2409 The <code>updateXXX</code> methods are used to update column values in the
2410 current row or the insert row. The <code>updateXXX</code> methods do not
2411 update the underlying database; instead the <code>updateRow</code> or
2412 <code>insertRow</code> methods are called to update the database.
2414 @param columnName the name of the column
2415 @param x the new column value
2417 procedure TZAbstractResultSet.UpdateDoubleByName(const ColumnName: string;
2420 UpdateDouble(GetColumnIndex(ColumnName), Value);
2424 Updates the designated column with a <code>java.sql.BigDecimal</code>
2426 The <code>updateXXX</code> methods are used to update column values in the
2427 current row or the insert row. The <code>updateXXX</code> methods do not
2428 update the underlying database; instead the <code>updateRow</code> or
2429 <code>insertRow</code> methods are called to update the database.
2431 @param columnName the name of the column
2432 @param x the new column value
2434 procedure TZAbstractResultSet.UpdateBigDecimalByName(const ColumnName: string;
2437 UpdateBigDecimal(GetColumnIndex(ColumnName), Value);
2441 Updates the designated column with a <code>String</code> value.
2442 The <code>updateXXX</code> methods are used to update column values in the
2443 current row or the insert row. The <code>updateXXX</code> methods do not
2444 update the underlying database; instead the <code>updateRow</code> or
2445 <code>insertRow</code> methods are called to update the database.
2447 @param columnName the name of the column
2448 @param x the new column value
2450 procedure TZAbstractResultSet.UpdatePCharByName(const ColumnName: string;
2453 UpdatePChar(GetColumnIndex(ColumnName), Value);
2457 Updates the designated column with a <code>String</code> value.
2458 The <code>updateXXX</code> methods are used to update column values in the
2459 current row or the insert row. The <code>updateXXX</code> methods do not
2460 update the underlying database; instead the <code>updateRow</code> or
2461 <code>insertRow</code> methods are called to update the database.
2463 @param columnName the name of the column
2464 @param x the new column value
2466 procedure TZAbstractResultSet.UpdateStringByName(const ColumnName: string;
2467 const Value: String);
2469 UpdateString(GetColumnIndex(ColumnName), Value);
2473 Updates the designated column with a <code>String</code> value.
2474 The <code>updateXXX</code> methods are used to update column values in the
2475 current row or the insert row. The <code>updateXXX</code> methods do not
2476 update the underlying database; instead the <code>updateRow</code> or
2477 <code>insertRow</code> methods are called to update the database.
2479 @param columnName the name of the column
2480 @param x the new column value
2482 procedure TZAbstractResultSet.UpdateBinaryStringByName(const ColumnName: string;
2483 const Value: RawByteString);
2485 UpdateBinaryString(GetColumnIndex(ColumnName), Value);
2489 Updates the designated column with a <code>WideString</code> value.
2490 The <code>updateXXX</code> methods are used to update column values in the
2491 current row or the insert row. The <code>updateXXX</code> methods do not
2492 update the underlying database; instead the <code>updateRow</code> or
2493 <code>insertRow</code> methods are called to update the database.
2495 @param columnName the name of the column
2496 @param x the new column value
2498 procedure TZAbstractResultSet.UpdateUnicodeStringByName(const ColumnName: string;
2499 const Value: WideString);
2501 UpdateUnicodeString(GetColumnIndex(ColumnName), Value);
2505 Updates the designated column with a <code>boolean</code> value.
2506 The <code>updateXXX</code> methods are used to update column values in the
2507 current row or the insert row. The <code>updateXXX</code> methods do not
2508 update the underlying database; instead the <code>updateRow</code> or
2509 <code>insertRow</code> methods are called to update the database.
2513 Updates a column with a byte array value.
2515 The <code>updateXXX</code> methods are used to update column values in the
2516 current row, or the insert row. The <code>updateXXX</code> methods do not
2517 update the underlying database; instead the <code>updateRow</code> or <code>insertRow</code>
2518 methods are called to update the database.
2520 @param columnName the name of the column
2521 @param x the new column value
2523 procedure TZAbstractResultSet.UpdateBytesByName(const ColumnName: string;
2524 const Value: TByteDynArray);
2526 UpdateBytes(GetColumnIndex(ColumnName), Value);
2530 Updates the designated column with a <code>java.sql.Date</code> value.
2531 The <code>updateXXX</code> methods are used to update column values in the
2532 current row or the insert row. The <code>updateXXX</code> methods do not
2533 update the underlying database; instead the <code>updateRow</code> or
2534 <code>insertRow</code> methods are called to update the database.
2536 @param columnName the name of the column
2537 @param x the new column value
2539 procedure TZAbstractResultSet.UpdateDateByName(const ColumnName: string;
2542 UpdateDate(GetColumnIndex(ColumnName), Value);
2546 Updates the designated column with a <code>java.sql.Time</code> value.
2547 The <code>updateXXX</code> methods are used to update column values in the
2548 current row or the insert row. The <code>updateXXX</code> methods do not
2549 update the underlying database; instead the <code>updateRow</code> or
2550 <code>insertRow</code> methods are called to update the database.
2552 @param columnName the name of the column
2553 @param x the new column value
2555 procedure TZAbstractResultSet.UpdateTimeByName(const ColumnName: string;
2558 UpdateTime(GetColumnIndex(ColumnName), Value);
2562 Updates the designated column with a <code>java.sql.Timestamp</code>
2564 The <code>updateXXX</code> methods are used to update column values in the
2565 current row or the insert row. The <code>updateXXX</code> methods do not
2566 update the underlying database; instead the <code>updateRow</code> or
2567 <code>insertRow</code> methods are called to update the database.
2569 @param columnName the name of the column
2570 @param x the new column value
2572 procedure TZAbstractResultSet.UpdateTimestampByName(const ColumnName: string;
2575 UpdateTimestamp(GetColumnIndex(ColumnName), Value);
2579 Updates the designated column with an ascii stream value.
2580 The <code>updateXXX</code> methods are used to update column values in the
2581 current row or the insert row. The <code>updateXXX</code> methods do not
2582 update the underlying database; instead the <code>updateRow</code> or
2583 <code>insertRow</code> methods are called to update the database.
2585 @param columnName the name of the column
2586 @param x the new column value
2588 procedure TZAbstractResultSet.UpdateAsciiStreamByName(const ColumnName: string;
2591 UpdateAsciiStream(GetColumnIndex(ColumnName), Value);
2595 Updates the designated column with a binary stream value.
2596 The <code>updateXXX</code> methods are used to update column values in the
2597 current row or the insert row. The <code>updateXXX</code> methods do not
2598 update the underlying database; instead the <code>updateRow</code> or
2599 <code>insertRow</code> methods are called to update the database.
2601 @param columnName the name of the column
2602 @param x the new column value
2604 procedure TZAbstractResultSet.UpdateBinaryStreamByName(const ColumnName: string;
2607 UpdateBinaryStream(GetColumnIndex(ColumnName), Value);
2610 procedure TZAbstractResultSet.UpdateDataSetByName(const ColumnName: string;
2613 UpdateDataSet(GetColumnIndex(ColumnName), Value);
2617 Updates the designated column with a character stream value.
2618 The <code>updateXXX</code> methods are used to update column values in the
2619 current row or the insert row. The <code>updateXXX</code> methods do not
2620 update the underlying database; instead the <code>updateRow</code> or
2621 <code>insertRow</code> methods are called to update the database.
2623 @param columnName the name of the column
2624 @param x the new column value
2626 procedure TZAbstractResultSet.UpdateUnicodeStreamByName(const ColumnName: string;
2629 UpdateUnicodeStream(GetColumnIndex(ColumnName), Value);
2633 Updates the designated column with a <code>Variant</code> value.
2634 The <code>updateXXX</code> methods are used to update column values in the
2635 current row or the insert row. The <code>updateXXX</code> methods do not
2636 update the underlying database; instead the <code>updateRow</code> or
2637 <code>insertRow</code> methods are called to update the database.
2639 @param columnName the name of the column
2640 @param x the new column value
2642 procedure TZAbstractResultSet.UpdateValueByName(const ColumnName: string;
2643 const Value: TZVariant);
2645 UpdateValue(GetColumnIndex(ColumnName), Value);
2649 Inserts the contents of the insert row into this
2650 <code>ResultSet</code> objaect and into the database.
2651 The cursor must be on the insert row when this method is called.
2653 procedure TZAbstractResultSet.InsertRow;
2655 RaiseReadOnlyException;
2659 Updates the underlying database with the new contents of the
2660 current row of this <code>ResultSet</code> object.
2661 This method cannot be called when the cursor is on the insert row.
2663 procedure TZAbstractResultSet.UpdateRow;
2665 RaiseReadOnlyException;
2669 Deletes the current row from this <code>ResultSet</code> object
2670 and from the underlying database. This method cannot be called when
2671 the cursor is on the insert row.
2673 procedure TZAbstractResultSet.DeleteRow;
2675 RaiseReadOnlyException;
2679 Refreshes the current row with its most recent value in
2680 the database. This method cannot be called when
2681 the cursor is on the insert row.
2683 <P>The <code>refreshRow</code> method provides a way for an
2685 explicitly tell the JDBC driver to refetch a row(s) from the
2686 database. An application may want to call <code>refreshRow</code> when
2687 caching or prefetching is being done by the JDBC driver to
2688 fetch the latest value of a row from the database. The JDBC driver
2689 may actually refresh multiple rows at once if the fetch size is
2692 <P> All values are refetched subject to the transaction isolation
2693 level and cursor sensitivity. If <code>refreshRow</code> is called after
2694 calling an <code>updateXXX</code> method, but before calling
2695 the method <code>updateRow</code>, then the
2696 updates made to the row are lost. Calling the method
2697 <code>refreshRow</code> frequently will likely slow performance.
2699 procedure TZAbstractResultSet.RefreshRow;
2701 RaiseUnsupportedException;
2705 Cancels the updates made to the current row in this
2706 <code>ResultSet</code> object.
2707 This method may be called after calling an
2708 <code>updateXXX</code> method(s) and before calling
2709 the method <code>updateRow</code> to roll back
2710 the updates made to a row. If no updates have been made or
2711 <code>updateRow</code> has already been called, this method has no
2714 procedure TZAbstractResultSet.CancelRowUpdates;
2716 RaiseReadOnlyException;
2720 Moves the cursor to the insert row. The current cursor position is
2721 remembered while the cursor is positioned on the insert row.
2723 The insert row is a special row associated with an updatable
2724 result set. It is essentially a buffer where a new row may
2725 be constructed by calling the <code>updateXXX</code> methods prior to
2726 inserting the row into the result set.
2728 Only the <code>updateXXX</code>, <code>getXXX</code>,
2729 and <code>insertRow</code> methods may be
2730 called when the cursor is on the insert row. All of the columns in
2731 a result set must be given a value each time this method is
2732 called before calling <code>insertRow</code>.
2733 An <code>updateXXX</code> method must be called before a
2734 <code>getXXX</code> method can be called on a column value.
2736 procedure TZAbstractResultSet.MoveToInsertRow;
2738 RaiseReadOnlyException;
2742 Moves the cursor to the remembered cursor position, usually the
2743 current row. This method has no effect if the cursor is not on
2746 procedure TZAbstractResultSet.MoveToCurrentRow;
2751 Compares fields from two row buffers.
2752 @param Row1 the first row buffer to compare.
2753 @param Row2 the second row buffer to compare.
2754 @param ColumnIndices column indices to compare.
2755 @param ColumnDirs compare direction for each columns.
2757 function TZAbstractResultSet.CompareRows(Row1, Row2: Integer;
2758 const ColumnIndices: TIntegerDynArray; const ColumnDirs: TBooleanDynArray): Integer;
2761 ColumnIndex: Integer;
2763 Value1, Value2: TZVariant;
2765 function CompareFloat(Value1, Value2: Extended): Integer;
2767 Value1 := Value1 - Value2;
2770 else if Value1 < 0 then
2780 for I := Low(ColumnIndices) to High(ColumnIndices) do
2782 ColumnIndex := ColumnIndices[I];
2785 Value1 := GetValue(ColumnIndex);
2787 Value2 := GetValue(ColumnIndex);
2789 { Checks for both Null columns. }
2790 if (Value1.VType = vtNull) and (Value2.VType = vtNull) then
2792 { Checks for not-Null and Null columns. }
2793 if (Value1.VType = vtNull) or (Value2.VType = vtNull) then
2795 if Value1.VType <> vtNull then
2799 if not ColumnDirs[I] then
2803 case Value1.VType of
2806 if Value1.VBoolean = Value2.VBoolean then
2808 else if Value1.VBoolean = True then
2814 Result := Value1.VInteger - Value2.VInteger;
2816 Result := CompareFloat(Value1.VFloat, Value2.VFloat);
2818 Result := CompareFloat(Value1.VDateTime, Value2.VDateTime);
2820 Result := AnsiCompareStr(Value1.VString, Value2.VString);
2822 Result := WideCompareStr(Value1.VUnicodeString, Value2.VUnicodeString);
2826 if not ColumnDirs[I] then
2832 MoveAbsolute(SaveRowNo);
2837 Returns the <code>Statement</code> object that produced this
2838 <code>ResultSet</code> object.
2839 If the result set was generated some other way, such as by a
2840 <code>DatabaseMetaData</code> method, this method returns
2843 @return the <code>Statment</code> object that produced
2844 this <code>ResultSet</code> object or <code>null</code>
2845 if the result set was produced some other way
2847 function TZAbstractResultSet.GetStatement: IZStatement;
2849 Result := FStatement;
2852 function TZAbstractResultSet.GetConSettings: PZConsettings;
2854 Result := ConSettings;
2860 Constructs this class and assignes the main properties.
2861 @param Stream a data string object.
2863 constructor TZAbstractBlob.CreateWithStream(Stream: TStream;
2864 Connection: IZConnection = Nil; Decoded: Boolean = False);
2868 FConnection := Connection;
2869 FDecoded := Decoded;
2870 if Assigned(Stream) then
2872 FBlobSize := Stream.Size;
2873 if FBlobSize > 0 then
2875 GetMem(FBlobData, FBlobSize);
2876 Stream.Position := 0;
2877 Stream.ReadBuffer(FBlobData^, FBlobSize);
2888 Constructs this class and assignes the main properties.
2889 @param Data a pointer to the blobdata.
2890 @param Size the size of the blobdata.
2892 constructor TZAbstractBlob.CreateWithData(Data: Pointer; Size: Integer;
2893 Connection: IZConnection = nil; Decoded: Boolean = False);
2896 FConnection := Connection;
2899 FDecoded := Decoded;
2900 if FBlobSize > 0 then
2902 GetMem(FBlobData, FBlobSize);
2903 System.Move(Data^, FBlobData^, FBlobSize);
2909 Destroys this object and cleanups the memory.
2911 destructor TZAbstractBlob.Destroy;
2918 Clears the content of this blob.
2920 procedure TZAbstractBlob.Clear;
2922 if Assigned(FBlobData) then
2930 Clones this blob object.
2931 @return a clonned blob object.
2933 function TZAbstractBlob.Clone: IZBlob;
2935 Result := TZAbstractBlob.CreateWithData(FBlobData, FBlobSize, FConnection, FDecoded);
2939 Checks if this Text-blob was right Decoded.
2940 @return <code>True</code> if this blob is empty.
2942 function TZAbstractBlob.WasDecoded: Boolean;
2948 Returns the IZConnection which is propable needed to handle the encoding
2949 @return <code>IZConnection</code> if assigned
2951 function TZAbstractBlob.Connection: IZConnection;
2953 Result := FConnection;
2957 Checks if this blob has an empty content.
2958 @return <code>True</code> if this blob is empty.
2960 function TZAbstractBlob.IsEmpty: Boolean;
2962 Result := FBlobSize < 0;
2966 Checks if the content of this blob was updated.
2967 @return <code>True</code> is this blob was updated.
2969 function TZAbstractBlob.IsUpdated: Boolean;
2975 Gets the length of the stored data.
2976 @return the length of the stored data or null if the blob is empty.
2978 function TZAbstractBlob.Length: LongInt;
2980 Result := FBlobSize;
2984 Gets the string from the stored data.
2985 @return a string which contains the stored data.
2987 function TZAbstractBlob.GetString: RawByteString;
2989 if (FBlobSize > 0) and Assigned(FBlobData) then
2991 Result := FConnection.GetIZPlainDriver.ZPlainString(GetUnicodeString, FConnection.GetConSettings)
2994 {$IFDEF WITH_RAWBYTESTRING}
2995 SetLength(Result, FBlobSize);
2996 System.Move(PAnsiChar(FBlobData)^, PAnsiChar(Result)^, FBlobSize);
2998 System.SetString(Result, PAnsiChar(FBlobData), FBlobSize);
3006 Sets a new string data to this blob content.
3007 @param Value a new string data.
3009 procedure TZAbstractBlob.SetString(const Value: RawByteString);
3012 FBlobSize := System.Length(Value);
3013 if FBlobSize > 0 then
3015 GetMem(FBlobData, FBlobSize);
3016 System.Move(PAnsiChar(Value)^, FBlobData^, FBlobSize);
3022 Gets the wide string from the stored data.
3023 @return a string which contains the stored data.
3025 function TZAbstractBlob.GetUnicodeString: WideString;
3027 Bytes: TByteDynArray;
3029 if (FBlobSize > 0) and Assigned(FBlobData) then
3032 SetLength(Result, FBlobSize div 2);
3033 System.Move(PWidechar(FBlobData)^, PWideChar(Result)^, FBlobSize);
3037 SetLength(Bytes, FBlobSize +2);
3038 System.move(FBlobData^, Pointer(Bytes)^, FBlobSize);
3039 if ( not ( {$IFDEF WITH_ANSISTRCOMP_DEPRECATED}AnsiStrings.{$ENDIF}StrLen(PAnsiChar(Bytes)) = Cardinal(FBlobSize) ) ) and
3040 ( {$IFDEF DELPHI14_UP}StrLen{$ELSE}System.Length{$ENDIF}(PWideChar(Bytes)) = Cardinal(FBlobSize) div 2 ) then
3042 SetLength(Result, FBlobSize div 2);
3043 System.Move(PWidechar(Bytes)^, PWideChar(Result)^, FBlobSize);
3046 Result := FConnection.GetIZPlainDriver.ZDbcUnicodeString(PAnsiChar(Bytes), FConnection.GetConSettings.CTRL_CP);
3047 SetLength(Bytes, 0);
3054 Sets a new string data to this blob content.
3055 @param Value a new wide string data.
3057 procedure TZAbstractBlob.SetUnicodeString(const Value: WideString);
3060 FBlobSize := System.Length(Value) *2;
3061 if FBlobSize > 0 then
3063 GetMem(FBlobData, FBlobSize);
3064 System.Move(PWideChar(Value)^, FBlobData^, FBlobSize);
3071 Gets the byte buffer from the stored data.
3072 @return a byte buffer which contains the stored data.
3074 function TZAbstractBlob.GetBytes: TByteDynArray;
3078 if (FBlobSize > 0) and Assigned(FBlobData) then begin
3079 SetLength(Result, FBlobSize);
3080 Move(FBlobData^, Result[0], FBlobSize);
3089 Sets a new byte buffer to this blob content.
3090 @param Value a new byte buffer.
3092 procedure TZAbstractBlob.SetBytes(const Value: TByteDynArray);
3095 if Value <> nil then
3097 FBlobSize := System.Length(Value);
3098 if FBlobSize > 0 then
3100 GetMem(FBlobData, FBlobSize);
3101 System.Move(Value[0], FBlobData^, FBlobSize);
3107 function TZAbstractBlob.GetUnicodeStream: TStream;
3111 Result := TMemoryStream.Create;
3112 if (FBlobSize > 0) and Assigned(FBlobData) then
3114 if ( not ( {$IFDEF WITH_ANSISTRCOMP_DEPRECATED}AnsiStrings.{$ENDIF}StrLen(PAnsiChar(FBlobData)) = Cardinal(FBlobSize) ) ) and
3115 ( {$IFDEF DELPHI14_UP}StrLen{$ELSE}System.Length{$ENDIF}(PWideChar(FBlobData)) = Cardinal(FBlobSize) div 2 ) then
3117 Result.Size := FBlobSize;
3118 System.Move(PWidechar(FBlobData)^, TMemoryStream(Result).Memory^, FBlobSize);
3122 ws:=GetUnicodeString;
3123 Result.Size := System.Length(WS)*2;
3124 System.Move(ws[1], TMemoryStream(Result).Memory^, Result.Size);
3127 Result.Position := 0;
3131 Gets the associated stream object.
3132 @return an associated or newly created stream object.
3134 function TZAbstractBlob.GetStream: TStream;
3136 Result := TMemoryStream.Create;
3137 if (FBlobSize > 0) and Assigned(FBlobData) then
3139 Result.Size := FBlobSize;
3140 System.Move(FBlobData^, TMemoryStream(Result).Memory^, FBlobSize);
3142 Result.Position := 0;
3146 Sets a data from the specified stream into this blob.
3147 @param Value a stream object to be stored into this blob.
3149 procedure TZAbstractBlob.SetStream(Value: TStream; Decoded: Boolean = False);
3152 if Assigned(Value) then
3154 FBlobSize := Value.Size;
3155 if FBlobSize > 0 then
3157 GetMem(FBlobData, FBlobSize);
3158 Value.Position := 0;
3159 Value.ReadBuffer(FBlobData^, FBlobSize);
3168 FDecoded := Decoded;
3171 function TZAbstractBlob.GetBuffer: Pointer;
3173 Result := FBlobData;
3176 procedure TZAbstractBlob.SetBuffer(Buffer: Pointer; Length: Integer);
3178 FBlobSize := Length;
3179 if Assigned(Buffer) and ( Length > 0 ) then
3182 GetMem(FBlobData, Length);
3183 Move(FBlobData^, Buffer^, Length);