00001 {*********************************************************}
00002 { }
00003 { Zeos Database Objects }
00004 { Abstract Database Connectivity Classes }
00005 { }
00006 { Originally written by Sergey Seroukhov }
00007 { }
00008 {*********************************************************}
00009
00010 {@********************************************************}
00011 { Copyright (c) 1999-2006 Zeos Development Group }
00012 { }
00013 { License Agreement: }
00014 { }
00015 { This library is distributed in the hope that it will be }
00016 { useful, but WITHOUT ANY WARRANTY; without even the }
00017 { implied warranty of MERCHANTABILITY or FITNESS FOR }
00018 { A PARTICULAR PURPOSE. See the GNU Lesser General }
00019 { Public License for more details. }
00020 { }
00021 { The source code of the ZEOS Libraries and packages are }
00022 { distributed under the Library GNU General Public }
00023 { License (see the file COPYING / COPYING.ZEOS) }
00024 { with the following modification: }
00025 { As a special exception, the copyright holders of this }
00026 { library give you permission to link this library with }
00027 { independent modules to produce an executable, }
00028 { regardless of the license terms of these independent }
00029 { modules, and to copy and distribute the resulting }
00030 { executable under terms of your choice, provided that }
00031 { you also meet, for each linked independent module, }
00032 { the terms and conditions of the license of that module. }
00033 { An independent module is a module which is not derived }
00034 { from or based on this library. If you modify this }
00035 { library, you may extend this exception to your version }
00036 { of the library, but you are not obligated to do so. }
00037 { If you do not wish to do so, delete this exception }
00038 { statement from your version. }
00039 { }
00040 { }
00041 { The project web site is located on: }
00042 { http:
00043 { http:
00044 { svn:
00045 { }
00046 { http:
00047 { http:
00048 { }
00049 { }
00050 { }
00051 { Zeos Development Group. }
00052 {********************************************************@}
00053
00054 unit ZDbcResultSet;
00055
00056 interface
00057
00058 {$I ZDbc.inc}
00059
00060 uses
00061 {$IFDEF MSWINDOWS}
00062 Windows,
00063 {$ENDIF}
00064 Classes, SysUtils, Contnrs, ZDbcIntfs, ZClasses, ZCollections, ZSysUtils,
00065 {$IFNDEF VER130BELOW}
00066 Types,
00067 {$ENDIF}
00068 {$IFDEF VER130BELOW}
00069 {$IFDEF WIN32}
00070 Comobj,
00071 {$ENDIF}
00072 {$ENDIF}
00073 ZCompatibility, ZVariant;
00074
00075 type
00076 {** Implements Abstract ResultSet. }
00077 TZAbstractResultSet = class(TInterfacedObject, IZResultSet)
00078 private
00079 FTemp: string;
00080 FRowNo: Integer;
00081 FLastRowNo: Integer;
00082 FMaxRows: Integer;
00083 FClosed: Boolean;
00084 FFetchDirection: TZFetchDirection;
00085 FFetchSize: Integer;
00086 FResultSetType: TZResultSetType;
00087 FResultSetConcurrency: TZResultSetConcurrency;
00088 FPostUpdates: TZPostUpdatesMode;
00089 FLocateUpdates: TZLocateUpdatesMode;
00090 FColumnsInfo: TObjectList;
00091 FMetadata: TContainedObject;
00092 FStatement: IZStatement;
00093 protected
00094 LastWasNull: Boolean;
00095
00096 procedure RaiseUnsupportedException;
00097 procedure RaiseForwardOnlyException;
00098 procedure RaiseReadOnlyException;
00099 procedure CheckClosed;
00100 procedure CheckColumnConvertion(ColumnIndex: Integer; ResultType: TZSQLType);
00101 procedure CheckBlobColumn(ColumnIndex: Integer);
00102 procedure Open; virtual;
00103 function GetColumnIndex(const ColumnName: string): Integer;
00104
00105 property RowNo: Integer read FRowNo write FRowNo;
00106 property LastRowNo: Integer read FLastRowNo write FLastRowNo;
00107 property MaxRows: Integer read FMaxRows write FMaxRows;
00108 property Closed: Boolean read FClosed write FClosed;
00109 property FetchDirection: TZFetchDirection
00110 read FFetchDirection write FFetchDirection;
00111 property FetchSize: Integer read FFetchSize write FFetchSize;
00112 property ResultSetType: TZResultSetType
00113 read FResultSetType write FResultSetType;
00114 property ResultSetConcurrency: TZResultSetConcurrency
00115 read FResultSetConcurrency write FResultSetConcurrency;
00116 property Statement: IZStatement read FStatement;
00117 property Metadata: TContainedObject read FMetadata write FMetadata;
00118 public
00119 constructor Create(Statement: IZStatement; SQL: string;
00120 Metadata: TContainedObject);
00121 destructor Destroy; override;
00122
00123 procedure SetType(Value: TZResultSetType);
00124 procedure SetConcurrency(Value: TZResultSetConcurrency);
00125
00126 function Next: Boolean; virtual;
00127 procedure Close; virtual;
00128 function WasNull: Boolean; virtual;
00129
00130
00131
00132
00133
00134 function IsNull(ColumnIndex: Integer): Boolean; virtual;
00135 function GetPChar(ColumnIndex: Integer): PChar; virtual;
00136 function GetString(ColumnIndex: Integer): string; virtual;
00137 function GetUnicodeString(ColumnIndex: Integer): WideString; virtual;
00138 function GetBoolean(ColumnIndex: Integer): Boolean; virtual;
00139 function GetByte(ColumnIndex: Integer): ShortInt; virtual;
00140 function GetShort(ColumnIndex: Integer): SmallInt; virtual;
00141 function GetInt(ColumnIndex: Integer): Integer; virtual;
00142 function GetLong(ColumnIndex: Integer): Int64; virtual;
00143 function GetFloat(ColumnIndex: Integer): Single; virtual;
00144 function GetDouble(ColumnIndex: Integer): Double; virtual;
00145 function GetBigDecimal(ColumnIndex: Integer): Extended; virtual;
00146 function GetBytes(ColumnIndex: Integer): TByteDynArray; virtual;
00147 function GetDate(ColumnIndex: Integer): TDateTime; virtual;
00148 function GetTime(ColumnIndex: Integer): TDateTime; virtual;
00149 function GetTimestamp(ColumnIndex: Integer): TDateTime; virtual;
00150 function GetAsciiStream(ColumnIndex: Integer): TStream; virtual;
00151 function GetUnicodeStream(ColumnIndex: Integer): TStream; virtual;
00152 function GetBinaryStream(ColumnIndex: Integer): TStream; virtual;
00153 function GetBlob(ColumnIndex: Integer): IZBlob; virtual;
00154 function GetValue(ColumnIndex: Integer): TZVariant; virtual;
00155
00156
00157
00158
00159
00160 function IsNullByName(const ColumnName: string): Boolean; virtual;
00161 function GetPCharByName(const ColumnName: string): PChar; virtual;
00162 function GetStringByName(const ColumnName: string): string; virtual;
00163 function GetUnicodeStringByName(const ColumnName: string): WideString; virtual;
00164 function GetBooleanByName(const ColumnName: string): Boolean; virtual;
00165 function GetByteByName(const ColumnName: string): ShortInt; virtual;
00166 function GetShortByName(const ColumnName: string): SmallInt; virtual;
00167 function GetIntByName(const ColumnName: string): Integer; virtual;
00168 function GetLongByName(const ColumnName: string): Int64; virtual;
00169 function GetFloatByName(const ColumnName: string): Single; virtual;
00170 function GetDoubleByName(const ColumnName: string): Double; virtual;
00171 function GetBigDecimalByName(const ColumnName: string): Extended; virtual;
00172 function GetBytesByName(const ColumnName: string): TByteDynArray; virtual;
00173 function GetDateByName(const ColumnName: string): TDateTime; virtual;
00174 function GetTimeByName(const ColumnName: string): TDateTime; virtual;
00175 function GetTimestampByName(const ColumnName: string): TDateTime; virtual;
00176 function GetAsciiStreamByName(const ColumnName: string): TStream; virtual;
00177 function GetUnicodeStreamByName(const ColumnName: string): TStream; virtual;
00178 function GetBinaryStreamByName(const ColumnName: string): TStream; virtual;
00179 function GetBlobByName(const ColumnName: string): IZBlob; virtual;
00180 function GetValueByName(const ColumnName: string): TZVariant; virtual;
00181
00182
00183
00184
00185
00186 function GetWarnings: EZSQLWarning; virtual;
00187 procedure ClearWarnings; virtual;
00188
00189 function GetCursorName: string; virtual;
00190 function GetMetaData: IZResultSetMetaData; virtual;
00191 function FindColumn(const ColumnName: string): Integer; virtual;
00192
00193
00194
00195
00196
00197 function IsBeforeFirst: Boolean; virtual;
00198 function IsAfterLast: Boolean; virtual;
00199 function IsFirst: Boolean; virtual;
00200 function IsLast: Boolean; virtual;
00201 procedure BeforeFirst; virtual;
00202 procedure AfterLast; virtual;
00203 function First: Boolean; virtual;
00204 function Last: Boolean; virtual;
00205 function GetRow: Integer; virtual;
00206 function MoveAbsolute(Row: Integer): Boolean; virtual;
00207 function MoveRelative(Rows: Integer): Boolean; virtual;
00208 function Previous: Boolean; virtual;
00209
00210
00211
00212
00213
00214 procedure SetFetchDirection(Direction: TZFetchDirection); virtual;
00215 function GetFetchDirection: TZFetchDirection; virtual;
00216
00217 procedure SetFetchSize(Rows: Integer); virtual;
00218 function GetFetchSize: Integer; virtual;
00219
00220 function GetType: TZResultSetType; virtual;
00221 function GetConcurrency: TZResultSetConcurrency; virtual;
00222
00223 function GetPostUpdates: TZPostUpdatesMode;
00224 function GetLocateUpdates: TZLocateUpdatesMode;
00225
00226
00227
00228
00229
00230 function RowUpdated: Boolean; virtual;
00231 function RowInserted: Boolean; virtual;
00232 function RowDeleted: Boolean; virtual;
00233
00234 procedure UpdateNull(ColumnIndex: Integer); virtual;
00235 procedure UpdateBoolean(ColumnIndex: Integer; Value: Boolean); virtual;
00236 procedure UpdateByte(ColumnIndex: Integer; Value: ShortInt); virtual;
00237 procedure UpdateShort(ColumnIndex: Integer; Value: SmallInt); virtual;
00238 procedure UpdateInt(ColumnIndex: Integer; Value: Integer); virtual;
00239 procedure UpdateLong(ColumnIndex: Integer; Value: Int64); virtual;
00240 procedure UpdateFloat(ColumnIndex: Integer; Value: Single); virtual;
00241 procedure UpdateDouble(ColumnIndex: Integer; Value: Double); virtual;
00242 procedure UpdateBigDecimal(ColumnIndex: Integer; Value: Extended); virtual;
00243 procedure UpdatePChar(ColumnIndex: Integer; Value: PChar); virtual;
00244 procedure UpdateString(ColumnIndex: Integer; const Value: string); virtual;
00245 procedure UpdateUnicodeString(ColumnIndex: Integer; const Value: WideString);
00246 virtual;
00247 procedure UpdateBytes(ColumnIndex: Integer; const Value: TByteDynArray); virtual;
00248 procedure UpdateDate(ColumnIndex: Integer; Value: TDateTime); virtual;
00249 procedure UpdateTime(ColumnIndex: Integer; Value: TDateTime); virtual;
00250 procedure UpdateTimestamp(ColumnIndex: Integer; Value: TDateTime); virtual;
00251 procedure UpdateAsciiStream(ColumnIndex: Integer; Value: TStream); virtual;
00252 procedure UpdateUnicodeStream(ColumnIndex: Integer; Value: TStream); virtual;
00253 procedure UpdateBinaryStream(ColumnIndex: Integer; Value: TStream); virtual;
00254 procedure UpdateValue(ColumnIndex: Integer; const Value: TZVariant); virtual;
00255
00256
00257
00258
00259
00260 procedure UpdateNullByName(const ColumnName: string); virtual;
00261 procedure UpdateBooleanByName(const ColumnName: string; Value: Boolean); virtual;
00262 procedure UpdateByteByName(const ColumnName: string; Value: ShortInt); virtual;
00263 procedure UpdateShortByName(const ColumnName: string; Value: SmallInt); virtual;
00264 procedure UpdateIntByName(const ColumnName: string; Value: Integer); virtual;
00265 procedure UpdateLongByName(const ColumnName: string; Value: Int64); virtual;
00266 procedure UpdateFloatByName(const ColumnName: string; Value: Single); virtual;
00267 procedure UpdateDoubleByName(const ColumnName: string; Value: Double); virtual;
00268 procedure UpdateBigDecimalByName(const ColumnName: string; Value: Extended); virtual;
00269 procedure UpdatePCharByName(const ColumnName: string; Value: PChar); virtual;
00270 procedure UpdateStringByName(const ColumnName: string; const Value: string); virtual;
00271 procedure UpdateUnicodeStringByName(const ColumnName: string; const Value: WideString);
00272 virtual;
00273 procedure UpdateBytesByName(const ColumnName: string; const Value: TByteDynArray); virtual;
00274 procedure UpdateDateByName(const ColumnName: string; Value: TDateTime); virtual;
00275 procedure UpdateTimeByName(const ColumnName: string; Value: TDateTime); virtual;
00276 procedure UpdateTimestampByName(const ColumnName: string; Value: TDateTime); virtual;
00277 procedure UpdateAsciiStreamByName(const ColumnName: string; Value: TStream); virtual;
00278 procedure UpdateUnicodeStreamByName(const ColumnName: string; Value: TStream); virtual;
00279 procedure UpdateBinaryStreamByName(const ColumnName: string; Value: TStream); virtual;
00280 procedure UpdateValueByName(const ColumnName: string; const Value: TZVariant); virtual;
00281
00282 procedure InsertRow; virtual;
00283 procedure UpdateRow; virtual;
00284 procedure DeleteRow; virtual;
00285 procedure RefreshRow; virtual;
00286 procedure CancelRowUpdates; virtual;
00287 procedure MoveToInsertRow; virtual;
00288 procedure MoveToCurrentRow; virtual;
00289
00290 function CompareRows(Row1, Row2: Integer; const ColumnIndices: TIntegerDynArray;
00291 const ColumnDirs: TBooleanDynArray): Integer; virtual;
00292
00293 function GetStatement: IZStatement; virtual;
00294
00295 property ColumnsInfo: TObjectList read FColumnsInfo write FColumnsInfo;
00296 end;
00297
00298 {** Implements external or internal blob wrapper object. }
00299 TZAbstractBlob = class(TInterfacedObject, IZBlob)
00300 private
00301 FBlobData: Pointer;
00302 FBlobSize: Integer;
00303 FUpdated: Boolean;
00304 protected
00305 property BlobData: Pointer read FBlobData write FBlobData;
00306 property BlobSize: Integer read FBlobSize write FBlobSize;
00307 property Updated: Boolean read FUpdated write FUpdated;
00308 public
00309 constructor CreateWithStream(Stream: TStream);
00310 constructor CreateWithData(Data: Pointer; Size: Integer);
00311 destructor Destroy; override;
00312
00313 function IsEmpty: Boolean; virtual;
00314 function IsUpdated: Boolean; virtual;
00315 function Length: LongInt; virtual;
00316
00317 function GetString: string; virtual;
00318 procedure SetString(const Value: string); virtual;
00319 function GetUnicodeString: WideString; virtual;
00320 procedure SetUnicodeString(const Value: WideString); virtual;
00321 function GetBytes: TByteDynArray; virtual;
00322 procedure SetBytes(const Value: TByteDynArray); virtual;
00323 function GetStream: TStream; virtual;
00324 procedure SetStream(Value: TStream); virtual;
00325
00326 procedure Clear; virtual;
00327 function Clone: IZBlob; virtual;
00328 end;
00329
00330 implementation
00331
00332 uses ZMessages, ZDbcUtils, ZDbcResultSetMetadata;
00333
00334 { TZAbstractResultSet }
00335
00336 {**
00337 Creates this object and assignes the main properties.
00338 @param Statement an SQL statement object.
00339 @param SQL an SQL query string.
00340 @param Metadata a resultset metadata object.
00341 }
00342 constructor TZAbstractResultSet.Create(Statement: IZStatement; SQL: string;
00343 Metadata: TContainedObject);
00344 var
00345 DatabaseMetadata: IZDatabaseMetadata;
00346 begin
00347 LastWasNull := True;
00348 FRowNo := 0;
00349 FLastRowNo := 0;
00350 FClosed := True;
00351
00352 if Statement = nil then
00353 begin
00354 FResultSetType := rtForwardOnly;
00355 FResultSetConcurrency := rcReadOnly;
00356 FPostUpdates := poColumnsAll;
00357 FLocateUpdates := loWhereAll;
00358 FMaxRows := 0;
00359 end
00360 else
00361 begin
00362 FFetchDirection := Statement.GetFetchDirection;
00363 FFetchSize := Statement.GetFetchSize;
00364 FResultSetType := Statement.GetResultSetType;
00365 FResultSetConcurrency := Statement.GetResultSetConcurrency;
00366 FPostUpdates := Statement.GetPostUpdates;
00367 FLocateUpdates := Statement.GetLocateUpdates;
00368 FStatement := Statement;
00369 FMaxRows := Statement.GetMaxRows;
00370 end;
00371
00372 if Metadata = nil then
00373 begin
00374 if Statement <> nil then
00375 DatabaseMetadata := GetStatement.GetConnection.GetMetadata
00376 else DatabaseMetadata := nil;
00377 FMetadata := TZAbstractResultSetMetadata.Create(DatabaseMetadata, SQL, Self);
00378 end else
00379 FMetadata := Metadata;
00380
00381 FColumnsInfo := TObjectList.Create;
00382 end;
00383
00384 {**
00385 Destroys this object and cleanups the memory.
00386 }
00387 destructor TZAbstractResultSet.Destroy;
00388 begin
00389 if not FClosed then Close;
00390
00391 if FMetadata <> nil then
00392 FMetadata.Free;
00393 FMetadata := nil;
00394 FStatement := nil;
00395
00396 FColumnsInfo.Free;
00397 inherited Destroy;
00398 end;
00399
00400 {**
00401 Raises unsupported operation exception.
00402 }
00403 procedure TZAbstractResultSet.RaiseUnsupportedException;
00404 begin
00405 raise EZSQLException.Create(SUnsupportedOperation);
00406 end;
00407
00408 {**
00409 Raises operation is not allowed in FORWARD ONLY mode exception.
00410 }
00411 procedure TZAbstractResultSet.RaiseForwardOnlyException;
00412 begin
00413 raise EZSQLException.Create(SOperationIsNotAllowed1);
00414 end;
00415
00416 {**
00417 Raises operation is not allowed in READ ONLY mode exception.
00418 }
00419 procedure TZAbstractResultSet.RaiseReadOnlyException;
00420 begin
00421 raise EZSQLException.Create(SOperationIsNotAllowed2);
00422 end;
00423
00424 {**
00425 Checks if result set is open and operation is allowed.
00426 }
00427 procedure TZAbstractResultSet.CheckClosed;
00428 begin
00429 if FClosed then
00430 raise EZSQLException.Create(SOperationIsNotAllowed4);
00431 end;
00432
00433 {**
00434 Checks is the column convertion from one type to another type allowed.
00435 @param ColumnIndex an index of column.
00436 @param ResultType a requested data type.
00437 }
00438 procedure TZAbstractResultSet.CheckColumnConvertion(ColumnIndex: Integer;
00439 ResultType: TZSQLType);
00440 var
00441 InitialType: TZSQLType;
00442 Metadata: TZAbstractResultSetMetadata;
00443 begin
00444 CheckClosed;
00445 Metadata := TZAbstractResultSetMetadata(FMetadata);
00446 if (Metadata = nil) or (ColumnIndex <= 0)
00447 or (ColumnIndex > Metadata.GetColumnCount) then
00448 begin
00449 raise EZSQLException.Create(
00450 Format(SColumnIsNotAccessable, [ColumnIndex]));
00451 end;
00452
00453 InitialType := Metadata.GetColumnType(ColumnIndex);
00454 if not CheckConvertion(InitialType, ResultType) then
00455 begin
00456 raise EZSQLException.Create(
00457 Format(SConvertionIsNotPossible,
00458 [ColumnIndex, DefineColumnTypeName(InitialType),
00459 DefineColumnTypeName(ResultType)]));
00460 end;
00461 end;
00462
00463 {**
00464 Checks for blob expected column.
00465 @param ColumnIndex an index of column.
00466 }
00467 procedure TZAbstractResultSet.CheckBlobColumn(ColumnIndex: Integer);
00468 var
00469 InitialType: TZSQLType;
00470 Metadata: TZAbstractResultSetMetadata;
00471 begin
00472 CheckClosed;
00473 Metadata := TZAbstractResultSetMetadata(FMetadata);
00474 if (Metadata = nil) or (ColumnIndex <= 0)
00475 or (ColumnIndex > Metadata.GetColumnCount) then
00476 begin
00477 raise EZSQLException.Create(
00478 Format(SColumnIsNotAccessable, [ColumnIndex]));
00479 end;
00480
00481 InitialType := Metadata.GetColumnType(ColumnIndex);
00482 if not (InitialType in [stAsciiStream, stBinaryStream, stUnicodeStream]) then
00483 begin
00484 raise EZSQLException.Create(
00485 Format(SCanNotAccessBlobRecord,
00486 [ColumnIndex, DefineColumnTypeName(InitialType)]));
00487 end;
00488 end;
00489
00490 {**
00491 Set the concurrency mode of this <code>ResultSet</code> object.
00492 The concurrency used is determined by the
00493 <code>Statement</code> object that created the result set.
00494
00495 @param the concurrency type, either <code>CONCUR_READ_ONLY</code>
00496 or <code>CONCUR_UPDATABLE</code>
00497 }
00498 procedure TZAbstractResultSet.SetConcurrency(Value: TZResultSetConcurrency);
00499 begin
00500 ResultSetConcurrency := Value;
00501 end;
00502
00503 {**
00504 Set the type of this <code>ResultSet</code> object.
00505 The type is determined by the <code>Statement</code> object
00506 that created the result set.
00507
00508 @param <code>TYPE_FORWARD_ONLY</code>,
00509 <code>TYPE_SCROLL_INSENSITIVE</code>,
00510 or <code>TYPE_SCROLL_SENSITIVE</code>
00511 }
00512 procedure TZAbstractResultSet.SetType(Value: TZResultSetType);
00513 begin
00514 ResultSetType := Value;
00515 end;
00516
00517 {**
00518 Opens this recordset.
00519 }
00520 procedure TZAbstractResultSet.Open;
00521 begin
00522 FClosed := False;
00523 end;
00524
00525 {**
00526 Releases this <code>ResultSet</code> object's database and
00527 JDBC resources immediately instead of waiting for
00528 this to happen when it is automatically closed.
00529
00530 <P><B>Note:</B> A <code>ResultSet</code> object
00531 is automatically closed by the
00532 <code>Statement</code> object that generated it when
00533 that <code>Statement</code> object is closed,
00534 re-executed, or is used to retrieve the next result from a
00535 sequence of multiple results. A <code>ResultSet</code> object
00536 is also automatically closed when it is garbage collected.
00537 }
00538 procedure TZAbstractResultSet.Close;
00539 var I : integer;
00540 var FColumnInfo : TZColumnInfo;
00541 begin
00542 LastWasNull := True;
00543 FRowNo := 0;
00544 FLastRowNo := 0;
00545 FClosed := True;
00546 for I := FColumnsInfo.Count-1 downto 0 do begin
00547 FColumnInfo:=TZColumnInfo(FColumnsInfo.Extract(FColumnsInfo.Items[I]));
00548 FColumnInfo.Free;
00549 end;
00550 FColumnsInfo.Clear;
00551 FStatement := nil;
00552 end;
00553
00554 {**
00555 Reports whether
00556 the last column read had a value of SQL <code>NULL</code>.
00557 Note that you must first call one of the <code>getXXX</code> methods
00558 on a column to try to read its value and then call
00559 the method <code>wasNull</code> to see if the value read was
00560 SQL <code>NULL</code>.
00561
00562 @return <code>true</code> if the last column value read was SQL
00563 <code>NULL</code> and <code>false</code> otherwise
00564 }
00565 function TZAbstractResultSet.WasNull: Boolean;
00566 begin
00567 Result := LastWasNull;
00568 end;
00569
00570 //======================================================================
00571 // Methods for accessing results by column index
00572 //======================================================================
00573
00574 {**
00575 Indicates if the value of the designated column in the current row
00576 of this <code>ResultSet</code> object is Null.
00577
00578 @param columnIndex the first column is 1, the second is 2, ...
00579 @return if the value is SQL <code>NULL</code>, the
00580 value returned is <code>true</code>. <code>false</code> otherwise.
00581 }
00582 function TZAbstractResultSet.IsNull(ColumnIndex: Integer): Boolean;
00583 begin
00584 Result := True;
00585 end;
00586
00587 {**
00588 Gets the value of the designated column in the current row
00589 of this <code>ResultSet</code> object as
00590 a <code>PChar</code> in the Delphi programming language.
00591
00592 @param columnIndex the first column is 1, the second is 2, ...
00593 @return the column value; if the value is SQL <code>NULL</code>, the
00594 value returned is <code>null</code>
00595 }
00596 function TZAbstractResultSet.GetPChar(ColumnIndex: Integer): PChar;
00597 begin
00598 FTemp := GetString(ColumnIndex);
00599 Result := PChar(FTemp);
00600 end;
00601
00602 {**
00603 Gets the value of the designated column in the current row
00604 of this <code>ResultSet</code> object as
00605 a <code>String</code> in the Java programming language.
00606
00607 @param columnIndex the first column is 1, the second is 2, ...
00608 @return the column value; if the value is SQL <code>NULL</code>, the
00609 value returned is <code>null</code>
00610 }
00611 function TZAbstractResultSet.GetString(ColumnIndex: Integer): string;
00612 begin
00613 {$IFNDEF DISABLE_CHECKING}
00614 CheckColumnConvertion(ColumnIndex, stString);
00615 {$ENDIF}
00616 Result := '';
00617 end;
00618
00619 {**
00620 Gets the value of the designated column in the current row
00621 of this <code>ResultSet</code> object as
00622 a <code>WideString</code> in the Delphi programming language.
00623
00624 @param columnIndex the first column is 1, the second is 2, ...
00625 @return the column value; if the value is SQL <code>NULL</code>, the
00626 value returned is <code>null</code>
00627 }
00628 function TZAbstractResultSet.GetUnicodeString(ColumnIndex: Integer): WideString;
00629 begin
00630 {$IFNDEF DISABLE_CHECKING}
00631 CheckColumnConvertion(ColumnIndex, stUnicodeString);
00632 {$ENDIF}
00633 Result := '';
00634 end;
00635
00636 {**
00637 Gets the value of the designated column in the current row
00638 of this <code>ResultSet</code> object as
00639 a <code>boolean</code> in the Java programming language.
00640
00641 @param columnIndex the first column is 1, the second is 2, ...
00642 @return the column value; if the value is SQL <code>NULL</code>, the
00643 value returned is <code>false</code>
00644 }
00645 function TZAbstractResultSet.GetBoolean(ColumnIndex: Integer): Boolean;
00646 begin
00647 {$IFNDEF DISABLE_CHECKING}
00648 CheckColumnConvertion(ColumnIndex, stBoolean);
00649 {$ENDIF}
00650 Result := False;
00651 end;
00652
00653 {**
00654 Gets the value of the designated column in the current row
00655 of this <code>ResultSet</code> object as
00656 a <code>byte</code> in the Java programming language.
00657
00658 @param columnIndex the first column is 1, the second is 2, ...
00659 @return the column value; if the value is SQL <code>NULL</code>, the
00660 value returned is <code>0</code>
00661 }
00662 function TZAbstractResultSet.GetByte(ColumnIndex: Integer): ShortInt;
00663 begin
00664 {$IFNDEF DISABLE_CHECKING}
00665 CheckColumnConvertion(ColumnIndex, stByte);
00666 {$ENDIF}
00667 Result := 0;
00668 end;
00669
00670 {**
00671 Gets the value of the designated column in the current row
00672 of this <code>ResultSet</code> object as
00673 a <code>short</code> in the Java programming language.
00674
00675 @param columnIndex the first column is 1, the second is 2, ...
00676 @return the column value; if the value is SQL <code>NULL</code>, the
00677 value returned is <code>0</code>
00678 }
00679 function TZAbstractResultSet.GetShort(ColumnIndex: Integer): SmallInt;
00680 begin
00681 {$IFNDEF DISABLE_CHECKING}
00682 CheckColumnConvertion(ColumnIndex, stShort);
00683 {$ENDIF}
00684 Result := 0;
00685 end;
00686
00687 {**
00688 Gets the value of the designated column in the current row
00689 of this <code>ResultSet</code> object as
00690 an <code>int</code> in the Java programming language.
00691
00692 @param columnIndex the first column is 1, the second is 2, ...
00693 @return the column value; if the value is SQL <code>NULL</code>, the
00694 value returned is <code>0</code>
00695 }
00696 function TZAbstractResultSet.GetInt(ColumnIndex: Integer): Integer;
00697 begin
00698 {$IFNDEF DISABLE_CHECKING}
00699 CheckColumnConvertion(ColumnIndex, stInteger);
00700 {$ENDIF}
00701 Result := 0;
00702 end;
00703
00704 {**
00705 Gets the value of the designated column in the current row
00706 of this <code>ResultSet</code> object as
00707 a <code>long</code> in the Java programming language.
00708
00709 @param columnIndex the first column is 1, the second is 2, ...
00710 @return the column value; if the value is SQL <code>NULL</code>, the
00711 value returned is <code>0</code>
00712 }
00713 function TZAbstractResultSet.GetLong(ColumnIndex: Integer): Int64;
00714 begin
00715 {$IFNDEF DISABLE_CHECKING}
00716 CheckColumnConvertion(ColumnIndex, stLong);
00717 {$ENDIF}
00718 Result := 0;
00719 end;
00720
00721 {**
00722 Gets the value of the designated column in the current row
00723 of this <code>ResultSet</code> object as
00724 a <code>float</code> in the Java programming language.
00725
00726 @param columnIndex the first column is 1, the second is 2, ...
00727 @return the column value; if the value is SQL <code>NULL</code>, the
00728 value returned is <code>0</code>
00729 }
00730 function TZAbstractResultSet.GetFloat(ColumnIndex: Integer): Single;
00731 begin
00732 {$IFNDEF DISABLE_CHECKING}
00733 CheckColumnConvertion(ColumnIndex, stFloat);
00734 {$ENDIF}
00735 Result := 0;
00736 end;
00737
00738 {**
00739 Gets the value of the designated column in the current row
00740 of this <code>ResultSet</code> object as
00741 a <code>double</code> in the Java programming language.
00742
00743 @param columnIndex the first column is 1, the second is 2, ...
00744 @return the column value; if the value is SQL <code>NULL</code>, the
00745 value returned is <code>0</code>
00746 }
00747 function TZAbstractResultSet.GetDouble(ColumnIndex: Integer): Double;
00748 begin
00749 {$IFNDEF DISABLE_CHECKING}
00750 CheckColumnConvertion(ColumnIndex, stDouble);
00751 {$ENDIF}
00752 Result := 0;
00753 end;
00754
00755 {**
00756 Gets the value of the designated column in the current row
00757 of this <code>ResultSet</code> object as
00758 a <code>java.sql.BigDecimal</code> in the Java programming language.
00759
00760 @param columnIndex the first column is 1, the second is 2, ...
00761 @param scale the number of digits to the right of the decimal point
00762 @return the column value; if the value is SQL <code>NULL</code>, the
00763 value returned is <code>null</code>
00764 }
00765 function TZAbstractResultSet.GetBigDecimal(ColumnIndex: Integer): Extended;
00766 begin
00767 {$IFNDEF DISABLE_CHECKING}
00768 CheckColumnConvertion(ColumnIndex, stBigDecimal);
00769 {$ENDIF}
00770 Result := 0;
00771 end;
00772
00773 {**
00774 Gets the value of the designated column in the current row
00775 of this <code>ResultSet</code> object as
00776 a <code>byte</code> array in the Java programming language.
00777 The bytes represent the raw values returned by the driver.
00778
00779 @param columnIndex the first column is 1, the second is 2, ...
00780 @return the column value; if the value is SQL <code>NULL</code>, the
00781 value returned is <code>null</code>
00782 }
00783 function TZAbstractResultSet.GetBytes(ColumnIndex: Integer): TByteDynArray;
00784 begin
00785 {$IFNDEF DISABLE_CHECKING}
00786 CheckColumnConvertion(ColumnIndex, stBytes);
00787 {$ENDIF}
00788 Result := nil;
00789 end;
00790
00791 {**
00792 Gets the value of the designated column in the current row
00793 of this <code>ResultSet</code> object as
00794 a <code>java.sql.Date</code> object in the Java programming language.
00795
00796 @param columnIndex the first column is 1, the second is 2, ...
00797 @return the column value; if the value is SQL <code>NULL</code>, the
00798 value returned is <code>null</code>
00799 }
00800 function TZAbstractResultSet.GetDate(ColumnIndex: Integer): TDateTime;
00801 begin
00802 {$IFNDEF DISABLE_CHECKING}
00803 CheckColumnConvertion(ColumnIndex, stDate);
00804 {$ENDIF}
00805 Result := 0;
00806 end;
00807
00808 {**
00809 Gets the value of the designated column in the current row
00810 of this <code>ResultSet</code> object as
00811 a <code>java.sql.Time</code> object in the Java programming language.
00812
00813 @param columnIndex the first column is 1, the second is 2, ...
00814 @return the column value; if the value is SQL <code>NULL</code>, the
00815 value returned is <code>null</code>
00816 }
00817 function TZAbstractResultSet.GetTime(ColumnIndex: Integer): TDateTime;
00818 begin
00819 {$IFNDEF DISABLE_CHECKING}
00820 CheckColumnConvertion(ColumnIndex, stTime);
00821 {$ENDIF}
00822 Result := 0;
00823 end;
00824
00825 {**
00826 Gets the value of the designated column in the current row
00827 of this <code>ResultSet</code> object as
00828 a <code>java.sql.Timestamp</code> object in the Java programming language.
00829
00830 @param columnIndex the first column is 1, the second is 2, ...
00831 @return the column value; if the value is SQL <code>NULL</code>, the
00832 value returned is <code>null</code>
00833 @exception SQLException if a database access error occurs
00834 }
00835 function TZAbstractResultSet.GetTimestamp(ColumnIndex: Integer): TDateTime;
00836 begin
00837 {$IFNDEF DISABLE_CHECKING}
00838 CheckColumnConvertion(ColumnIndex, stTimestamp);
00839 {$ENDIF}
00840 Result := 0;
00841 end;
00842
00843 {**
00844 Gets the value of the designated column in the current row
00845 of this <code>ResultSet</code> object as
00846 a stream of ASCII characters. The value can then be read in chunks from the
00847 stream. This method is particularly
00848 suitable for retrieving large <char>LONGVARCHAR</char> values.
00849 The JDBC driver will
00850 do any necessary conversion from the database format into ASCII.
00851
00852 <P><B>Note:</B> All the data in the returned stream must be
00853 read prior to getting the value of any other column. The next
00854 call to a <code>getXXX</code> method implicitly closes the stream. Also, a
00855 stream may return <code>0</code> when the method
00856 <code>InputStream.available</code>
00857 is called whether there is data available or not.
00858
00859 @param columnIndex the first column is 1, the second is 2, ...
00860 @return a Java input stream that delivers the database column value
00861 as a stream of one-byte ASCII characters; if the value is SQL
00862 <code>NULL</code>, the value returned is <code>null</code>
00863 }
00864 function TZAbstractResultSet.GetAsciiStream(ColumnIndex: Integer): TStream;
00865 var
00866 Blob: IZBlob;
00867 begin
00868 {$IFNDEF DISABLE_CHECKING}
00869 CheckColumnConvertion(ColumnIndex, stAsciiStream);
00870 {$ENDIF}
00871 Result := nil;
00872 if not IsNull(ColumnIndex) then
00873 begin
00874 Blob := GetBlob(ColumnIndex);
00875 if Blob <> nil then
00876 Result := Blob.GetStream;
00877 end;
00878 LastWasNull := (Result = nil);
00879 end;
00880
00881 {**
00882 Gets the value of a column in the current row as a stream of
00883 Gets the value of the designated column in the current row
00884 of this <code>ResultSet</code> object as
00885 as a stream of Unicode characters.
00886 The value can then be read in chunks from the
00887 stream. This method is particularly
00888 suitable for retrieving large<code>LONGVARCHAR</code>values. The JDBC driver will
00889 do any necessary conversion from the database format into Unicode.
00890 The byte format of the Unicode stream must be Java UTF-8,
00891 as specified in the Java virtual machine specification.
00892
00893 <P><B>Note:</B> All the data in the returned stream must be
00894 read prior to getting the value of any other column. The next
00895 call to a <code>getXXX</code> method implicitly closes the stream. Also, a
00896 stream may return <code>0</code> when the method
00897 <code>InputStream.available</code>
00898 is called whether there is data available or not.
00899
00900 @param columnIndex the first column is 1, the second is 2, ...
00901 @return a Java input stream that delivers the database column value
00902 as a stream in Java UTF-8 byte format; if the value is SQL
00903 <code>NULL</code>, the value returned is <code>null</code>
00904 }
00905 function TZAbstractResultSet.GetUnicodeStream(ColumnIndex: Integer): TStream;
00906 var
00907 Blob: IZBlob;
00908 begin
00909 {$IFNDEF DISABLE_CHECKING}
00910 CheckColumnConvertion(ColumnIndex, stUnicodeStream);
00911 {$ENDIF}
00912 Result := nil;
00913 if not IsNull(ColumnIndex) then
00914 begin
00915 Blob := GetBlob(ColumnIndex);
00916 if Blob <> nil then
00917 Result := Blob.GetStream;
00918 end;
00919 LastWasNull := (Result = nil);
00920 end;
00921
00922 {**
00923 Gets the value of a column in the current row as a stream of
00924 Gets the value of the designated column in the current row
00925 of this <code>ResultSet</code> object as a binary stream of
00926 uninterpreted bytes. The value can then be read in chunks from the
00927 stream. This method is particularly
00928 suitable for retrieving large <code>LONGVARBINARY</code> values.
00929
00930 <P><B>Note:</B> All the data in the returned stream must be
00931 read prior to getting the value of any other column. The next
00932 call to a <code>getXXX</code> method implicitly closes the stream. Also, a
00933 stream may return <code>0</code> when the method
00934 <code>InputStream.available</code>
00935 is called whether there is data available or not.
00936
00937 @param columnIndex the first column is 1, the second is 2, ...
00938 @return a Java input stream that delivers the database column value
00939 as a stream of uninterpreted bytes;
00940 if the value is SQL <code>NULL</code>, the value returned is <code>null</code>
00941 }
00942 function TZAbstractResultSet.GetBinaryStream(ColumnIndex: Integer): TStream;
00943 var
00944 Blob: IZBlob;
00945 begin
00946 {$IFNDEF DISABLE_CHECKING}
00947 CheckColumnConvertion(ColumnIndex, stBinaryStream);
00948 {$ENDIF}
00949 Result := nil;
00950 if not IsNull(ColumnIndex) then
00951 begin
00952 Blob := GetBlob(ColumnIndex);
00953 if Blob <> nil then
00954 Result := Blob.GetStream;
00955 end;
00956 LastWasNull := (Result = nil);
00957 end;
00958
00959 {**
00960 Returns the value of the designated column in the current row
00961 of this <code>ResultSet</code> object as a <code>Blob</code> object
00962 in the Java programming language.
00963
00964 @param ColumnIndex the first column is 1, the second is 2, ...
00965 @return a <code>Blob</code> object representing the SQL <code>BLOB</code> value in
00966 the specified column
00967 }
00968 function TZAbstractResultSet.GetBlob(ColumnIndex: Integer): IZBlob;
00969 begin
00970 {$IFNDEF DISABLE_CHECKING}
00971 CheckBlobColumn(ColumnIndex);
00972 {$ENDIF}
00973 Result := TZAbstractBlob.CreateWithStream(nil);
00974 end;
00975
00976 {**
00977 Returns the value of the designated column in the current row
00978 of this <code>ResultSet</code> object as a <code>Variant</code> object.
00979
00980 @param ColumnIndex the first column is 1, the second is 2, ...
00981 @return a <code>Variant</code> object representing the SQL
00982 any value in the specified column
00983 }
00984 function TZAbstractResultSet.GetValue(ColumnIndex: Integer): TZVariant;
00985 var
00986 Metadata: TZAbstractResultSetMetadata;
00987 begin
00988 {$IFNDEF DISABLE_CHECKING}
00989 CheckClosed;
00990 {$ENDIF}
00991 Metadata := TZAbstractResultSetMetadata(FMetadata);
00992 {$IFNDEF DISABLE_CHECKING}
00993 if (Metadata = nil) or (ColumnIndex <= 0)
00994 or (ColumnIndex > Metadata.GetColumnCount) then
00995 begin
00996 raise EZSQLException.Create(
00997 Format(SColumnIsNotAccessable, [ColumnIndex]));
00998 end;
00999 {$ENDIF}
01000
01001 case Metadata.GetColumnType(ColumnIndex) of
01002 stBoolean:
01003 begin
01004 Result.VType := vtBoolean;
01005 Result.VBoolean := GetBoolean(ColumnIndex);
01006 end;
01007 stByte, stShort, stInteger, stLong:
01008 begin
01009 Result.VType := vtInteger;
01010 Result.VInteger := GetLong(ColumnIndex);
01011 end;
01012 stFloat, stDouble, stBigDecimal:
01013 begin
01014 Result.VType := vtFloat;
01015 Result.VFloat := GetBigDecimal(ColumnIndex);
01016 end;
01017 stDate, stTime, stTimestamp:
01018 begin
01019 Result.VType := vtDateTime;
01020 Result.VDateTime := GetTimestamp(ColumnIndex);
01021 end;
01022 stString, stBytes, stAsciiStream, stBinaryStream:
01023 begin
01024 Result.VType := vtString;
01025 Result.VString := GetString(ColumnIndex);
01026 end;
01027 stUnicodeString, stUnicodeStream:
01028 begin
01029 Result.VType := vtUnicodeString;
01030 Result.VUnicodeString := GetUnicodeString(ColumnIndex);
01031 end;
01032 else
01033 Result.VType := vtNull;
01034 end;
01035
01036 if WasNull then
01037 Result.VType := vtNull;
01038 end;
01039
01040 //======================================================================
01041 // Methods for accessing results by column name
01042 //======================================================================
01043
01044 {**
01045 Indicates if the value of the designated column in the current row
01046 of this <code>ResultSet</code> object is Null.
01047
01048 @param columnName the SQL name of the column
01049 @return if the value is SQL <code>NULL</code>, the
01050 value returned is <code>true</code>. <code>false</code> otherwise.
01051 }
01052 function TZAbstractResultSet.IsNullByName(const ColumnName: string): Boolean;
01053 begin
01054 Result := IsNull(GetColumnIndex(ColumnName));
01055 end;
01056
01057 {**
01058 Gets the value of the designated column in the current row
01059 of this <code>ResultSet</code> object as
01060 a <code>PChar</code> in the Delphi programming language.
01061
01062 @param columnName the SQL name of the column
01063 @return the column value; if the value is SQL <code>NULL</code>, the
01064 value returned is <code>null</code>
01065 }
01066 function TZAbstractResultSet.GetPCharByName(const ColumnName: string): PChar;
01067 begin
01068 Result := GetPChar(GetColumnIndex(ColumnName));
01069 end;
01070
01071 {**
01072 Gets the value of the designated column in the current row
01073 of this <code>ResultSet</code> object as
01074 a <code>String</code> in the Java programming language.
01075
01076 @param columnName the SQL name of the column
01077 @return the column value; if the value is SQL <code>NULL</code>, the
01078 value returned is <code>null</code>
01079 }
01080 function TZAbstractResultSet.GetStringByName(const ColumnName: string): string;
01081 begin
01082 Result := GetString(GetColumnIndex(ColumnName));
01083 end;
01084
01085 {**
01086 Gets the value of the designated column in the current row
01087 of this <code>ResultSet</code> object as
01088 a <code>WideString</code> in the Object Pascal programming language.
01089
01090 @param columnName the SQL name of the column
01091 @return the column value; if the value is SQL <code>NULL</code>, the
01092 value returned is <code>null</code>
01093 }
01094 function TZAbstractResultSet.GetUnicodeStringByName(const ColumnName: string):
01095 WideString;
01096 begin
01097 Result := GetUnicodeString(GetColumnIndex(ColumnName));
01098 end;
01099
01100 {**
01101 Gets the value of the designated column in the current row
01102 of this <code>ResultSet</code> object as
01103 a <code>boolean</code> in the Java programming language.
01104
01105 @param columnName the SQL name of the column
01106 @return the column value; if the value is SQL <code>NULL</code>, the
01107 value returned is <code>false</code>
01108 }
01109 function TZAbstractResultSet.GetBooleanByName(const ColumnName: string): Boolean;
01110 begin
01111 Result := GetBoolean(GetColumnIndex(ColumnName));
01112 end;
01113
01114 {**
01115 Gets the value of the designated column in the current row
01116 of this <code>ResultSet</code> object as
01117 a <code>byte</code> in the Java programming language.
01118
01119 @param columnName the SQL name of the column
01120 @return the column value; if the value is SQL <code>NULL</code>, the
01121 value returned is <code>0</code>
01122 }
01123 function TZAbstractResultSet.GetByteByName(const ColumnName: string): ShortInt;
01124 begin
01125 Result := GetByte(GetColumnIndex(ColumnName));
01126 end;
01127
01128 {**
01129 Gets the value of the designated column in the current row
01130 of this <code>ResultSet</code> object as
01131 a <code>short</code> in the Java programming language.
01132
01133 @param columnName the SQL name of the column
01134 @return the column value; if the value is SQL <code>NULL</code>, the
01135 value returned is <code>0</code>
01136 }
01137 function TZAbstractResultSet.GetShortByName(const ColumnName: string): SmallInt;
01138 begin
01139 Result := GetShort(GetColumnIndex(ColumnName));
01140 end;
01141
01142 {**
01143 Gets the value of the designated column in the current row
01144 of this <code>ResultSet</code> object as
01145 an <code>int</code> in the Java programming language.
01146
01147 @param columnName the SQL name of the column
01148 @return the column value; if the value is SQL <code>NULL</code>, the
01149 value returned is <code>0</code>
01150 }
01151 function TZAbstractResultSet.GetIntByName(const ColumnName: string): Integer;
01152 begin
01153 Result := GetInt(GetColumnIndex(ColumnName));
01154 end;
01155
01156 {**
01157 Gets the value of the designated column in the current row
01158 of this <code>ResultSet</code> object as
01159 a <code>long</code> in the Java programming language.
01160
01161 @param columnName the SQL name of the column
01162 @return the column value; if the value is SQL <code>NULL</code>, the
01163 value returned is <code>0</code>
01164 }
01165 function TZAbstractResultSet.GetLongByName(const ColumnName: string): Int64;
01166 begin
01167 Result := GetLong(GetColumnIndex(ColumnName));
01168 end;
01169
01170 {**
01171 Gets the value of the designated column in the current row
01172 of this <code>ResultSet</code> object as
01173 a <code>float</code> in the Java programming language.
01174
01175 @param columnName the SQL name of the column
01176 @return the column value; if the value is SQL <code>NULL</code>, the
01177 value returned is <code>0</code>
01178 }
01179 function TZAbstractResultSet.GetFloatByName(const ColumnName: string): Single;
01180 begin
01181 Result := GetFloat(GetColumnIndex(ColumnName));
01182 end;
01183
01184 {**
01185 Gets the value of the designated column in the current row
01186 of this <code>ResultSet</code> object as
01187 a <code>double</code> in the Java programming language.
01188
01189 @param columnName the SQL name of the column
01190 @return the column value; if the value is SQL <code>NULL</code>, the
01191 value returned is <code>0</code>
01192 }
01193 function TZAbstractResultSet.GetDoubleByName(const ColumnName: string): Double;
01194 begin
01195 Result := GetDouble(GetColumnIndex(ColumnName));
01196 end;
01197
01198 {**
01199 Gets the value of the designated column in the current row
01200 of this <code>ResultSet</code> object as
01201 a <code>java.math.BigDecimal</code> in the Java programming language.
01202
01203 @param columnName the SQL name of the column
01204 @return the column value; if the value is SQL <code>NULL</code>, the
01205 value returned is <code>null</code>
01206 }
01207 function TZAbstractResultSet.GetBigDecimalByName(const ColumnName: string): Extended;
01208 begin
01209 Result := GetBigDecimal(GetColumnIndex(ColumnName));
01210 end;
01211
01212 {**
01213 Gets the value of the designated column in the current row
01214 of this <code>ResultSet</code> object as
01215 a <code>byte</code> array in the Java programming language.
01216 The bytes represent the raw values returned by the driver.
01217
01218 @param columnName the SQL name of the column
01219 @return the column value; if the value is SQL <code>NULL</code>, the
01220 value returned is <code>null</code>
01221 }
01222 function TZAbstractResultSet.GetBytesByName(const ColumnName: string): TByteDynArray;
01223 begin
01224 Result := GetBytes(GetColumnIndex(ColumnName));
01225 end;
01226
01227 {**
01228 Gets the value of the designated column in the current row
01229 of this <code>ResultSet</code> object as
01230 a <code>java.sql.Date</code> object in the Java programming language.
01231
01232 @param columnName the SQL name of the column
01233 @return the column value; if the value is SQL <code>NULL</code>, the
01234 value returned is <code>null</code>
01235 }
01236 function TZAbstractResultSet.GetDateByName(const ColumnName: string): TDateTime;
01237 begin
01238 Result := GetDate(GetColumnIndex(ColumnName));
01239 end;
01240
01241 {**
01242 Gets the value of the designated column in the current row
01243 of this <code>ResultSet</code> object as
01244 a <code>java.sql.Time</code> object in the Java programming language.
01245
01246 @param columnName the SQL name of the column
01247 @return the column value; if the value is SQL <code>NULL</code>,
01248 the value returned is <code>null</code>
01249 }
01250 function TZAbstractResultSet.GetTimeByName(const ColumnName: string): TDateTime;
01251 begin
01252 Result := GetTime(GetColumnIndex(ColumnName));
01253 end;
01254
01255 {**
01256 Gets the value of the designated column in the current row
01257 of this <code>ResultSet</code> object as
01258 a <code>java.sql.Timestamp</code> object.
01259
01260 @param columnName the SQL name of the column
01261 @return the column value; if the value is SQL <code>NULL</code>, the
01262 value returned is <code>null</code>
01263 }
01264 function TZAbstractResultSet.GetTimestampByName(const ColumnName: string): TDateTime;
01265 begin
01266 Result := GetTimestamp(GetColumnIndex(ColumnName));
01267 end;
01268
01269 {**
01270 Gets the value of the designated column in the current row
01271 of this <code>ResultSet</code> object as a stream of
01272 ASCII characters. The value can then be read in chunks from the
01273 stream. This method is particularly
01274 suitable for retrieving large <code>LONGVARCHAR</code> values.
01275 The JDBC driver will
01276 do any necessary conversion from the database format into ASCII.
01277
01278 <P><B>Note:</B> All the data in the returned stream must be
01279 read prior to getting the value of any other column. The next
01280 call to a <code>getXXX</code> method implicitly closes the stream. Also, a
01281 stream may return <code>0</code> when the method <code>available</code>
01282 is called whether there is data available or not.
01283
01284 @param columnName the SQL name of the column
01285 @return a Java input stream that delivers the database column value
01286 as a stream of one-byte ASCII characters.
01287 If the value is SQL <code>NULL</code>,
01288 the value returned is <code>null</code>.
01289 }
01290 function TZAbstractResultSet.GetAsciiStreamByName(const ColumnName: string): TStream;
01291 begin
01292 Result := GetAsciiStream(GetColumnIndex(ColumnName));
01293 end;
01294
01295 {**
01296 Gets the value of the designated column in the current row
01297 of this <code>ResultSet</code> object as a stream of
01298 Unicode characters. The value can then be read in chunks from the
01299 stream. This method is particularly
01300 suitable for retrieving large <code>LONGVARCHAR</code> values.
01301 The JDBC driver will
01302 do any necessary conversion from the database format into Unicode.
01303 The byte format of the Unicode stream must be Java UTF-8,
01304 as defined in the Java virtual machine specification.
01305
01306 <P><B>Note:</B> All the data in the returned stream must be
01307 read prior to getting the value of any other column. The next
01308 call to a <code>getXXX</code> method implicitly closes the stream. Also, a
01309 stream may return <code>0</code> when the method <code>available</code>
01310 is called whether there is data available or not.
01311
01312 @param columnName the SQL name of the column
01313 @return a Java input stream that delivers the database column value
01314 as a stream of two-byte Unicode characters.
01315 If the value is SQL <code>NULL</code>, the value returned is <code>null</code>.
01316 }
01317 function TZAbstractResultSet.GetUnicodeStreamByName(const ColumnName: string): TStream;
01318 begin
01319 Result := GetUnicodeStream(GetColumnIndex(ColumnName));
01320 end;
01321
01322 {**
01323 Gets the value of the designated column in the current row
01324 of this <code>ResultSet</code> object as a stream of uninterpreted
01325 <code>byte</code>s.
01326 The value can then be read in chunks from the
01327 stream. This method is particularly
01328 suitable for retrieving large <code>LONGVARBINARY</code>
01329 values.
01330
01331 <P><B>Note:</B> All the data in the returned stream must be
01332 read prior to getting the value of any other column. The next
01333 call to a <code>getXXX</code> method implicitly closes the stream. Also, a
01334 stream may return <code>0</code> when the method <code>available</code>
01335 is called whether there is data available or not.
01336
01337 @param columnName the SQL name of the column
01338 @return a Java input stream that delivers the database column value
01339 as a stream of uninterpreted bytes;
01340 if the value is SQL <code>NULL</code>, the result is <code>null</code>
01341 }
01342 function TZAbstractResultSet.GetBinaryStreamByName(const ColumnName: string): TStream;
01343 begin
01344 Result := GetBinaryStream(GetColumnIndex(ColumnName));
01345 end;
01346
01347 {**
01348 Returns the value of the designated column in the current row
01349 of this <code>ResultSet</code> object as a <code>Blob</code> object
01350 in the Java programming language.
01351
01352 @param colName the name of the column from which to retrieve the value
01353 @return a <code>Blob</code> object representing the SQL <code>BLOB</code> value in
01354 the specified column
01355 }
01356 function TZAbstractResultSet.GetBlobByName(const ColumnName: string): IZBlob;
01357 begin
01358 Result := GetBlob(GetColumnIndex(ColumnName));
01359 end;
01360
01361 {**
01362 Returns the value of the designated column in the current row
01363 of this <code>ResultSet</code> object as a <code>Variant</code> object.
01364
01365 @param colName the name of the column from which to retrieve the value
01366 @return a <code>Blob</code> object representing the SQL <code>Any</code>
01367 value in the specified column
01368 }
01369 function TZAbstractResultSet.GetValueByName(const ColumnName: string): TZVariant;
01370 begin
01371 Result := GetValue(GetColumnIndex(ColumnName));
01372 end;
01373
01374 //=====================================================================
01375 // Advanced features:
01376 //=====================================================================
01377
01378 {**
01379 Returns the first warning reported by calls on this
01380 <code>ResultSet</code> object.
01381 Subsequent warnings on this <code>ResultSet</code> object
01382 will be chained to the <code>SQLWarning</code> object that
01383 this method returns.
01384
01385 <P>The warning chain is automatically cleared each time a new
01386 row is read.
01387
01388 <P><B>Note:</B> This warning chain only covers warnings caused
01389 by <code>ResultSet</code> methods. Any warning caused by
01390 <code>Statement</code> methods
01391 (such as reading OUT parameters) will be chained on the
01392 <code>Statement</code> object.
01393
01394 @return the first <code>SQLWarning</code> object reported or <code>null</code>
01395 }
01396 function TZAbstractResultSet.GetWarnings: EZSQLWarning;
01397 begin
01398 Result := nil;
01399 end;
01400
01401 {**
01402 Clears all warnings reported on this <code>ResultSet</code> object.
01403 After this method is called, the method <code>getWarnings</code>
01404 returns <code>null</code> until a new warning is
01405 reported for this <code>ResultSet</code> object.
01406 }
01407 procedure TZAbstractResultSet.ClearWarnings;
01408 begin
01409 end;
01410
01411 {**
01412 Gets the name of the SQL cursor used by this <code>ResultSet</code>
01413 object.
01414
01415 <P>In SQL, a result table is retrieved through a cursor that is
01416 named. The current row of a result set can be updated or deleted
01417 using a positioned update/delete statement that references the
01418 cursor name. To insure that the cursor has the proper isolation
01419 level to support update, the cursor's <code>select</code> statement should be
01420 of the form 'select for update'. If the 'for update' clause is
01421 omitted, the positioned updates may fail.
01422
01423 <P>The JDBC API supports this SQL feature by providing the name of the
01424 SQL cursor used by a <code>ResultSet</code> object.
01425 The current row of a <code>ResultSet</code> object
01426 is also the current row of this SQL cursor.
01427
01428 <P><B>Note:</B> If positioned update is not supported, a
01429 <code>SQLException</code> is thrown.
01430
01431 @return the SQL name for this <code>ResultSet</code> object's cursor
01432 }
01433 function TZAbstractResultSet.GetCursorName: string;
01434 begin
01435 Result := '';
01436 end;
01437
01438 {**
01439 Retrieves the number, types and properties of
01440 this <code>ResultSet</code> object's columns.
01441 @return the description of this <code>ResultSet</code> object's columns
01442 }
01443 function TZAbstractResultSet.GetMetaData: IZResultSetMetaData;
01444 begin
01445 Result := TZAbstractResultSetMetadata(FMetadata);
01446 end;
01447
01448 {**
01449 Maps the given <code>ResultSet</code> column name to its
01450 <code>ResultSet</code> column index.
01451
01452 @param columnName the name of the column
01453 @return the column index of the given column name
01454 }
01455 function TZAbstractResultSet.GetColumnIndex(const ColumnName: string): Integer;
01456 begin
01457 Result := FindColumn(ColumnName);
01458
01459 if Result < 1 then
01460 raise EZSQLException.Create(Format(SColumnWasNotFound, [ColumnName]));
01461 end;
01462
01463 {**
01464 Maps the given <code>ResultSet</code> column name to its
01465 <code>ResultSet</code> column index.
01466
01467 @param columnName the name of the column
01468 @return the column index of the given column name
01469 }
01470 function TZAbstractResultSet.FindColumn(const ColumnName: string): Integer;
01471 var
01472 I: Integer;
01473 Metadata: TZAbstractResultSetMetadata;
01474 begin
01475 CheckClosed;
01476 Metadata := TZAbstractResultSetMetadata(FMetadata);
01477 Result := 0;
01478
01479 { Search for case sensitive columns. }
01480 for I := 1 to Metadata.GetColumnCount do
01481 begin
01482 if Metadata.GetColumnLabel(I) = ColumnName then
01483 begin
01484 Result := I;
01485 Exit;
01486 end;
01487 end;
01488
01489 { Search for case insensitive columns. }
01490 for I := 1 to Metadata.GetColumnCount do
01491 begin
01492 if AnsiUpperCase(Metadata.GetColumnLabel(I)) = AnsiUpperCase(ColumnName) then
01493 begin
01494 Result := I;
01495 Exit;
01496 end;
01497 end;
01498 end;
01499
01500 //---------------------------------------------------------------------
01501 // Traversal/Positioning
01502 //---------------------------------------------------------------------
01503
01504 {**
01505 Indicates whether the cursor is before the first row in
01506 this <code>ResultSet</code> object.
01507
01508 @return <code>true</code> if the cursor is before the first row;
01509 <code>false</code> if the cursor is at any other position or the
01510 result set contains no rows
01511 }
01512 function TZAbstractResultSet.IsBeforeFirst: Boolean;
01513 begin
01514 Result := (FRowNo = 0);
01515 end;
01516
01517 {**
01518 Indicates whether the cursor is after the last row in
01519 this <code>ResultSet</code> object.
01520
01521 @return <code>true</code> if the cursor is after the last row;
01522 <code>false</code> if the cursor is at any other position or the
01523 result set contains no rows
01524 }
01525 function TZAbstractResultSet.IsAfterLast: Boolean;
01526 begin
01527 Result := {(FLastRowNo > 0) and} (FRowNo > FLastRowNo);
01528 end;
01529
01530 {**
01531 Indicates whether the cursor is on the first row of
01532 this <code>ResultSet</code> object.
01533
01534 @return <code>true</code> if the cursor is on the first row;
01535 <code>false</code> otherwise
01536 }
01537 function TZAbstractResultSet.IsFirst: Boolean;
01538 begin
01539 Result := (FRowNo = 1);
01540 end;
01541
01542 {**
01543 Indicates whether the cursor is on the last row of
01544 this <code>ResultSet</code> object.
01545 Note: Calling the method <code>isLast</code> may be expensive
01546 because the JDBC driver
01547 might need to fetch ahead one row in order to determine
01548 whether the current row is the last row in the result set.
01549
01550 @return <code>true</code> if the cursor is on the last row;
01551 <code>false</code> otherwise
01552 }
01553 function TZAbstractResultSet.IsLast: Boolean;
01554 begin
01555 Result := {(FLastRowNo > 0) and} (FRowNo = FLastRowNo);
01556 end;
01557
01558 {**
01559 Moves the cursor to the front of
01560 this <code>ResultSet</code> object, just before the
01561 first row. This method has no effect if the result set contains no rows.
01562 }
01563 procedure TZAbstractResultSet.BeforeFirst;
01564 begin
01565 MoveAbsolute(0);
01566 end;
01567
01568 {**
01569 Moves the cursor to the end of
01570 this <code>ResultSet</code> object, just after the
01571 last row. This method has no effect if the result set contains no rows.
01572 }
01573 procedure TZAbstractResultSet.AfterLast;
01574 begin
01575 Last;
01576 Next;
01577 end;
01578
01579 {**
01580 Moves the cursor to the first row in
01581 this <code>ResultSet</code> object.
01582
01583 @return <code>true</code> if the cursor is on a valid row;
01584 <code>false</code> if there are no rows in the result set
01585 }
01586 function TZAbstractResultSet.First: Boolean;
01587 begin
01588 Result := MoveAbsolute(1);
01589 end;
01590
01591 {**
01592 Moves the cursor to the last row in
01593 this <code>ResultSet</code> object.
01594
01595 @return <code>true</code> if the cursor is on a valid row;
01596 <code>false</code> if there are no rows in the result set
01597 }
01598 function TZAbstractResultSet.Last: Boolean;
01599 begin
01600 Result := MoveAbsolute(FLastRowNo);
01601 end;
01602
01603 {**
01604 Retrieves the current row number. The first row is number 1, the
01605 second number 2, and so on.
01606 @return the current row number; <code>0</code> if there is no current row
01607 }
01608 function TZAbstractResultSet.GetRow: Integer;
01609 begin
01610 Result := FRowNo;
01611 end;
01612
01613 {**
01614 Moves the cursor to the given row number in
01615 this <code>ResultSet</code> object.
01616
01617 <p>If the row number is positive, the cursor moves to
01618 the given row number with respect to the
01619 beginning of the result set. The first row is row 1, the second
01620 is row 2, and so on.
01621
01622 <p>If the given row number is negative, the cursor moves to
01623 an absolute row position with respect to
01624 the end of the result set. For example, calling the method
01625 <code>absolute(-1)</code> positions the
01626 cursor on the last row; calling the method <code>absolute(-2)</code>
01627 moves the cursor to the next-to-last row, and so on.
01628
01629 <p>An attempt to position the cursor beyond the first/last row in
01630 the result set leaves the cursor before the first row or after
01631 the last row.
01632
01633 <p><B>Note:</B> Calling <code>absolute(1)</code> is the same
01634 as calling <code>first()</code>. Calling <code>absolute(-1)</code>
01635 is the same as calling <code>last()</code>.
01636
01637 @return <code>true</code> if the cursor is on the result set;
01638 <code>false</code> otherwise
01639 }
01640 function TZAbstractResultSet.MoveAbsolute(Row: Integer): Boolean;
01641 begin
01642 Result := False;
01643 RaiseForwardOnlyException;
01644 end;
01645
01646 {**
01647 Moves the cursor a relative number of rows, either positive or negative.
01648 Attempting to move beyond the first/last row in the
01649 result set positions the cursor before/after the
01650 the first/last row. Calling <code>relative(0)</code> is valid, but does
01651 not change the cursor position.
01652
01653 <p>Note: Calling the method <code>relative(1)</code>
01654 is different from calling the method <code>next()</code>
01655 because is makes sense to call <code>next()</code> when there
01656 is no current row,
01657 for example, when the cursor is positioned before the first row
01658 or after the last row of the result set.
01659
01660 @return <code>true</code> if the cursor is on a row;
01661 <code>false</code> otherwise
01662 }
01663 function TZAbstractResultSet.MoveRelative(Rows: Integer): Boolean;
01664 begin
01665 Result := MoveAbsolute(FRowNo + Rows);
01666 end;
01667
01668 {**
01669 Moves the cursor to the previous row in this
01670 <code>ResultSet</code> object.
01671
01672 <p><B>Note:</B> Calling the method <code>previous()</code> is not the same as
01673 calling the method <code>relative(-1)</code> because it
01674 makes sense to call</code>previous()</code> when there is no current row.
01675
01676 @return <code>true</code> if the cursor is on a valid row;
01677 <code>false</code> if it is off the result set
01678 }
01679 function TZAbstractResultSet.Previous: Boolean;
01680 begin
01681 Result := MoveAbsolute(FRowNo - 1);
01682 end;
01683
01684 {**
01685 Moves the cursor down one row from its current position.
01686 A <code>ResultSet</code> cursor is initially positioned
01687 before the first row; the first call to the method
01688 <code>next</code> makes the first row the current row; the
01689 second call makes the second row the current row, and so on.
01690
01691 <P>If an input stream is open for the current row, a call
01692 to the method <code>next</code> will
01693 implicitly close it. A <code>ResultSet</code> object's
01694 warning chain is cleared when a new row is read.
01695
01696 @return <code>true</code> if the new current row is valid;
01697 <code>false</code> if there are no more rows
01698 }
01699 function TZAbstractResultSet.Next: Boolean;
01700 begin
01701 Result := MoveAbsolute(FRowNo + 1);
01702 end;
01703
01704
01705
01706
01707
01708 {**
01709 Returns the fetch direction for this
01710 <code>ResultSet</code> object.
01711 @return the current fetch direction for this <code>ResultSet</code> object
01712 }
01713 function TZAbstractResultSet.GetFetchDirection: TZFetchDirection;
01714 begin
01715 Result := FFetchDirection;
01716 end;
01717
01718 {**
01719 Gives a hint as to the direction in which the rows in this
01720 <code>ResultSet</code> object will be processed.
01721 The initial value is determined by the
01722 <code>Statement</code> object
01723 that produced this <code>ResultSet</code> object.
01724 The fetch direction may be changed at any time.
01725 }
01726 procedure TZAbstractResultSet.SetFetchDirection(Direction: TZFetchDirection);
01727 begin
01728 if Direction <> fdForward then
01729 RaiseUnsupportedException;
01730 end;
01731
01732 {**
01733 Returns the fetch size for this
01734 <code>ResultSet</code> object.
01735 @return the current fetch size for this <code>ResultSet</code> object
01736 }
01737 function TZAbstractResultSet.GetFetchSize: Integer;
01738 begin
01739 Result := FFetchSize;
01740 end;
01741
01742 {**
01743 Gives the JDBC driver a hint as to the number of rows that should
01744 be fetched from the database when more rows are needed for this
01745 <code>ResultSet</code> object.
01746 If the fetch size specified is zero, the JDBC driver
01747 ignores the value and is free to make its own best guess as to what
01748 the fetch size should be. The default value is set by the
01749 <code>Statement</code> object
01750 that created the result set. The fetch size may be changed at any time.
01751
01752 @param rows the number of rows to fetch
01753 }
01754 procedure TZAbstractResultSet.SetFetchSize(Rows: Integer);
01755 begin
01756 FFetchSize := Rows;
01757 end;
01758
01759 {**
01760 Returns the type of this <code>ResultSet</code> object.
01761 The type is determined by the <code>Statement</code> object
01762 that created the result set.
01763
01764 @return <code>TYPE_FORWARD_ONLY</code>,
01765 <code>TYPE_SCROLL_INSENSITIVE</code>,
01766 or <code>TYPE_SCROLL_SENSITIVE</code>
01767 }
01768 function TZAbstractResultSet.GetType: TZResultSetType;
01769 begin
01770 Result := FResultSetType;
01771 end;
01772
01773 {**
01774 Returns the concurrency mode of this <code>ResultSet</code> object.
01775 The concurrency used is determined by the
01776 <code>Statement</code> object that created the result set.
01777
01778 @return the concurrency type, either <code>CONCUR_READ_ONLY</code>
01779 or <code>CONCUR_UPDATABLE</code>
01780 }
01781 function TZAbstractResultSet.GetConcurrency: TZResultSetConcurrency;
01782 begin
01783 Result := FResultSetConcurrency;
01784 end;
01785
01786 {**
01787 Gets an assigned post locate mode.
01788 @param the assigned post locate mode.
01789 }
01790 function TZAbstractResultSet.GetLocateUpdates: TZLocateUpdatesMode;
01791 begin
01792 Result := FLocateUpdates;
01793 end;
01794
01795 function TZAbstractResultSet.GetPostUpdates: TZPostUpdatesMode;
01796 begin
01797 Result := FPostUpdates;
01798 end;
01799
01800
01801
01802
01803
01804 {**
01805 Indicates whether the current row has been updated. The value returned
01806 depends on whether or not the result set can detect updates.
01807
01808 @return <code>true</code> if the row has been visibly updated
01809 by the owner or another, and updates are detected
01810 }
01811 function TZAbstractResultSet.RowUpdated: Boolean;
01812 begin
01813 Result := False;
01814 end;
01815
01816 {**
01817 Indicates whether the current row has had an insertion.
01818 The value returned depends on whether or not this
01819 <code>ResultSet</code> object can detect visible inserts.
01820
01821 @return <code>true</code> if a row has had an insertion
01822 and insertions are detected; <code>false</code> otherwise
01823 }
01824 function TZAbstractResultSet.RowInserted: Boolean;
01825 begin
01826 Result := False;
01827 end;
01828
01829 {**
01830 Indicates whether a row has been deleted. A deleted row may leave
01831 a visible "hole" in a result set. This method can be used to
01832 detect holes in a result set. The value returned depends on whether
01833 or not this <code>ResultSet</code> object can detect deletions.
01834
01835 @return <code>true</code> if a row was deleted and deletions are detected;
01836 <code>false</code> otherwise
01837 }
01838 function TZAbstractResultSet.RowDeleted: Boolean;
01839 begin
01840 Result := False;
01841 end;
01842
01843 {**
01844 Gives a nullable column a null value.
01845
01846 The <code>updateXXX</code> methods are used to update column values in the
01847 current row or the insert row. The <code>updateXXX</code> methods do not
01848 update the underlying database; instead the <code>updateRow</code>
01849 or <code>insertRow</code> methods are called to update the database.
01850
01851 @param columnIndex the first column is 1, the second is 2, ...
01852 }
01853 procedure TZAbstractResultSet.UpdateNull(ColumnIndex: Integer);
01854 begin
01855 RaiseReadOnlyException;
01856 end;
01857
01858 {**
01859 Updates the designated column with a <code>boolean</code> value.
01860 The <code>updateXXX</code> methods are used to update column values in the
01861 current row or the insert row. The <code>updateXXX</code> methods do not
01862 update the underlying database; instead the <code>updateRow</code> or
01863 <code>insertRow</code> methods are called to update the database.
01864
01865 @param columnIndex the first column is 1, the second is 2, ...
01866 @param x the new column value
01867 }
01868 procedure TZAbstractResultSet.UpdateBoolean(ColumnIndex: Integer; Value: Boolean);
01869 begin
01870 RaiseReadOnlyException;
01871 end;
01872
01873 {**
01874 Updates the designated column with a <code>byte</code> value.
01875 The <code>updateXXX</code> methods are used to update column values in the
01876 current row or the insert row. The <code>updateXXX</code> methods do not
01877 update the underlying database; instead the <code>updateRow</code> or
01878 <code>insertRow</code> methods are called to update the database.
01879
01880
01881 @param columnIndex the first column is 1, the second is 2, ...
01882 @param x the new column value
01883 }
01884 procedure TZAbstractResultSet.UpdateByte(ColumnIndex: Integer;
01885 Value: ShortInt);
01886 begin
01887 RaiseReadOnlyException;
01888 end;
01889
01890 {**
01891 Updates the designated column with a <code>short</code> value.
01892 The <code>updateXXX</code> methods are used to update column values in the
01893 current row or the insert row. The <code>updateXXX</code> methods do not
01894 update the underlying database; instead the <code>updateRow</code> or
01895 <code>insertRow</code> methods are called to update the database.
01896
01897 @param columnIndex the first column is 1, the second is 2, ...
01898 @param x the new column value
01899 }
01900 procedure TZAbstractResultSet.UpdateShort(ColumnIndex: Integer; Value: SmallInt);
01901 begin
01902 RaiseReadOnlyException;
01903 end;
01904
01905 {**
01906 Updates the designated column with an <code>int</code> value.
01907 The <code>updateXXX</code> methods are used to update column values in the
01908 current row or the insert row. The <code>updateXXX</code> methods do not
01909 update the underlying database; instead the <code>updateRow</code> or
01910 <code>insertRow</code> methods are called to update the database.
01911
01912 @param columnIndex the first column is 1, the second is 2, ...
01913 @param x the new column value
01914 }
01915 procedure TZAbstractResultSet.UpdateInt(ColumnIndex: Integer; Value: Integer);
01916 begin
01917 RaiseReadOnlyException;
01918 end;
01919
01920 {**
01921 Updates the designated column with a <code>long</code> value.
01922 The <code>updateXXX</code> methods are used to update column values in the
01923 current row or the insert row. The <code>updateXXX</code> methods do not
01924 update the underlying database; instead the <code>updateRow</code> or
01925 <code>insertRow</code> methods are called to update the database.
01926
01927 @param columnIndex the first column is 1, the second is 2, ...
01928 @param x the new column value
01929 }
01930 procedure TZAbstractResultSet.UpdateLong(ColumnIndex: Integer; Value: Int64);
01931 begin
01932 RaiseReadOnlyException;
01933 end;
01934
01935 {**
01936 Updates the designated column with a <code>float</code> value.
01937 The <code>updateXXX</code> methods are used to update column values in the
01938 current row or the insert row. The <code>updateXXX</code> methods do not
01939 update the underlying database; instead the <code>updateRow</code> or
01940 <code>insertRow</code> methods are called to update the database.
01941
01942 @param columnIndex the first column is 1, the second is 2, ...
01943 @param x the new column value
01944 }
01945 procedure TZAbstractResultSet.UpdateFloat(ColumnIndex: Integer; Value: Single);
01946 begin
01947 RaiseReadOnlyException;
01948 end;
01949
01950 {**
01951 Updates the designated column with a <code>double</code> value.
01952 The <code>updateXXX</code> methods are used to update column values in the
01953 current row or the insert row. The <code>updateXXX</code> methods do not
01954 update the underlying database; instead the <code>updateRow</code> or
01955 <code>insertRow</code> methods are called to update the database.
01956
01957 @param columnIndex the first column is 1, the second is 2, ...
01958 @param x the new column value
01959 }
01960 procedure TZAbstractResultSet.UpdateDouble(ColumnIndex: Integer; Value: Double);
01961 begin
01962 RaiseReadOnlyException;
01963 end;
01964
01965 {**
01966 Updates the designated column with a <code>java.math.BigDecimal</code>
01967 value.
01968 The <code>updateXXX</code> methods are used to update column values in the
01969 current row or the insert row. The <code>updateXXX</code> methods do not
01970 update the underlying database; instead the <code>updateRow</code> or
01971 <code>insertRow</code> methods are called to update the database.
01972
01973 @param columnIndex the first column is 1, the second is 2, ...
01974 @param x the new column value
01975 }
01976 procedure TZAbstractResultSet.UpdateBigDecimal(ColumnIndex: Integer;
01977 Value: Extended);
01978 begin
01979 RaiseReadOnlyException;
01980 end;
01981
01982 {**
01983 Updates the designated column with a <code>String</code> value.
01984 The <code>updateXXX</code> methods are used to update column values in the
01985 current row or the insert row. The <code>updateXXX</code> methods do not
01986 update the underlying database; instead the <code>updateRow</code> or
01987 <code>insertRow</code> methods are called to update the database.
01988
01989 @param columnIndex the first column is 1, the second is 2, ...
01990 @param x the new column value
01991 }
01992 procedure TZAbstractResultSet.UpdatePChar(ColumnIndex: Integer; Value: PChar);
01993 begin
01994 UpdateString(ColumnIndex, Value);
01995 end;
01996
01997 {**
01998 Updates the designated column with a <code>String</code> value.
01999 The <code>updateXXX</code> methods are used to update column values in the
02000 current row or the insert row. The <code>updateXXX</code> methods do not
02001 update the underlying database; instead the <code>updateRow</code> or
02002 <code>insertRow</code> methods are called to update the database.
02003
02004 @param columnIndex the first column is 1, the second is 2, ...
02005 @param x the new column value
02006 }
02007 procedure TZAbstractResultSet.UpdateString(ColumnIndex: Integer; const Value: string);
02008 begin
02009 RaiseReadOnlyException;
02010 end;
02011
02012 {**
02013 Updates the designated column with a <code>WideString</code> value.
02014 The <code>updateXXX</code> methods are used to update column values in the
02015 current row or the insert row. The <code>updateXXX</code> methods do not
02016 update the underlying database; instead the <code>updateRow</code> or
02017 <code>insertRow</code> methods are called to update the database.
02018
02019 @param columnIndex the first column is 1, the second is 2, ...
02020 @param x the new column value
02021 }
02022 procedure TZAbstractResultSet.UpdateUnicodeString(ColumnIndex: Integer;
02023 const Value: WideString);
02024 begin
02025 RaiseReadOnlyException;
02026 end;
02027
02028 {**
02029 Updates the designated column with a <code>byte</code> array value.
02030 The <code>updateXXX</code> methods are used to update column values in the
02031 current row or the insert row. The <code>updateXXX</code> methods do not
02032 update the underlying database; instead the <code>updateRow</code> or
02033 <code>insertRow</code> methods are called to update the database.
02034
02035 @param columnIndex the first column is 1, the second is 2, ...
02036 @param x the new column value
02037 }
02038 procedure TZAbstractResultSet.UpdateBytes(ColumnIndex: Integer;
02039 const Value: TByteDynArray);
02040 begin
02041 RaiseReadOnlyException;
02042 end;
02043
02044 {**
02045 Updates the designated column with a <code>java.sql.Date</code> value.
02046 The <code>updateXXX</code> methods are used to update column values in the
02047 current row or the insert row. The <code>updateXXX</code> methods do not
02048 update the underlying database; instead the <code>updateRow</code> or
02049 <code>insertRow</code> methods are called to update the database.
02050
02051 @param columnIndex the first column is 1, the second is 2, ...
02052 @param x the new column value
02053 }
02054 procedure TZAbstractResultSet.UpdateDate(ColumnIndex: Integer; Value: TDateTime);
02055 begin
02056 RaiseReadOnlyException;
02057 end;
02058
02059 {**
02060 Updates the designated column with a <code>java.sql.Time</code> value.
02061 The <code>updateXXX</code> methods are used to update column values in the
02062 current row or the insert row. The <code>updateXXX</code> methods do not
02063 update the underlying database; instead the <code>updateRow</code> or
02064 <code>insertRow</code> methods are called to update the database.
02065
02066 @param columnIndex the first column is 1, the second is 2, ...
02067 @param x the new column value
02068 }
02069 procedure TZAbstractResultSet.UpdateTime(ColumnIndex: Integer; Value: TDateTime);
02070 begin
02071 RaiseReadOnlyException;
02072 end;
02073
02074 {**
02075 Updates the designated column with a <code>java.sql.Timestamp</code>
02076 value.
02077 The <code>updateXXX</code> methods are used to update column values in the
02078 current row or the insert row. The <code>updateXXX</code> methods do not
02079 update the underlying database; instead the <code>updateRow</code> or
02080 <code>insertRow</code> methods are called to update the database.
02081
02082 @param columnIndex the first column is 1, the second is 2, ...
02083 @param x the new column value
02084 }
02085 procedure TZAbstractResultSet.UpdateTimestamp(ColumnIndex: Integer;
02086 Value: TDateTime);
02087 begin
02088 RaiseReadOnlyException;
02089 end;
02090
02091 {**
02092 Updates the designated column with an ascii stream value.
02093 The <code>updateXXX</code> methods are used to update column values in the
02094 current row or the insert row. The <code>updateXXX</code> methods do not
02095 update the underlying database; instead the <code>updateRow</code> or
02096 <code>insertRow</code> methods are called to update the database.
02097
02098 @param columnIndex the first column is 1, the second is 2, ...
02099 @param x the new column value
02100 }
02101 procedure TZAbstractResultSet.UpdateAsciiStream(ColumnIndex: Integer;
02102 Value: TStream);
02103 begin
02104 RaiseReadOnlyException;
02105 end;
02106
02107 {**
02108 Updates the designated column with a binary stream value.
02109 The <code>updateXXX</code> methods are used to update column values in the
02110 current row or the insert row. The <code>updateXXX</code> methods do not
02111 update the underlying database; instead the <code>updateRow</code> or
02112 <code>insertRow</code> methods are called to update the database.
02113
02114 @param columnIndex the first column is 1, the second is 2, ...
02115 @param x the new column value
02116 @param length the length of the stream
02117 }
02118 procedure TZAbstractResultSet.UpdateBinaryStream(ColumnIndex: Integer;
02119 Value: TStream);
02120 begin
02121 RaiseReadOnlyException;
02122 end;
02123
02124 {**
02125 Updates the designated column with a character stream value.
02126 The <code>updateXXX</code> methods are used to update column values in the
02127 current row or the insert row. The <code>updateXXX</code> methods do not
02128 update the underlying database; instead the <code>updateRow</code> or
02129 <code>insertRow</code> methods are called to update the database.
02130
02131 @param columnIndex the first column is 1, the second is 2, ...
02132 @param x the new column value
02133 }
02134 procedure TZAbstractResultSet.UpdateUnicodeStream(ColumnIndex: Integer;
02135 Value: TStream);
02136 begin
02137 RaiseReadOnlyException;
02138 end;
02139
02140 {**
02141 Updates the designated column with a variant value.
02142 The <code>updateXXX</code> methods are used to update column values in the
02143 current row or the insert row. The <code>updateXXX</code> methods do not
02144 update the underlying database; instead the <code>updateRow</code> or
02145 <code>insertRow</code> methods are called to update the database.
02146
02147 @param columnIndex the first column is 1, the second is 2, ...
02148 @param x the new column value
02149 }
02150 procedure TZAbstractResultSet.UpdateValue(ColumnIndex: Integer;
02151 const Value: TZVariant);
02152 begin
02153 case Value.VType of
02154 vtBoolean: UpdateBoolean(ColumnIndex, Value.VBoolean);
02155 vtInteger: UpdateLong(ColumnIndex, Value.VInteger);
02156 vtFloat: UpdateBigDecimal(ColumnIndex, Value.VFloat);
02157 vtString: UpdateString(ColumnIndex, Value.VString);
02158 vtDateTime: UpdateTimestamp(ColumnIndex, Value.VDateTime);
02159 vtUnicodeString: UpdateUnicodeString(ColumnIndex, Value.VUnicodeString);
02160 else UpdateNull(ColumnIndex);
02161 end;
02162 end;
02163
02164 {**
02165 Updates the designated column with a <code>null</code> value.
02166 The <code>updateXXX</code> methods are used to update column values in the
02167 current row or the insert row. The <code>updateXXX</code> methods do not
02168 update the underlying database; instead the <code>updateRow</code> or
02169 <code>insertRow</code> methods are called to update the database.
02170
02171 @param columnName the name of the column
02172 }
02173 procedure TZAbstractResultSet.UpdateNullByName(const ColumnName: string);
02174 begin
02175 UpdateNull(GetColumnIndex(ColumnName));
02176 end;
02177
02178 {**
02179 Updates the designated column with a <code>boolean</code> value.
02180 The <code>updateXXX</code> methods are used to update column values in the
02181 current row or the insert row. The <code>updateXXX</code> methods do not
02182 update the underlying database; instead the <code>updateRow</code> or
02183 <code>insertRow</code> methods are called to update the database.
02184
02185 @param columnName the name of the column
02186 @param x the new column value
02187 }
02188 procedure TZAbstractResultSet.UpdateBooleanByName(const ColumnName: string;
02189 Value: Boolean);
02190 begin
02191 UpdateBoolean(GetColumnIndex(ColumnName), Value);
02192 end;
02193
02194 {**
02195 Updates the designated column with a <code>byte</code> value.
02196 The <code>updateXXX</code> methods are used to update column values in the
02197 current row or the insert row. The <code>updateXXX</code> methods do not
02198 update the underlying database; instead the <code>updateRow</code> or
02199 <code>insertRow</code> methods are called to update the database.
02200
02201 @param columnName the name of the column
02202 @param x the new column value
02203 }
02204 procedure TZAbstractResultSet.UpdateByteByName(const ColumnName: string;
02205 Value: ShortInt);
02206 begin
02207 UpdateByte(GetColumnIndex(ColumnName), Value);
02208 end;
02209
02210 {**
02211 Updates the designated column with a <code>short</code> value.
02212 The <code>updateXXX</code> methods are used to update column values in the
02213 current row or the insert row. The <code>updateXXX</code> methods do not
02214 update the underlying database; instead the <code>updateRow</code> or
02215 <code>insertRow</code> methods are called to update the database.
02216
02217 @param columnName the name of the column
02218 @param x the new column value
02219 }
02220 procedure TZAbstractResultSet.UpdateShortByName(const ColumnName: string;
02221 Value: SmallInt);
02222 begin
02223 UpdateShort(GetColumnIndex(ColumnName), Value);
02224 end;
02225
02226 {**
02227 Updates the designated column with an <code>int</code> value.
02228 The <code>updateXXX</code> methods are used to update column values in the
02229 current row or the insert row. The <code>updateXXX</code> methods do not
02230 update the underlying database; instead the <code>updateRow</code> or
02231 <code>insertRow</code> methods are called to update the database.
02232
02233 @param columnName the name of the column
02234 @param x the new column value
02235 }
02236 procedure TZAbstractResultSet.UpdateIntByName(const ColumnName: string;
02237 Value: Integer);
02238 begin
02239 UpdateInt(GetColumnIndex(ColumnName), Value);
02240 end;
02241
02242 {**
02243 Updates the designated column with a <code>long</code> value.
02244 The <code>updateXXX</code> methods are used to update column values in the
02245 current row or the insert row. The <code>updateXXX</code> methods do not
02246 update the underlying database; instead the <code>updateRow</code> or
02247 <code>insertRow</code> methods are called to update the database.
02248
02249 @param columnName the name of the column
02250 @param x the new column value
02251 }
02252 procedure TZAbstractResultSet.UpdateLongByName(const ColumnName: string;
02253 Value: Int64);
02254 begin
02255 UpdateLong(GetColumnIndex(ColumnName), Value);
02256 end;
02257
02258 {**
02259 Updates the designated column with a <code>float </code> value.
02260 The <code>updateXXX</code> methods are used to update column values in the
02261 current row or the insert row. The <code>updateXXX</code> methods do not
02262 update the underlying database; instead the <code>updateRow</code> or
02263 <code>insertRow</code> methods are called to update the database.
02264
02265 @param columnName the name of the column
02266 @param x the new column value
02267 }
02268 procedure TZAbstractResultSet.UpdateFloatByName(const ColumnName: string;
02269 Value: Single);
02270 begin
02271 UpdateFloat(GetColumnIndex(ColumnName), Value);
02272 end;
02273
02274 {**
02275 Updates the designated column with a <code>double</code> value.
02276 The <code>updateXXX</code> methods are used to update column values in the
02277 current row or the insert row. The <code>updateXXX</code> methods do not
02278 update the underlying database; instead the <code>updateRow</code> or
02279 <code>insertRow</code> methods are called to update the database.
02280
02281 @param columnName the name of the column
02282 @param x the new column value
02283 }
02284 procedure TZAbstractResultSet.UpdateDoubleByName(const ColumnName: string;
02285 Value: Double);
02286 begin
02287 UpdateDouble(GetColumnIndex(ColumnName), Value);
02288 end;
02289
02290 {**
02291 Updates the designated column with a <code>java.sql.BigDecimal</code>
02292 value.
02293 The <code>updateXXX</code> methods are used to update column values in the
02294 current row or the insert row. The <code>updateXXX</code> methods do not
02295 update the underlying database; instead the <code>updateRow</code> or
02296 <code>insertRow</code> methods are called to update the database.
02297
02298 @param columnName the name of the column
02299 @param x the new column value
02300 }
02301 procedure TZAbstractResultSet.UpdateBigDecimalByName(const ColumnName: string;
02302 Value: Extended);
02303 begin
02304 UpdateBigDecimal(GetColumnIndex(ColumnName), Value);
02305 end;
02306
02307 {**
02308 Updates the designated column with a <code>String</code> value.
02309 The <code>updateXXX</code> methods are used to update column values in the
02310 current row or the insert row. The <code>updateXXX</code> methods do not
02311 update the underlying database; instead the <code>updateRow</code> or
02312 <code>insertRow</code> methods are called to update the database.
02313
02314 @param columnName the name of the column
02315 @param x the new column value
02316 }
02317 procedure TZAbstractResultSet.UpdatePCharByName(const ColumnName: string;
02318 Value: PChar);
02319 begin
02320 UpdatePChar(GetColumnIndex(ColumnName), Value);
02321 end;
02322
02323 {**
02324 Updates the designated column with a <code>String</code> value.
02325 The <code>updateXXX</code> methods are used to update column values in the
02326 current row or the insert row. The <code>updateXXX</code> methods do not
02327 update the underlying database; instead the <code>updateRow</code> or
02328 <code>insertRow</code> methods are called to update the database.
02329
02330 @param columnName the name of the column
02331 @param x the new column value
02332 }
02333 procedure TZAbstractResultSet.UpdateStringByName(const ColumnName: string;
02334 const Value: string);
02335 begin
02336 UpdateString(GetColumnIndex(ColumnName), Value);
02337 end;
02338
02339 {**
02340 Updates the designated column with a <code>WideString</code> value.
02341 The <code>updateXXX</code> methods are used to update column values in the
02342 current row or the insert row. The <code>updateXXX</code> methods do not
02343 update the underlying database; instead the <code>updateRow</code> or
02344 <code>insertRow</code> methods are called to update the database.
02345
02346 @param columnName the name of the column
02347 @param x the new column value
02348 }
02349 procedure TZAbstractResultSet.UpdateUnicodeStringByName(const ColumnName: string;
02350 const Value: WideString);
02351 begin
02352 UpdateUnicodeString(GetColumnIndex(ColumnName), Value);
02353 end;
02354
02355 {**
02356 Updates the designated column with a <code>boolean</code> value.
02357 The <code>updateXXX</code> methods are used to update column values in the
02358 current row or the insert row. The <code>updateXXX</code> methods do not
02359 update the underlying database; instead the <code>updateRow</code> or
02360 <code>insertRow</code> methods are called to update the database.
02361
02362 JDBC 2.0
02363
02364 Updates a column with a byte array value.
02365
02366 The <code>updateXXX</code> methods are used to update column values in the
02367 current row, or the insert row. The <code>updateXXX</code> methods do not
02368 update the underlying database; instead the <code>updateRow</code> or <code>insertRow</code>
02369 methods are called to update the database.
02370
02371 @param columnName the name of the column
02372 @param x the new column value
02373 }
02374 procedure TZAbstractResultSet.UpdateBytesByName(const ColumnName: string;
02375 const Value: TByteDynArray);
02376 begin
02377 UpdateBytes(GetColumnIndex(ColumnName), Value);
02378 end;
02379
02380 {**
02381 Updates the designated column with a <code>java.sql.Date</code> value.
02382 The <code>updateXXX</code> methods are used to update column values in the
02383 current row or the insert row. The <code>updateXXX</code> methods do not
02384 update the underlying database; instead the <code>updateRow</code> or
02385 <code>insertRow</code> methods are called to update the database.
02386
02387 @param columnName the name of the column
02388 @param x the new column value
02389 }
02390 procedure TZAbstractResultSet.UpdateDateByName(const ColumnName: string;
02391 Value: TDateTime);
02392 begin
02393 UpdateDate(GetColumnIndex(ColumnName), Value);
02394 end;
02395
02396 {**
02397 Updates the designated column with a <code>java.sql.Time</code> value.
02398 The <code>updateXXX</code> methods are used to update column values in the
02399 current row or the insert row. The <code>updateXXX</code> methods do not
02400 update the underlying database; instead the <code>updateRow</code> or
02401 <code>insertRow</code> methods are called to update the database.
02402
02403 @param columnName the name of the column
02404 @param x the new column value
02405 }
02406 procedure TZAbstractResultSet.UpdateTimeByName(const ColumnName: string;
02407 Value: TDateTime);
02408 begin
02409 UpdateTime(GetColumnIndex(ColumnName), Value);
02410 end;
02411
02412 {**
02413 Updates the designated column with a <code>java.sql.Timestamp</code>
02414 value.
02415 The <code>updateXXX</code> methods are used to update column values in the
02416 current row or the insert row. The <code>updateXXX</code> methods do not
02417 update the underlying database; instead the <code>updateRow</code> or
02418 <code>insertRow</code> methods are called to update the database.
02419
02420 @param columnName the name of the column
02421 @param x the new column value
02422 }
02423 procedure TZAbstractResultSet.UpdateTimestampByName(const ColumnName: string;
02424 Value: TDateTime);
02425 begin
02426 UpdateTimestamp(GetColumnIndex(ColumnName), Value);
02427 end;
02428
02429 {**
02430 Updates the designated column with an ascii stream value.
02431 The <code>updateXXX</code> methods are used to update column values in the
02432 current row or the insert row. The <code>updateXXX</code> methods do not
02433 update the underlying database; instead the <code>updateRow</code> or
02434 <code>insertRow</code> methods are called to update the database.
02435
02436 @param columnName the name of the column
02437 @param x the new column value
02438 }
02439 procedure TZAbstractResultSet.UpdateAsciiStreamByName(const ColumnName: string;
02440 Value: TStream);
02441 begin
02442 UpdateAsciiStream(GetColumnIndex(ColumnName), Value);
02443 end;
02444
02445 {**
02446 Updates the designated column with a binary stream value.
02447 The <code>updateXXX</code> methods are used to update column values in the
02448 current row or the insert row. The <code>updateXXX</code> methods do not
02449 update the underlying database; instead the <code>updateRow</code> or
02450 <code>insertRow</code> methods are called to update the database.
02451
02452 @param columnName the name of the column
02453 @param x the new column value
02454 }
02455 procedure TZAbstractResultSet.UpdateBinaryStreamByName(const ColumnName: string;
02456 Value: TStream);
02457 begin
02458 UpdateBinaryStream(GetColumnIndex(ColumnName), Value);
02459 end;
02460
02461 {**
02462 Updates the designated column with a character stream value.
02463 The <code>updateXXX</code> methods are used to update column values in the
02464 current row or the insert row. The <code>updateXXX</code> methods do not
02465 update the underlying database; instead the <code>updateRow</code> or
02466 <code>insertRow</code> methods are called to update the database.
02467
02468 @param columnName the name of the column
02469 @param x the new column value
02470 }
02471 procedure TZAbstractResultSet.UpdateUnicodeStreamByName(const ColumnName: string;
02472 Value: TStream);
02473 begin
02474 UpdateUnicodeStream(GetColumnIndex(ColumnName), Value);
02475 end;
02476
02477 {**
02478 Updates the designated column with a <code>Variant</code> value.
02479 The <code>updateXXX</code> methods are used to update column values in the
02480 current row or the insert row. The <code>updateXXX</code> methods do not
02481 update the underlying database; instead the <code>updateRow</code> or
02482 <code>insertRow</code> methods are called to update the database.
02483
02484 @param columnName the name of the column
02485 @param x the new column value
02486 }
02487 procedure TZAbstractResultSet.UpdateValueByName(const ColumnName: string;
02488 const Value: TZVariant);
02489 begin
02490 UpdateValue(GetColumnIndex(ColumnName), Value);
02491 end;
02492
02493 {**
02494 Inserts the contents of the insert row into this
02495 <code>ResultSet</code> objaect and into the database.
02496 The cursor must be on the insert row when this method is called.
02497 }
02498 procedure TZAbstractResultSet.InsertRow;
02499 begin
02500 RaiseReadOnlyException;
02501 end;
02502
02503 {**
02504 Updates the underlying database with the new contents of the
02505 current row of this <code>ResultSet</code> object.
02506 This method cannot be called when the cursor is on the insert row.
02507 }
02508 procedure TZAbstractResultSet.UpdateRow;
02509 begin
02510 RaiseReadOnlyException;
02511 end;
02512
02513 {**
02514 Deletes the current row from this <code>ResultSet</code> object
02515 and from the underlying database. This method cannot be called when
02516 the cursor is on the insert row.
02517 }
02518 procedure TZAbstractResultSet.DeleteRow;
02519 begin
02520 RaiseReadOnlyException;
02521 end;
02522
02523 {**
02524 Refreshes the current row with its most recent value in
02525 the database. This method cannot be called when
02526 the cursor is on the insert row.
02527
02528 <P>The <code>refreshRow</code> method provides a way for an
02529 application to
02530 explicitly tell the JDBC driver to refetch a row(s) from the
02531 database. An application may want to call <code>refreshRow</code> when
02532 caching or prefetching is being done by the JDBC driver to
02533 fetch the latest value of a row from the database. The JDBC driver
02534 may actually refresh multiple rows at once if the fetch size is
02535 greater than one.
02536
02537 <P> All values are refetched subject to the transaction isolation
02538 level and cursor sensitivity. If <code>refreshRow</code> is called after
02539 calling an <code>updateXXX</code> method, but before calling
02540 the method <code>updateRow</code>, then the
02541 updates made to the row are lost. Calling the method
02542 <code>refreshRow</code> frequently will likely slow performance.
02543 }
02544 procedure TZAbstractResultSet.RefreshRow;
02545 begin
02546 RaiseUnsupportedException;
02547 end;
02548
02549 {**
02550 Cancels the updates made to the current row in this
02551 <code>ResultSet</code> object.
02552 This method may be called after calling an
02553 <code>updateXXX</code> method(s) and before calling
02554 the method <code>updateRow</code> to roll back
02555 the updates made to a row. If no updates have been made or
02556 <code>updateRow</code> has already been called, this method has no
02557 effect.
02558 }
02559 procedure TZAbstractResultSet.CancelRowUpdates;
02560 begin
02561 RaiseReadOnlyException;
02562 end;
02563
02564 {**
02565 Moves the cursor to the insert row. The current cursor position is
02566 remembered while the cursor is positioned on the insert row.
02567
02568 The insert row is a special row associated with an updatable
02569 result set. It is essentially a buffer where a new row may
02570 be constructed by calling the <code>updateXXX</code> methods prior to
02571 inserting the row into the result set.
02572
02573 Only the <code>updateXXX</code>, <code>getXXX</code>,
02574 and <code>insertRow</code> methods may be
02575 called when the cursor is on the insert row. All of the columns in
02576 a result set must be given a value each time this method is
02577 called before calling <code>insertRow</code>.
02578 An <code>updateXXX</code> method must be called before a
02579 <code>getXXX</code> method can be called on a column value.
02580 }
02581 procedure TZAbstractResultSet.MoveToInsertRow;
02582 begin
02583 RaiseReadOnlyException;
02584 end;
02585
02586 {**
02587 Moves the cursor to the remembered cursor position, usually the
02588 current row. This method has no effect if the cursor is not on
02589 the insert row.
02590 }
02591 procedure TZAbstractResultSet.MoveToCurrentRow;
02592 begin
02593 end;
02594
02595 {**
02596 Compares fields from two row buffers.
02597 @param Row1 the first row buffer to compare.
02598 @param Row2 the second row buffer to compare.
02599 @param ColumnIndices column indices to compare.
02600 @param ColumnDirs compare direction for each columns.
02601 }
02602 function TZAbstractResultSet.CompareRows(Row1, Row2: Integer;
02603 const ColumnIndices: TIntegerDynArray; const ColumnDirs: TBooleanDynArray): Integer;
02604 var
02605 I: Integer;
02606 ColumnIndex: Integer;
02607 SaveRowNo: Integer;
02608 Value1, Value2: TZVariant;
02609
02610 function CompareFloat(Value1, Value2: Extended): Integer;
02611 begin
02612 Value1 := Value1 - Value2;
02613 if Value1 > 0 then
02614 Result := 1
02615 else if Value1 < 0 then
02616 Result := -1
02617 else Result := 0;
02618 end;
02619
02620 begin
02621 Result := 0;
02622 SaveRowNo := RowNo;
02623 try
02624 for I := Low(ColumnIndices) to High(ColumnIndices) do
02625 begin
02626 ColumnIndex := ColumnIndices[I];
02627
02628 MoveAbsolute(Row1);
02629 Value1 := GetValue(ColumnIndex);
02630 MoveAbsolute(Row2);
02631 Value2 := GetValue(ColumnIndex);
02632
02633 { Checks for both Null columns. }
02634 if (Value1.VType = vtNull) and (Value2.VType = vtNull) then
02635 Continue;
02636 { Checks for not-Null and Null columns. }
02637 if (Value1.VType = vtNull) or (Value2.VType = vtNull) then
02638 begin
02639 if Value1.VType <> vtNull then
02640 Result := 1
02641 else Result := -1;
02642 if not ColumnDirs[I] then
02643 Result := -Result;
02644 Break;
02645 end;
02646 case Value1.VType of
02647 vtBoolean:
02648 begin
02649 if Value1.VBoolean = Value2.VBoolean then
02650 Result := 0
02651 else if Value1.VBoolean = True then
02652 Result := 1
02653 else Result := -1;
02654 end;
02655 vtInteger:
02656 Result := Value1.VInteger - Value2.VInteger;
02657 vtFloat:
02658 Result := CompareFloat(Value1.VFloat, Value2.VFloat);
02659 vtDateTime:
02660 Result := CompareFloat(Value1.VDateTime, Value2.VDateTime);
02661 vtString:
02662 Result := AnsiCompareStr(Value1.VString, Value2.VString);
02663 vtUnicodeString:
02664 {$IFNDEF VER130BELOW}
02665 Result := WideCompareStr(Value1.VUnicodeString, Value2.VUnicodeString);
02666 {$ELSE}
02667 Result := AnsiCompareStr(Value1.VUnicodeString, Value2.VUnicodeString);
02668 {$ENDIF}
02669 end;
02670 if Result <> 0 then
02671 begin
02672 if not ColumnDirs[I] then
02673 Result := -Result;
02674 Break;
02675 end;
02676 end;
02677 finally
02678 MoveAbsolute(SaveRowNo);
02679 end;
02680 end;
02681
02682 {**
02683 Returns the <code>Statement</code> object that produced this
02684 <code>ResultSet</code> object.
02685 If the result set was generated some other way, such as by a
02686 <code>DatabaseMetaData</code> method, this method returns
02687 <code>null</code>.
02688
02689 @return the <code>Statment</code> object that produced
02690 this <code>ResultSet</code> object or <code>null</code>
02691 if the result set was produced some other way
02692 }
02693 function TZAbstractResultSet.GetStatement: IZStatement;
02694 begin
02695 Result := FStatement;
02696 end;
02697
02698 { TZAbstractBlob }
02699
02700 {**
02701 Constructs this class and assignes the main properties.
02702 @param Stream a data string object.
02703 }
02704 constructor TZAbstractBlob.CreateWithStream(Stream: TStream);
02705 begin
02706 inherited Create;
02707 FUpdated := False;
02708 if Assigned(Stream) then
02709 begin
02710 FBlobSize := Stream.Size;
02711 if FBlobSize > 0 then
02712 begin
02713 GetMem(FBlobData, FBlobSize);
02714 Stream.Position := 0;
02715 Stream.ReadBuffer(FBlobData^, FBlobSize);
02716 end;
02717 end
02718 else
02719 begin
02720 FBlobSize := -1;
02721 FBlobData := nil;
02722 end;
02723 end;
02724
02725 {**
02726 Constructs this class and assignes the main properties.
02727 @param Data a pointer to the blobdata.
02728 @param Size the size of the blobdata.
02729 }
02730 constructor TZAbstractBlob.CreateWithData(Data: Pointer; Size: Integer);
02731 begin
02732 inherited Create;
02733 FBlobData := nil;
02734 FBlobSize := Size;
02735 if FBlobSize > 0 then
02736 begin
02737 GetMem(FBlobData, FBlobSize);
02738 System.Move(Data^, FBlobData^, FBlobSize);
02739 end;
02740 FUpdated := False;
02741 end;
02742
02743 {**
02744 Destroys this object and cleanups the memory.
02745 }
02746 destructor TZAbstractBlob.Destroy;
02747 begin
02748 Clear;
02749 inherited Destroy;
02750 end;
02751
02752 {**
02753 Clears the content of this blob.
02754 }
02755 procedure TZAbstractBlob.Clear;
02756 begin
02757 if Assigned(FBlobData) then
02758 FreeMem(FBlobData);
02759 FBlobData := nil;
02760 FBlobSize := -1;
02761 FUpdated := True;
02762 end;
02763
02764 {**
02765 Clones this blob object.
02766 @return a clonned blob object.
02767 }
02768 function TZAbstractBlob.Clone: IZBlob;
02769 begin
02770 Result := TZAbstractBlob.CreateWithData(FBlobData, FBlobSize);
02771 end;
02772
02773 {**
02774 Checks if this blob has an empty content.
02775 @return <code>True</code> if this blob is empty.
02776 }
02777 function TZAbstractBlob.IsEmpty: Boolean;
02778 begin
02779 Result := FBlobSize < 0;
02780 end;
02781
02782 {**
02783 Checks if the content of this blob was updated.
02784 @return <code>True</code> is this blob was updated.
02785 }
02786 function TZAbstractBlob.IsUpdated: Boolean;
02787 begin
02788 Result := FUpdated;
02789 end;
02790
02791 {**
02792 Gets the length of the stored data.
02793 @return the length of the stored data or null if the blob is empty.
02794 }
02795 function TZAbstractBlob.Length: LongInt;
02796 begin
02797 Result := FBlobSize;
02798 end;
02799
02800 {**
02801 Gets the string from the stored data.
02802 @return a string which contains the stored data.
02803 }
02804 function TZAbstractBlob.GetString: string;
02805 begin
02806 if (FBlobSize > 0) and Assigned(FBlobData) then
02807 System.SetString(Result, PChar(FBlobData), FBlobSize)
02808 else Result := '';
02809 end;
02810
02811 {**
02812 Sets a new string data to this blob content.
02813 @param Value a new string data.
02814 }
02815 procedure TZAbstractBlob.SetString(const Value: string);
02816 begin
02817 Clear;
02818 FBlobSize := System.Length(Value);
02819 if FBlobSize > 0 then
02820 begin
02821 GetMem(FBlobData, FBlobSize);
02822 System.Move(PChar(Value)^, FBlobData^, FBlobSize);
02823 end;
02824 FUpdated := True;
02825 end;
02826
02827 {**
02828 Gets the wide string from the stored data.
02829 @return a string which contains the stored data.
02830 }
02831 function TZAbstractBlob.GetUnicodeString: WideString;
02832 begin
02833 Result := GetString;
02834 end;
02835
02836 {**
02837 Sets a new string data to this blob content.
02838 @param Value a new wide string data.
02839 }
02840 procedure TZAbstractBlob.SetUnicodeString(const Value: WideString);
02841 begin
02842 SetString(Value);
02843 end;
02844
02845 {**
02846 Gets the byte buffer from the stored data.
02847 @return a byte buffer which contains the stored data.
02848 }
02849 function TZAbstractBlob.GetBytes: TByteDynArray;
02850 var
02851 I: Integer;
02852 TempString: AnsiString;
02853 begin
02854 if not IsEmpty then
02855 begin
02856 TempString := GetString;
02857 SetLength(Result, System.Length(TempString));
02858 for I := 0 to System.Length(TempString) - 1 do
02859 Result[I] := Ord(TempString[I + 1]);
02860 end else
02861 Result := nil;
02862 end;
02863
02864 {**
02865 Sets a new byte buffer to this blob content.
02866 @param Value a new byte buffer.
02867 }
02868 procedure TZAbstractBlob.SetBytes(const Value: TByteDynArray);
02869 var
02870 I: Integer;
02871 TempString: AnsiString;
02872 begin
02873 if Value <> nil then
02874 begin
02875 SetLength(TempString, High(Value) + 1);
02876 for I := 0 to High(Value) do
02877 TempString[I + 1] := Chr(Value[I]);
02878 SetString(TempString);
02879 end else
02880 Clear;
02881 FUpdated := True;
02882 end;
02883
02884 {**
02885 Gets the associated stream object.
02886 @return an associated or newly created stream object.
02887 }
02888 function TZAbstractBlob.GetStream: TStream;
02889 begin
02890 Result := TMemoryStream.Create;
02891 if (FBlobSize > 0) and Assigned(FBlobData) then
02892 begin
02893 Result.Size := FBlobSize;
02894 System.Move(FBlobData^, TMemoryStream(Result).Memory^, FBlobSize);
02895 end;
02896 Result.Position := 0;
02897 end;
02898
02899 {**
02900 Sets a data from the specified stream into this blob.
02901 @param Value a stream object to be stored into this blob.
02902 }
02903 procedure TZAbstractBlob.SetStream(Value: TStream);
02904 begin
02905 Clear;
02906 if Assigned(Value) then
02907 begin
02908 FBlobSize := Value.Size;
02909 if FBlobSize > 0 then
02910 begin
02911 GetMem(FBlobData, FBlobSize);
02912 Value.Position := 0;
02913 Value.ReadBuffer(FBlobData^, FBlobSize);
02914 end;
02915 end
02916 else
02917 begin
02918 FBlobSize := -1;
02919 FBlobData := nil;
02920 end;
02921 FUpdated := True;
02922 end;
02923
02924 end.