00001 {*********************************************************}
00002 { }
00003 { Zeos Database Objects }
00004 { Caching Classes and Interfaces }
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 ZDbcCache;
00055
00056 interface
00057
00058 {$I ZDbc.inc}
00059
00060
00061 uses
00062 {$IFDEF MSWINDOWS}
00063 Windows,
00064 {$ENDIF}
00065 {$IFNDEF VER130BELOW}
00066 Types,
00067 {$ENDIF}
00068 ZCompatibility, Classes, SysUtils, Contnrs, ZClasses, ZDbcIntfs,
00069 ZDbcResultSet, ZDbcResultSetMetadata, ZVariant;
00070
00071 type
00072
00073 {** Defines a row status type. }
00074 TZRowUpdateType = (utUnmodified, utModified, utInserted, utDeleted);
00075 TZRowUpdateTypes = set of TZRowUpdateType;
00076
00077 {** Defines a header for row buffer. }
00078 TZRowBuffer = packed record
00079 Index: Integer;
00080 UpdateType: TZRowUpdateType;
00081 BookmarkFlag: Byte;
00082 Columns: TByteArray;
00083 end;
00084 PZRowBuffer = ^TZRowBuffer;
00085
00086 {** Implements a column buffer accessor. }
00087 TZRowAccessor = class(TObject)
00088 private
00089 FRowSize: Integer;
00090 FColumnsSize: Integer;
00091 FColumnCount: Integer;
00092 FColumnNames: array of string;
00093 FColumnCases: array of Boolean;
00094 FColumnTypes: array of TZSQLType;
00095 FColumnLengths: array of Integer;
00096 FColumnOffsets: array of Integer;
00097 FBuffer: PZRowBuffer;
00098 FHasBlobs: Boolean;
00099 FTemp: string;
00100
00101 function GetColumnSize(ColumnInfo: TZColumnInfo): Integer;
00102 function GetBlobObject(Buffer: PZRowBuffer; ColumnIndex: Integer): IZBlob;
00103 procedure SetBlobObject(Buffer: PZRowBuffer; ColumnIndex: Integer;
00104 Value: IZBlob);
00105
00106 protected
00107 procedure CheckColumnIndex(ColumnIndex: Integer);
00108 procedure CheckColumnConvertion(ColumnIndex: Integer; ResultType: TZSQLType);
00109
00110 public
00111 constructor Create(ColumnsInfo: TObjectList);
00112 destructor Destroy; override;
00113
00114 function AllocBuffer(var Buffer: PZRowBuffer): PZRowBuffer;
00115 procedure InitBuffer(Buffer: PZRowBuffer);
00116 procedure CopyBuffer(SrcBuffer: PZRowBuffer; DestBuffer: PZRowBuffer);
00117 procedure MoveBuffer(SrcBuffer: PZRowBuffer; DestBuffer: PZRowBuffer);
00118 procedure CloneBuffer(SrcBuffer: PZRowBuffer; DestBuffer: PZRowBuffer);
00119 procedure ClearBuffer(Buffer: PZRowBuffer);
00120 procedure DisposeBuffer(Buffer: PZRowBuffer);
00121
00122 function CompareBuffers(Buffer1, Buffer2: PZRowBuffer;
00123 ColumnIndices: TIntegerDynArray; ColumnDirs: TBooleanDynArray): Integer;
00124
00125 function Alloc: PZRowBuffer;
00126 procedure Init;
00127 procedure CopyTo(DestBuffer: PZRowBuffer);
00128 procedure CopyFrom(SrcBuffer: PZRowBuffer);
00129 procedure MoveTo(DestBuffer: PZRowBuffer);
00130 procedure MoveFrom(SrcBuffer: PZRowBuffer);
00131 procedure CloneTo(DestBuffer: PZRowBuffer);
00132 procedure CloneFrom(SrcBuffer: PZRowBuffer);
00133 procedure Clear;
00134 procedure Dispose;
00135
00136 function GetColumnData(ColumnIndex: Integer; var IsNull: Boolean): Pointer;
00137 function GetColumnDataSize(ColumnIndex: Integer): Integer;
00138
00139 function GetColumnName(ColumnIndex: Integer): string;
00140 function GetColumnCase(ColumnIndex: Integer): Boolean;
00141 function GetColumnType(ColumnIndex: Integer): TZSQLType;
00142 function GetColumnLength(ColumnIndex: Integer): Integer;
00143 function GetColumnOffSet(ColumnIndex: Integer): Integer;
00144
00145
00146
00147
00148
00149 function IsNull(ColumnIndex: Integer): Boolean;
00150 function GetPChar(ColumnIndex: Integer; var IsNull: Boolean): PChar;
00151 function GetString(ColumnIndex: Integer; var IsNull: Boolean): string;
00152 function GetUnicodeString(ColumnIndex: Integer; var IsNull: Boolean): WideString;
00153 function GetBoolean(ColumnIndex: Integer; var IsNull: Boolean): Boolean;
00154 function GetByte(ColumnIndex: Integer; var IsNull: Boolean): ShortInt;
00155 function GetShort(ColumnIndex: Integer; var IsNull: Boolean): SmallInt;
00156 function GetInt(ColumnIndex: Integer; var IsNull: Boolean): Integer;
00157 function GetLong(ColumnIndex: Integer; var IsNull: Boolean): Int64;
00158 function GetFloat(ColumnIndex: Integer; var IsNull: Boolean): Single;
00159 function GetDouble(ColumnIndex: Integer; var IsNull: Boolean): Double;
00160 function GetBigDecimal(ColumnIndex: Integer; var IsNull: Boolean): Extended;
00161 function GetBytes(ColumnIndex: Integer; var IsNull: Boolean): TByteDynArray;
00162 function GetDate(ColumnIndex: Integer; var IsNull: Boolean): TDateTime;
00163 function GetTime(ColumnIndex: Integer; var IsNull: Boolean): TDateTime;
00164 function GetTimestamp(ColumnIndex: Integer; var IsNull: Boolean): TDateTime;
00165 function GetAsciiStream(ColumnIndex: Integer; var IsNull: Boolean): TStream;
00166 function GetUnicodeStream(ColumnIndex: Integer; var IsNull: Boolean): TStream;
00167 function GetBinaryStream(ColumnIndex: Integer; var IsNull: Boolean): TStream;
00168 function GetBlob(ColumnIndex: Integer; var IsNull: Boolean): IZBlob;
00169 function GetValue(ColumnIndex: Integer): TZVariant;
00170
00171
00172
00173
00174
00175 procedure SetNotNull(ColumnIndex: Integer);
00176 procedure SetNull(ColumnIndex: Integer);
00177 procedure SetBoolean(ColumnIndex: Integer; Value: Boolean);
00178 procedure SetByte(ColumnIndex: Integer; Value: ShortInt);
00179 procedure SetShort(ColumnIndex: Integer; Value: SmallInt);
00180 procedure SetInt(ColumnIndex: Integer; Value: Integer);
00181 procedure SetLong(ColumnIndex: Integer; Value: Int64);
00182 procedure SetFloat(ColumnIndex: Integer; Value: Single);
00183 procedure SetDouble(ColumnIndex: Integer; Value: Double);
00184 procedure SetBigDecimal(ColumnIndex: Integer; Value: Extended);
00185 procedure SetPChar(ColumnIndex: Integer; Value: PChar);
00186 procedure SetString(ColumnIndex: Integer; Value: string);
00187 procedure SetUnicodeString(ColumnIndex: Integer; Value: WideString);
00188 procedure SetBytes(ColumnIndex: Integer; Value: TByteDynArray);
00189 procedure SetDate(ColumnIndex: Integer; Value: TDateTime);
00190 procedure SetTime(ColumnIndex: Integer; Value: TDateTime);
00191 procedure SetTimestamp(ColumnIndex: Integer; Value: TDateTime);
00192 procedure SetAsciiStream(ColumnIndex: Integer; Value: TStream);
00193 procedure SetUnicodeStream(ColumnIndex: Integer; Value: TStream);
00194 procedure SetBinaryStream(ColumnIndex: Integer; Value: TStream);
00195 procedure SetBlob(ColumnIndex: Integer; Value: IZBlob);
00196 procedure SetValue(ColumnIndex: Integer; Value: TZVariant);
00197
00198 property ColumnsSize: Integer read FColumnsSize;
00199 property RowSize: Integer read FRowSize;
00200 property RowBuffer: PZRowBuffer read FBuffer write FBuffer;
00201 end;
00202
00203 const
00204 RowHeaderSize = SizeOf(TZRowBuffer) - SizeOf(TByteArray);
00205
00206 implementation
00207
00208 uses Math, ZMessages, ZSysUtils, ZDbcUtils;
00209
00210 { TZRowAccessor }
00211
00212 {**
00213 Creates this object and assignes the main properties.
00214 @param ColumnsInfo a collection with column information.
00215 }
00216 constructor TZRowAccessor.Create(ColumnsInfo: TObjectList);
00217 var
00218 I: Integer;
00219 Current: TZColumnInfo;
00220 begin
00221 FBuffer := nil;
00222 FColumnCount := ColumnsInfo.Count;
00223 FColumnsSize := 0;
00224 SetLength(FColumnNames, FColumnCount);
00225 SetLength(FColumnCases, FColumnCount);
00226 SetLength(FColumnTypes, FColumnCount);
00227 SetLength(FColumnLengths, FColumnCount);
00228 SetLength(FColumnOffsets, FColumnCount);
00229 FHasBlobs := False;
00230
00231 for I := 0 to FColumnCount - 1 do
00232 begin
00233 Current := TZColumnInfo(ColumnsInfo[I]);
00234 FColumnNames[I] := Current.ColumnName;
00235 FColumnCases[I] := Current.CaseSensitive;
00236 FColumnTypes[I] := Current.ColumnType;
00237 FColumnLengths[I] := GetColumnSize(Current);
00238 FColumnOffsets[I] := FColumnsSize;
00239 Inc(FColumnsSize, FColumnLengths[I] + 1);
00240 FHasBlobs := FHasBlobs
00241 or (FColumnTypes[I] in [stAsciiStream, stUnicodeStream, stBinaryStream]);
00242 end;
00243 FRowSize := FColumnsSize + RowHeaderSize;
00244 end;
00245
00246 {**
00247 Destroys this object and cleanups the memory.
00248 }
00249 destructor TZRowAccessor.Destroy;
00250 begin
00251 inherited Destroy;
00252 end;
00253
00254 {**
00255 Checks is the column index correct and row buffer is available.
00256 @param ColumnIndex an index of column.
00257 }
00258 procedure TZRowAccessor.CheckColumnIndex(ColumnIndex: Integer);
00259 begin
00260 if not Assigned(FBuffer) then
00261 raise EZSQLException.Create(SRowBufferIsNotAssigned);
00262
00263 if (ColumnIndex <= 0) or (ColumnIndex > FColumnCount) then
00264 begin
00265 raise EZSQLException.Create(
00266 Format(SColumnIsNotAccessable, [ColumnIndex]));
00267 end;
00268 end;
00269
00270 {**
00271 Checks is the column convertion from one type to another type allowed.
00272 @param ColumnIndex an index of column.
00273 @param ResultType a requested data type.
00274 @return <code>true</code> if convertion is allowed or throw exception
00275 otherwise.
00276 }
00277 procedure TZRowAccessor.CheckColumnConvertion(ColumnIndex: Integer;
00278 ResultType: TZSQLType);
00279 begin
00280 if not Assigned(FBuffer) then
00281 raise EZSQLException.Create(SRowBufferIsNotAssigned);
00282
00283 if (ColumnIndex <= 0) or (ColumnIndex > FColumnCount) then
00284 begin
00285 raise EZSQLException.Create(
00286 Format(SColumnIsNotAccessable, [ColumnIndex]));
00287 end;
00288
00289 if not CheckConvertion(FColumnTypes[ColumnIndex - 1], ResultType) then
00290 begin
00291 raise EZSQLException.Create(
00292 Format(SConvertionIsNotPossible, [ColumnIndex,
00293 DefineColumnTypeName(FColumnTypes[ColumnIndex - 1]),
00294 DefineColumnTypeName(ResultType)]));
00295 end;
00296 end;
00297
00298 {**
00299 Gets a size of column with the specified type.
00300 @param ColumnInfo a column information struct.
00301 @return a size for the column with the specified type.
00302 }
00303 function TZRowAccessor.GetColumnSize(ColumnInfo: TZColumnInfo): Integer;
00304 begin
00305 case ColumnInfo.ColumnType of
00306 stBoolean:
00307 Result := SizeOf(WordBool);
00308 stByte:
00309 Result := SizeOf(Byte);
00310 stShort:
00311 Result := SizeOf(SmallInt);
00312 stInteger:
00313 Result := SizeOf(Integer);
00314 stLong:
00315 Result := SizeOf(Int64);
00316 stFloat:
00317 Result := SizeOf(Single);
00318 stDouble:
00319 Result := SizeOf(Double);
00320 stBigDecimal:
00321 Result := SizeOf(Extended);
00322 stString:
00323 Result := ColumnInfo.Precision + 1;
00324 stUnicodeString:
00325 Result := 2 * ColumnInfo.Precision + 2;
00326 stBytes:
00327 Result := SizeOf(SmallInt) + ColumnInfo.Precision;
00328 stDate, stTime, stTimestamp:
00329 Result := SizeOf(TDateTime);
00330 stAsciiStream, stUnicodeStream, stBinaryStream:
00331 Result := SizeOf(Pointer);
00332 else
00333 Result := 0;
00334 end;
00335 end;
00336
00337 {**
00338 Gets a stream from the specified columns.
00339 @param Buffer a row buffer.
00340 @param ColumnIndex an index of the column.
00341 }
00342 function TZRowAccessor.GetBlobObject(Buffer: PZRowBuffer;
00343 ColumnIndex: Integer): IZBlob;
00344 var
00345 BlobPtr: PPointer;
00346 NullPtr: PByte;
00347 begin
00348 BlobPtr := PPointer(@Buffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1]);
00349 NullPtr := PByte(@Buffer.Columns[FColumnOffsets[ColumnIndex - 1]]);
00350
00351 if NullPtr^ = 0 then
00352 Result := IZBlob(BlobPtr^)
00353 else Result := nil;
00354 end;
00355
00356 {**
00357 Sets a blob into the specified columns.
00358 @param Buffer a row buffer.
00359 @param ColumnIndex an index of the column.
00360 @param Value a stream object to be set.
00361 }
00362 procedure TZRowAccessor.SetBlobObject(Buffer: PZRowBuffer; ColumnIndex: Integer;
00363 Value: IZBlob);
00364 var
00365 BlobPtr: PPointer;
00366 NullPtr: PByte;
00367 begin
00368 BlobPtr := PPointer(@Buffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1]);
00369 NullPtr := PByte(@Buffer.Columns[FColumnOffsets[ColumnIndex - 1]]);
00370
00371 if NullPtr^ = 0 then
00372 IZBlob(BlobPtr^) := nil
00373 else BlobPtr^ := nil;
00374
00375 IZBlob(BlobPtr^) := Value;
00376
00377 if Value <> nil then
00378 NullPtr^ := 0
00379 else NullPtr^ := 1;
00380 end;
00381
00382 {**
00383 Allocates a new row buffer and sets it into the variable.
00384 @param Buffer a pointer to row buffer.
00385 @return a pointer to the allocated buffer.
00386 }
00387 function TZRowAccessor.AllocBuffer(var Buffer: PZRowBuffer): PZRowBuffer;
00388 begin
00389 GetMem(Buffer, FRowSize);
00390 InitBuffer(Buffer);
00391 Result := Buffer;
00392 end;
00393
00394 {**
00395 Disposes the specified row buffer.
00396 @param Buffer a pointer to row buffer.
00397 }
00398 procedure TZRowAccessor.DisposeBuffer(Buffer: PZRowBuffer);
00399 begin
00400 if Assigned(Buffer) then
00401 begin
00402 ClearBuffer(Buffer);
00403 FreeMem(Buffer);
00404 end;
00405 end;
00406
00407 {**
00408 Initializes the row buffer.
00409 @param Buffer a pointer to row buffer.
00410 }
00411 procedure TZRowAccessor.InitBuffer(Buffer: PZRowBuffer);
00412 begin
00413 if Assigned(Buffer) then
00414 with Buffer^ do
00415 begin
00416 Index := 0;
00417 BookmarkFlag := 0;
00418 UpdateType := utUnmodified;
00419 FillChar(Columns, FColumnsSize, 1);
00420 end;
00421 end;
00422
00423 {**
00424 Copies the row buffer from source to destination row.
00425 @param SrcBuffer a pointer to source row buffer.
00426 @param DestBuffer a pointer to destination row buffer.
00427 }
00428 procedure TZRowAccessor.CopyBuffer(SrcBuffer: PZRowBuffer; DestBuffer: PZRowBuffer);
00429 var
00430 I: Integer;
00431 begin
00432 ClearBuffer(DestBuffer);
00433 with DestBuffer^ do
00434 begin
00435 Index := SrcBuffer^.Index;
00436 UpdateType := SrcBuffer^.UpdateType;
00437 BookmarkFlag := SrcBuffer^.BookmarkFlag;
00438 System.Move(SrcBuffer^.Columns, Columns, FColumnsSize);
00439 if FHasBlobs then
00440 for I := 0 to FColumnCount - 1 do
00441 begin
00442 if (FColumnTypes[I] in [stAsciiStream, stUnicodeStream, stBinaryStream])
00443 and (Columns[FColumnOffsets[I]] = 0) then
00444 begin
00445 Columns[FColumnOffsets[I]] := 1;
00446 SetBlobObject(DestBuffer, I + 1, GetBlobObject(SrcBuffer, I + 1));
00447 end;
00448 end;
00449 end;
00450 end;
00451
00452 {**
00453 Moves the row buffer from source to destination row.
00454 Source buffer is cleaned up after the operation.
00455 @param SrcBuffer a pointer to source row buffer.
00456 @param DestBuffer a pointer to destination row buffer.
00457 }
00458 procedure TZRowAccessor.MoveBuffer(SrcBuffer: PZRowBuffer;
00459 DestBuffer: PZRowBuffer);
00460 begin
00461 CopyBuffer(SrcBuffer, DestBuffer);
00462 ClearBuffer(SrcBuffer);
00463 end;
00464
00465 {**
00466 Clones the row buffer from source to destination row.
00467 @param SrcBuffer a pointer to source row buffer.
00468 @param DestBuffer a pointer to destination row buffer.
00469 }
00470 procedure TZRowAccessor.CloneBuffer(SrcBuffer: PZRowBuffer;
00471 DestBuffer: PZRowBuffer);
00472 var
00473 I: Integer;
00474 Blob: IZBlob;
00475 begin
00476 ClearBuffer(DestBuffer);
00477 with DestBuffer^ do
00478 begin
00479 Index := SrcBuffer^.Index;
00480 UpdateType := SrcBuffer^.UpdateType;
00481 BookmarkFlag := SrcBuffer^.BookmarkFlag;
00482 System.Move(SrcBuffer^.Columns, Columns, FColumnsSize);
00483 if FHasBlobs then
00484 for I := 0 to FColumnCount - 1 do
00485 begin
00486 if (FColumnTypes[I] in [stAsciiStream, stUnicodeStream, stBinaryStream])
00487 and (Columns[FColumnOffsets[I]] = 0) then
00488 begin
00489 Columns[FColumnOffsets[I]] := 1;
00490 Blob := GetBlobObject(SrcBuffer, I + 1);
00491 if Blob <> nil then
00492 Blob := Blob.Clone;
00493 SetBlobObject(DestBuffer, I + 1, Blob);
00494 end;
00495 end;
00496 end;
00497 end;
00498
00499 {**
00500 Compares fields from two row buffers.
00501 @param Buffer1 the first row buffer to compare.
00502 @param Buffer2 the second row buffer to compare.
00503 @param ColumnIndices column indices to compare.
00504 @param ColumnDirs compare direction for each columns.
00505 }
00506 function TZRowAccessor.CompareBuffers(Buffer1, Buffer2: PZRowBuffer;
00507 ColumnIndices: TIntegerDynArray; ColumnDirs: TBooleanDynArray): Integer;
00508 var
00509 I: Integer;
00510 ColumnIndex: Integer;
00511 Length1, Length2: SmallInt;
00512 ValuePtr1, ValuePtr2: Pointer;
00513 Blob1, Blob2: IZBlob;
00514 BlobEmpty1, BlobEmpty2: Boolean;
00515
00516 function CompareFloat(Value1, Value2: Extended): Integer;
00517 begin
00518 Value1 := Value1 - Value2;
00519 if Value1 > 0 then
00520 Result := 1
00521 else if Value1 < 0 then
00522 Result := -1
00523 else Result := 0;
00524 end;
00525
00526 function CompareBool(Value1, Value2: Boolean): Integer;
00527 begin
00528 if Value1 = Value2 then
00529 Result := 0
00530 else if Value1 = True then
00531 Result := 1
00532 else Result := -1;
00533 end;
00534
00535 function CompareInt64(Value1, Value2: Int64): Integer;
00536 begin
00537 Value1 := Value1 - Value2;
00538 if Value1 > 0 then
00539 Result := 1
00540 else if Value1 < 0 then
00541 Result := -1
00542 else Result := 0;
00543 end;
00544
00545 begin
00546 Result := 0;
00547 for I := Low(ColumnIndices) to High(ColumnIndices) do
00548 begin
00549 ColumnIndex := ColumnIndices[I] - 1;
00550 { Checks for both Null columns. }
00551 if (Buffer1.Columns[FColumnOffsets[ColumnIndex]] = 1) and
00552 (Buffer2.Columns[FColumnOffsets[ColumnIndex]] = 1) then
00553 Continue;
00554 { Checks for not-Null and Null columns. }
00555 if Buffer1.Columns[FColumnOffsets[ColumnIndex]] <>
00556 Buffer2.Columns[FColumnOffsets[ColumnIndex]] then
00557 begin
00558 if not (FColumnTypes[ColumnIndex]
00559 in [stAsciiStream, stUnicodeStream, stBinaryStream]) then
00560 begin
00561 Result := Buffer2.Columns[FColumnOffsets[ColumnIndex]] -
00562 Buffer1.Columns[FColumnOffsets[ColumnIndex]];
00563 if not ColumnDirs[I] then
00564 Result := -Result;
00565 Break;
00566 end;
00567 end;
00568 { Compares column values. }
00569 ValuePtr1 := @Buffer1.Columns[FColumnOffsets[ColumnIndex] + 1];
00570 ValuePtr2 := @Buffer2.Columns[FColumnOffsets[ColumnIndex] + 1];
00571 case FColumnTypes[ColumnIndex] of
00572 stByte:
00573 Result := PShortInt(ValuePtr1)^ - PShortInt(ValuePtr2)^;
00574 stShort:
00575 Result := PSmallInt(ValuePtr1)^ - PSmallInt(ValuePtr2)^;
00576 stInteger:
00577 Result := PInteger(ValuePtr1)^ - PInteger(ValuePtr2)^;
00578 stLong:
00579 Result := CompareInt64(PInt64(ValuePtr1)^, PInt64(ValuePtr2)^);
00580 stFloat:
00581 Result := CompareFloat(PSingle(ValuePtr1)^, PSingle(ValuePtr2)^);
00582 stDouble:
00583 Result := CompareFloat(PDouble(ValuePtr1)^, PDouble(ValuePtr2)^);
00584 stBigDecimal:
00585 Result := CompareFloat(PExtended(ValuePtr1)^, PExtended(ValuePtr2)^);
00586 stBoolean:
00587 Result := CompareBool(PWordBool(ValuePtr1)^, PWordBool(ValuePtr2)^);
00588 stDate, stTime, stTimestamp:
00589 Result := CompareFloat(PDateTime(ValuePtr1)^, PDateTime(ValuePtr2)^);
00590 stString:
00591 Result := AnsiStrComp(PChar(ValuePtr1), PChar(ValuePtr2));
00592 stUnicodeString:
00593 {$IFNDEF VER130BELOW}
00594 Result := WideCompareStr(PWideChar(ValuePtr1), PWideChar(ValuePtr2));
00595 {$ELSE}
00596 Result := AnsiCompareStr(PWideChar(ValuePtr1), PWideChar(ValuePtr2));
00597 {$ENDIF}
00598 stBytes:
00599 begin
00600 Length1 := PSmallInt(ValuePtr1)^;
00601 Length2 := PSmallInt(ValuePtr2)^;
00602 ValuePtr1 := @Buffer1.Columns[FColumnOffsets[ColumnIndex]
00603 + 1 + SizeOf(SmallInt)];
00604 ValuePtr2 := @Buffer2.Columns[FColumnOffsets[ColumnIndex]
00605 + 1 + SizeOf(SmallInt)];
00606 Result := CompareStr(BufferToStr(ValuePtr1, Length1),
00607 BufferToStr(ValuePtr2, Length2));
00608 end;
00609 stAsciiStream, stBinaryStream, stUnicodeStream:
00610 begin
00611 Blob1 := GetBlobObject(Buffer1, ColumnIndex + 1);
00612 BlobEmpty1 := (Blob1 = nil) or (Blob1.IsEmpty);
00613 Blob2 := GetBlobObject(Buffer2, ColumnIndex + 1);
00614 BlobEmpty2 := (Blob2 = nil) or (Blob2.IsEmpty);
00615 if (BlobEmpty1 = True) and (BlobEmpty2 = True) then
00616 Continue
00617 else if (BlobEmpty1 <> BlobEmpty2) then
00618 begin
00619 if BlobEmpty1 then
00620 Result := -1
00621 else Result := 1;
00622 end
00623 else if FColumnTypes[ColumnIndex] = stAsciiStream then
00624 Result := AnsiCompareStr(Blob1.GetString, Blob2.GetString)
00625 else if FColumnTypes[ColumnIndex] = stBinaryStream then
00626 Result := CompareStr(Blob1.GetString, Blob2.GetString)
00627 else if FColumnTypes[ColumnIndex] = stUnicodeStream then
00628 {$IFNDEF VER130BELOW}
00629 Result := WideCompareStr(Blob1.GetUnicodeString, Blob2.GetUnicodeString);
00630 {$ELSE}
00631 Result := AnsiCompareStr(Blob1.GetString, Blob2.GetString);
00632 {$ENDIF}
00633 end;
00634 end;
00635 if Result <> 0 then
00636 begin
00637 if not ColumnDirs[I] then
00638 Result := -Result;
00639 Break;
00640 end;
00641 end;
00642 end;
00643
00644 {**
00645 Cleans the specified row buffer.
00646 @param Buffer a pointer to row buffer.
00647 }
00648 procedure TZRowAccessor.ClearBuffer(Buffer: PZRowBuffer);
00649 var
00650 I: Integer;
00651 begin
00652 with Buffer^ do
00653 begin
00654 Index := -1;
00655 UpdateType := utUnmodified;
00656 BookmarkFlag := 0;
00657 if FHasBlobs then
00658 for I := 0 to FColumnCount - 1 do
00659 begin
00660 if (FColumnTypes[I] in [stAsciiStream, stUnicodeStream, stBinaryStream])
00661 and (Columns[FColumnOffsets[I]] = 0) then
00662 SetBlobObject(Buffer, I + 1, nil);
00663 end;
00664 FillChar(Columns, FColumnsSize, 1);
00665 end;
00666 end;
00667
00668 {**
00669 Allocates a new row buffer.
00670 @return a pointer to the allocated buffer.
00671 }
00672 function TZRowAccessor.Alloc: PZRowBuffer;
00673 begin
00674 Result := AllocBuffer(FBuffer);
00675 end;
00676
00677 {**
00678 Disposes an associated row buffer.
00679 }
00680 procedure TZRowAccessor.Dispose;
00681 begin
00682 DisposeBuffer(FBuffer);
00683 FBuffer := nil;
00684 end;
00685
00686 {**
00687 Initializes the associated row buffer.
00688 }
00689 procedure TZRowAccessor.Init;
00690 begin
00691 InitBuffer(FBuffer);
00692 end;
00693
00694 {**
00695 Copies the associated row buffer into a specified one.
00696 @param DestBuffer a destination row buffer.
00697 }
00698 procedure TZRowAccessor.CopyTo(DestBuffer: PZRowBuffer);
00699 begin
00700 CopyBuffer(FBuffer, DestBuffer);
00701 end;
00702
00703 {**
00704 Copies the associated row buffer from a specified one.
00705 @param SrcBuffer a source row buffer.
00706 }
00707 procedure TZRowAccessor.CopyFrom(SrcBuffer: PZRowBuffer);
00708 begin
00709 CopyBuffer(SrcBuffer, FBuffer);
00710 end;
00711
00712 {**
00713 Moves the associated row buffer into a specified one.
00714 @param DestBuffer a destination row buffer.
00715 }
00716 procedure TZRowAccessor.MoveTo(DestBuffer: PZRowBuffer);
00717 begin
00718 MoveBuffer(FBuffer, DestBuffer);
00719 end;
00720
00721 {**
00722 Moves the associated row buffer from a specified one.
00723 @param SrcBuffer a source row buffer.
00724 }
00725 procedure TZRowAccessor.MoveFrom(SrcBuffer: PZRowBuffer);
00726 begin
00727 MoveBuffer(SrcBuffer, FBuffer);
00728 end;
00729
00730 {**
00731 Clones the associated row buffer into a specified one.
00732 @param DestBuffer a destination row buffer.
00733 }
00734 procedure TZRowAccessor.CloneTo(DestBuffer: PZRowBuffer);
00735 begin
00736 CloneBuffer(FBuffer, DestBuffer);
00737 end;
00738
00739 {**
00740 Clones the associated row buffer from a specified one.
00741 @param SrcBuffer a source row buffer.
00742 }
00743 procedure TZRowAccessor.CloneFrom(SrcBuffer: PZRowBuffer);
00744 begin
00745 CloneBuffer(SrcBuffer, FBuffer);
00746 end;
00747
00748 {**
00749 Cleans the associated row buffer.
00750 }
00751 procedure TZRowAccessor.Clear;
00752 begin
00753 ClearBuffer(FBuffer);
00754 end;
00755
00756 {**
00757 Gets the case sensitive flag of a column data buffer.
00758
00759 @param ColumnIndex the first column is 1, the second is 2, ...
00760 @return the case sensitive flag of the column data buffer.
00761 }
00762 function TZRowAccessor.GetColumnCase(ColumnIndex: Integer): Boolean;
00763 begin
00764 CheckColumnIndex(ColumnIndex);
00765 Result := FColumnCases[ColumnIndex-1];
00766 end;
00767
00768 {**
00769 Gets a pointer to the column data buffer.
00770
00771 @param ColumnIndex the first column is 1, the second is 2, ...
00772 @return a pointer to the column data buffer.
00773 }
00774 function TZRowAccessor.GetColumnData(ColumnIndex: Integer;
00775 var IsNull: Boolean): Pointer;
00776 begin
00777 CheckColumnConvertion(ColumnIndex, stString);
00778 Result := @FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1];
00779 IsNull := FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 1;
00780 end;
00781
00782 {**
00783 Gets a size of the column data buffer.
00784
00785 @param ColumnIndex the first column is 1, the second is 2, ...
00786 @return a size of the column data buffer.
00787 }
00788 function TZRowAccessor.GetColumnDataSize(ColumnIndex: Integer): Integer;
00789 begin
00790 CheckColumnConvertion(ColumnIndex, stString);
00791 Result := FColumnLengths[ColumnIndex - 1];
00792 end;
00793
00794 {**
00795 Gets then length of a column data buffer.
00796
00797 @param ColumnIndex the first column is 1, the second is 2, ...
00798 @return the length of the column data buffer.
00799 }
00800 function TZRowAccessor.GetColumnLength(ColumnIndex: Integer): Integer;
00801 begin
00802 CheckColumnIndex(ColumnIndex);
00803 Result := FColumnLengths[ColumnIndex-1];
00804 end;
00805
00806 {**
00807 Gets then name of a column data buffer.
00808
00809 @param ColumnIndex the first column is 1, the second is 2, ...
00810 @return the name of the column data buffer.
00811 }
00812 function TZRowAccessor.GetColumnName(ColumnIndex: Integer): string;
00813 begin
00814 CheckColumnIndex(ColumnIndex);
00815 Result := FColumnNames[ColumnIndex-1];
00816 end;
00817
00818 {**
00819 Gets then offset of a column data buffer.
00820
00821 @param ColumnIndex the first column is 1, the second is 2, ...
00822 @return then offset of the column data buffer.
00823 }
00824 function TZRowAccessor.GetColumnOffSet(ColumnIndex: Integer): Integer;
00825 begin
00826 CheckColumnIndex(ColumnIndex);
00827 Result := FColumnOffSets[ColumnIndex-1];
00828 end;
00829
00830 {**
00831 Gets then SQLType of a column data buffer.
00832
00833 @param ColumnIndex the first column is 1, the second is 2, ...
00834 @return the SQLType of the column data buffer.
00835 }
00836 function TZRowAccessor.GetColumnType(ColumnIndex: Integer): TZSQLType;
00837 begin
00838 CheckColumnIndex(ColumnIndex);
00839 Result := FColumnTypes[ColumnIndex-1];
00840 end;
00841
00842
00843
00844
00845
00846
00847 {**
00848 Indicates if the value of the designated column in the current row
00849 of this <code>ResultSet</code> object is Null.
00850
00851 @param ColumnIndex the first column is 1, the second is 2, ...
00852 @return if the value is SQL <code>NULL</code>, the
00853 value returned is <code>true</code>. <code>false</code> otherwise.
00854 }
00855 function TZRowAccessor.IsNull(ColumnIndex: Integer): Boolean;
00856 var
00857 TempBlob: IZBlob;
00858 begin
00859 CheckColumnConvertion(ColumnIndex, stString);
00860 Result := FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 1;
00861 if not Result and (FColumnTypes[ColumnIndex - 1] in [stAsciiStream,
00862 stBinaryStream, stUnicodeStream]) then
00863 begin
00864 TempBlob := GetBlobObject(FBuffer, ColumnIndex);
00865 Result := (TempBlob = nil) or TempBlob.IsEmpty;
00866 end;
00867 end;
00868
00869 {**
00870 Gets the value of the designated column in the current row
00871 of this <code>ResultSet</code> object as
00872 a <code>PChar</code> in the Delphi programming language.
00873
00874 @param columnIndex the first column is 1, the second is 2, ...
00875 @return the column value; if the value is SQL <code>NULL</code>, the
00876 value returned is <code>null</code>
00877 }
00878 function TZRowAccessor.GetPChar(ColumnIndex: Integer;
00879 var IsNull: Boolean): PChar;
00880 begin
00881 {$IFNDEF DISABLE_CHECKING}
00882 CheckColumnConvertion(ColumnIndex, stString);
00883 {$ENDIF}
00884 Result := nil;
00885 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
00886 begin
00887 case FColumnTypes[ColumnIndex - 1] of
00888 stString:
00889 Result := @FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1];
00890 else
00891 begin
00892 FTemp := GetString(ColumnIndex, IsNull);
00893 Result := PChar(FTemp);
00894 end;
00895 end;
00896 IsNull := False;
00897 end else
00898 IsNull := True;
00899 end;
00900
00901 {**
00902 Gets the value of the designated column in the current row
00903 of this <code>ResultSet</code> object as
00904 a <code>String</code> in the Java programming language.
00905
00906 @param columnIndex the first column is 1, the second is 2, ...
00907 @return the column value; if the value is SQL <code>NULL</code>, the
00908 value returned is <code>null</code>
00909 }
00910 function TZRowAccessor.GetString(ColumnIndex: Integer;
00911 var IsNull: Boolean): string;
00912 var
00913 TempBytes: TByteDynArray;
00914 TempBlob: IZBlob;
00915 begin
00916 {$IFNDEF DISABLE_CHECKING}
00917 CheckColumnConvertion(ColumnIndex, stString);
00918 {$ENDIF}
00919 Result := '';
00920 TempBytes := nil;
00921 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
00922 begin
00923 case FColumnTypes[ColumnIndex - 1] of
00924 stBoolean:
00925 if GetBoolean(ColumnIndex, IsNull) then
00926 Result := 'True'
00927 else Result := 'False';
00928 stByte: Result := IntToStr(GetByte(ColumnIndex, IsNull));
00929 stShort: Result := IntToStr(GetShort(ColumnIndex, IsNull));
00930 stInteger: Result := IntToStr(GetInt(ColumnIndex, IsNull));
00931 stLong: Result := IntToStr(GetLong(ColumnIndex, IsNull));
00932 stFloat: Result := FloatToSQLStr(GetFloat(ColumnIndex, IsNull));
00933 stDouble: Result := FloatToSQLStr(GetDouble(ColumnIndex, IsNull));
00934 stBigDecimal: Result := FloatToSQLStr(GetBigDecimal(ColumnIndex, IsNull));
00935 stString:
00936 Result := PChar(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1]);
00937 stUnicodeString, stUnicodeStream: Result := GetUnicodeString(ColumnIndex, IsNull);
00938 stBytes: Result := BytesToStr(GetBytes(ColumnIndex, IsNull));
00939 stDate: Result := FormatDateTime('yyyy-mm-dd', GetDate(ColumnIndex, IsNull));
00940 stTime: Result := FormatDateTime('hh:mm:ss', GetTime(ColumnIndex, IsNull));
00941 stTimestamp:
00942 Result := FormatDateTime('yyyy-mm-dd hh:mm:ss',
00943 GetTimestamp(ColumnIndex, IsNull));
00944 stAsciiStream, stBinaryStream:
00945 begin
00946 TempBlob := GetBlobObject(FBuffer, ColumnIndex);
00947 if (TempBlob <> nil) and not TempBlob.IsEmpty then
00948 Result := TempBlob.GetString;
00949 end;
00950 end;
00951 IsNull := False;
00952 end else
00953 IsNull := True;
00954 end;
00955
00956 {**
00957 Gets the value of the designated column in the current row
00958 of this <code>ResultSet</code> object as
00959 a <code>WideString</code> in the ObjectPascal programming language.
00960
00961 @param columnIndex the first column is 1, the second is 2, ...
00962 @return the column value; if the value is SQL <code>NULL</code>, the
00963 value returned is <code>null</code>
00964 }
00965 function TZRowAccessor.GetUnicodeString(ColumnIndex: Integer;
00966 var IsNull: Boolean): WideString;
00967 var
00968 TempBlob: IZBlob;
00969 begin
00970 {$IFNDEF DISABLE_CHECKING}
00971 CheckColumnConvertion(ColumnIndex, stUnicodeString);
00972 {$ENDIF}
00973 Result := '';
00974 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
00975 begin
00976 case FColumnTypes[ColumnIndex - 1] of
00977 stUnicodeString:
00978 Result := PWideChar(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1]);
00979 stUnicodeStream:
00980 begin
00981 TempBlob := GetBlobObject(FBuffer, ColumnIndex);
00982 if (TempBlob <> nil) and not TempBlob.IsEmpty then
00983 Result := TempBlob.GetUnicodeString;
00984 end;
00985 else
00986 Result := GetString(ColumnIndex, IsNull);
00987 end;
00988 IsNull := False;
00989 end else
00990 IsNull := True;
00991 end;
00992
00993 {**
00994 Gets the value of the designated column in the current row
00995 of this <code>ResultSet</code> object as
00996 a <code>boolean</code> in the Java programming language.
00997
00998 @param columnIndex the first column is 1, the second is 2, ...
00999 @return the column value; if the value is SQL <code>NULL</code>, the
01000 value returned is <code>false</code>
01001 }
01002 function TZRowAccessor.GetBoolean(ColumnIndex: Integer;
01003 var IsNull: Boolean): Boolean;
01004 var
01005 TempStr: string;
01006 begin
01007 {$IFNDEF DISABLE_CHECKING}
01008 CheckColumnConvertion(ColumnIndex, stBoolean);
01009 {$ENDIF}
01010 Result := False;
01011 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
01012 begin
01013 case FColumnTypes[ColumnIndex - 1] of
01014 stBoolean:
01015 Result := PWordBool(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^;
01016 stByte: Result := GetByte(ColumnIndex, IsNull) <> 0;
01017 stShort: Result := GetShort(ColumnIndex, IsNull) <> 0;
01018 stInteger: Result := GetInt(ColumnIndex, IsNull) <> 0;
01019 stLong: Result := GetLong(ColumnIndex, IsNull) <> 0;
01020 stFloat: Result := GetFloat(ColumnIndex, IsNull) <> 0;
01021 stDouble: Result := GetDouble(ColumnIndex, IsNull) <> 0;
01022 stBigDecimal: Result := GetBigDecimal(ColumnIndex, IsNull) <> 0;
01023 stString, stUnicodeString:
01024 begin
01025 TempStr := UpperCase(GetString(ColumnIndex, IsNull));
01026 Result := (TempStr = 'T') or (TempStr = 'Y') or (TempStr = 'TRUE')
01027 or (TempStr = 'YES');
01028 end;
01029 end;
01030 IsNull := False;
01031 end else
01032 IsNull := True;
01033 end;
01034
01035 {**
01036 Gets the value of the designated column in the current row
01037 of this <code>ResultSet</code> object as
01038 a <code>byte</code> in the Java programming language.
01039
01040 @param columnIndex the first column is 1, the second is 2, ...
01041 @return the column value; if the value is SQL <code>NULL</code>, the
01042 value returned is <code>0</code>
01043 }
01044 function TZRowAccessor.GetByte(ColumnIndex: Integer;
01045 var IsNull: Boolean): ShortInt;
01046 begin
01047 {$IFNDEF DISABLE_CHECKING}
01048 CheckColumnConvertion(ColumnIndex, stByte);
01049 {$ENDIF}
01050 Result := 0;
01051 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
01052 begin
01053 case FColumnTypes[ColumnIndex - 1] of
01054 stBoolean:
01055 if GetBoolean(ColumnIndex, IsNull) then
01056 Result := 1
01057 else Result := 0;
01058 stByte:
01059 Result := PShortInt(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^;
01060 stShort: Result := GetShort(ColumnIndex, IsNull);
01061 stInteger: Result := GetInt(ColumnIndex, IsNull);
01062 stLong: Result := GetLong(ColumnIndex, IsNull);
01063 stFloat: Result := Trunc(GetFloat(ColumnIndex, IsNull));
01064 stDouble: Result := Trunc(GetDouble(ColumnIndex, IsNull));
01065 stBigDecimal: Result := Trunc(GetBigDecimal(ColumnIndex, IsNull));
01066 stString, stUnicodeString:
01067 Result := StrToIntDef(GetString(ColumnIndex, IsNull), 0);
01068 end;
01069 IsNull := False;
01070 end else
01071 IsNull := True;
01072 end;
01073
01074 {**
01075 Gets the value of the designated column in the current row
01076 of this <code>ResultSet</code> object as
01077 a <code>short</code> in the Java programming language.
01078
01079 @param columnIndex the first column is 1, the second is 2, ...
01080 @return the column value; if the value is SQL <code>NULL</code>, the
01081 value returned is <code>0</code>
01082 }
01083 function TZRowAccessor.GetShort(ColumnIndex: Integer;
01084 var IsNull: Boolean): SmallInt;
01085 begin
01086 {$IFNDEF DISABLE_CHECKING}
01087 CheckColumnConvertion(ColumnIndex, stShort);
01088 {$ENDIF}
01089 Result := 0;
01090 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
01091 begin
01092 case FColumnTypes[ColumnIndex - 1] of
01093 stBoolean:
01094 if GetBoolean(ColumnIndex, IsNull) then
01095 Result := 1
01096 else Result := 0;
01097 stByte: Result := GetByte(ColumnIndex, IsNull);
01098 stShort:
01099 Result := PSmallInt(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^;
01100 stInteger: Result := GetInt(ColumnIndex, IsNull);
01101 stLong: Result := GetLong(ColumnIndex, IsNull);
01102 stFloat: Result := Trunc(GetFloat(ColumnIndex, IsNull));
01103 stDouble: Result := Trunc(GetDouble(ColumnIndex, IsNull));
01104 stBigDecimal: Result := Trunc(GetBigDecimal(ColumnIndex, IsNull));
01105 stString, stUnicodeString:
01106 Result := StrToIntDef(GetString(ColumnIndex, IsNull), 0);
01107 end;
01108 IsNull := False;
01109 end else
01110 IsNull := True;
01111 end;
01112
01113 {**
01114 Gets the value of the designated column in the current row
01115 of this <code>ResultSet</code> object as
01116 an <code>int</code> in the Java programming language.
01117
01118 @param columnIndex the first column is 1, the second is 2, ...
01119 @return the column value; if the value is SQL <code>NULL</code>, the
01120 value returned is <code>0</code>
01121 }
01122 function TZRowAccessor.GetInt(ColumnIndex: Integer;
01123 var IsNull: Boolean): Integer;
01124 begin
01125 {$IFNDEF DISABLE_CHECKING}
01126 CheckColumnConvertion(ColumnIndex, stInteger);
01127 {$ENDIF}
01128 Result := 0;
01129 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
01130 begin
01131 case FColumnTypes[ColumnIndex - 1] of
01132 stBoolean:
01133 if GetBoolean(ColumnIndex, IsNull) then
01134 Result := 1
01135 else Result := 0;
01136 stByte: Result := GetByte(ColumnIndex, IsNull);
01137 stShort: Result := GetShort(ColumnIndex, IsNull);
01138 stInteger:
01139 Result := PInteger(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^;
01140 stLong: Result := GetLong(ColumnIndex, IsNull);
01141 stFloat: Result := Trunc(GetFloat(ColumnIndex, IsNull));
01142 stDouble: Result := Trunc(GetDouble(ColumnIndex, IsNull));
01143 stBigDecimal: Result := Trunc(GetBigDecimal(ColumnIndex, IsNull));
01144 stString, stUnicodeString:
01145 Result := StrToIntDef(GetString(ColumnIndex, IsNull), 0);
01146 end;
01147 IsNull := False;
01148 end else
01149 IsNull := True;
01150 end;
01151
01152 {**
01153 Gets the value of the designated column in the current row
01154 of this <code>ResultSet</code> object as
01155 a <code>long</code> in the Java programming language.
01156
01157 @param columnIndex the first column is 1, the second is 2, ...
01158 @return the column value; if the value is SQL <code>NULL</code>, the
01159 value returned is <code>0</code>
01160 }
01161 function TZRowAccessor.GetLong(ColumnIndex: Integer;
01162 var IsNull: Boolean): Int64;
01163 begin
01164 {$IFNDEF DISABLE_CHECKING}
01165 CheckColumnConvertion(ColumnIndex, stLong);
01166 {$ENDIF}
01167 Result := 0;
01168 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
01169 begin
01170 case FColumnTypes[ColumnIndex - 1] of
01171 stBoolean:
01172 if GetBoolean(ColumnIndex, IsNull) then
01173 Result := 1
01174 else Result := 0;
01175 stByte: Result := GetByte(ColumnIndex, IsNull);
01176 stShort: Result := GetShort(ColumnIndex, IsNull);
01177 stInteger: Result := GetInt(ColumnIndex, IsNull);
01178 stLong:
01179 Result := PInt64(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^;
01180 stFloat: Result := Trunc(GetFloat(ColumnIndex, IsNull));
01181 stDouble: Result := Trunc(GetDouble(ColumnIndex, IsNull));
01182 stBigDecimal: Result := Trunc(GetBigDecimal(ColumnIndex, IsNull));
01183 stString, stUnicodeString:
01184 Result := StrToIntDef(GetString(ColumnIndex, IsNull), 0);
01185 end;
01186 IsNull := False;
01187 end else
01188 IsNull := True;
01189 end;
01190
01191 {**
01192 Gets the value of the designated column in the current row
01193 of this <code>ResultSet</code> object as
01194 a <code>float</code> in the Java programming language.
01195
01196 @param columnIndex the first column is 1, the second is 2, ...
01197 @return the column value; if the value is SQL <code>NULL</code>, the
01198 value returned is <code>0</code>
01199 }
01200 function TZRowAccessor.GetFloat(ColumnIndex: Integer;
01201 var IsNull: Boolean): Single;
01202 begin
01203 {$IFNDEF DISABLE_CHECKING}
01204 CheckColumnConvertion(ColumnIndex, stFloat);
01205 {$ENDIF}
01206 Result := 0;
01207 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
01208 begin
01209 case FColumnTypes[ColumnIndex - 1] of
01210 stBoolean:
01211 if GetBoolean(ColumnIndex, IsNull) then
01212 Result := 1
01213 else Result := 0;
01214 stByte: Result := GetByte(ColumnIndex, IsNull);
01215 stShort: Result := GetShort(ColumnIndex, IsNull);
01216 stInteger: Result := GetInt(ColumnIndex, IsNull);
01217 stLong: Result := GetLong(ColumnIndex, IsNull);
01218 stFloat:
01219 Result := PSingle(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^;
01220 stDouble: Result := GetDouble(ColumnIndex, IsNull);
01221 stBigDecimal: Result := GetBigDecimal(ColumnIndex, IsNull);
01222 stString, stUnicodeString:
01223 Result := SQLStrToFloatDef(GetString(ColumnIndex, IsNull), 0);
01224 end;
01225 IsNull := False;
01226 end else
01227 IsNull := True;
01228 end;
01229
01230 {**
01231 Gets the value of the designated column in the current row
01232 of this <code>ResultSet</code> object as
01233 a <code>double</code> in the Java programming language.
01234
01235 @param columnIndex the first column is 1, the second is 2, ...
01236 @return the column value; if the value is SQL <code>NULL</code>, the
01237 value returned is <code>0</code>
01238 }
01239 function TZRowAccessor.GetDouble(ColumnIndex: Integer;
01240 var IsNull: Boolean): Double;
01241 begin
01242 {$IFNDEF DISABLE_CHECKING}
01243 CheckColumnConvertion(ColumnIndex, stDouble);
01244 {$ENDIF}
01245 Result := 0;
01246 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
01247 begin
01248 case FColumnTypes[ColumnIndex - 1] of
01249 stBoolean:
01250 if GetBoolean(ColumnIndex, IsNull) then
01251 Result := 1
01252 else Result := 0;
01253 stByte: Result := GetByte(ColumnIndex, IsNull);
01254 stShort: Result := GetShort(ColumnIndex, IsNull);
01255 stInteger: Result := GetInt(ColumnIndex, IsNull);
01256 stLong: Result := GetLong(ColumnIndex, IsNull);
01257 stFloat: Result := GetFloat(ColumnIndex, IsNull);
01258 stDouble:
01259 Result := PDouble(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^;
01260 stBigDecimal: Result := GetBigDecimal(ColumnIndex, IsNull);
01261 stString, stUnicodeString:
01262 Result := SQLStrToFloatDef(GetString(ColumnIndex, IsNull), 0);
01263 end;
01264 IsNull := False;
01265 end else
01266 IsNull := True;
01267 end;
01268
01269 {**
01270 Gets the value of the designated column in the current row
01271 of this <code>ResultSet</code> object as
01272 a <code>java.sql.BigDecimal</code> in the Java programming language.
01273
01274 @param columnIndex the first column is 1, the second is 2, ...
01275 @param scale the number of digits to the right of the decimal point
01276 @return the column value; if the value is SQL <code>NULL</code>, the
01277 value returned is <code>null</code>
01278 }
01279 function TZRowAccessor.GetBigDecimal(ColumnIndex: Integer;
01280 var IsNull: Boolean): Extended;
01281 begin
01282 {$IFNDEF DISABLE_CHECKING}
01283 CheckColumnConvertion(ColumnIndex, stBigDecimal);
01284 {$ENDIF}
01285 Result := 0;
01286 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
01287 begin
01288 case FColumnTypes[ColumnIndex - 1] of
01289 stBoolean:
01290 if GetBoolean(ColumnIndex, IsNull) then
01291 Result := 1
01292 else Result := 0;
01293 stByte: Result := GetByte(ColumnIndex, IsNull);
01294 stShort: Result := GetShort(ColumnIndex, IsNull);
01295 stInteger: Result := GetInt(ColumnIndex, IsNull);
01296 stLong: Result := GetLong(ColumnIndex, IsNull);
01297 stFloat: Result := GetFloat(ColumnIndex, IsNull);
01298 stDouble: Result := GetDouble(ColumnIndex, IsNull);
01299 stBigDecimal:
01300 Result := PExtended(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^;
01301 stString, stUnicodeString:
01302 Result := SQLStrToFloatDef(GetString(ColumnIndex, IsNull), 0);
01303 end;
01304 IsNull := False;
01305 end else
01306 IsNull := True;
01307 end;
01308
01309 {**
01310 Gets the value of the designated column in the current row
01311 of this <code>ResultSet</code> object as
01312 a <code>byte</code> array in the Java programming language.
01313 The bytes represent the raw values returned by the driver.
01314
01315 @param columnIndex the first column is 1, the second is 2, ...
01316 @return the column value; if the value is SQL <code>NULL</code>, the
01317 value returned is <code>null</code>
01318 }
01319 function TZRowAccessor.GetBytes(ColumnIndex: Integer;
01320 var IsNull: Boolean): TByteDynArray;
01321 var
01322 I: Integer;
01323 TempShort: SmallInt;
01324 begin
01325 {$IFNDEF DISABLE_CHECKING}
01326 CheckColumnConvertion(ColumnIndex, stBytes);
01327 {$ENDIF}
01328 Result := nil;
01329 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
01330 begin
01331 case FColumnTypes[ColumnIndex - 1] of
01332 stBytes:
01333 begin
01334 TempShort := PSmallInt(@FBuffer.Columns[
01335 FColumnOffsets[ColumnIndex - 1] + 1])^;
01336 SetLength(Result, TempShort);
01337 for I := 0 to TempShort - 1 do
01338 begin
01339 Result[I] := FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]
01340 + 1 + SizeOf(SmallInt) + I];
01341 end;
01342 end;
01343 else
01344 Result := StrToBytes(GetString(ColumnIndex, IsNull));
01345 end;
01346 IsNull := False;
01347 end else
01348 IsNull := True;
01349 end;
01350
01351 {**
01352 Gets the value of the designated column in the current row
01353 of this <code>ResultSet</code> object as
01354 a <code>java.sql.Date</code> object in the Java programming language.
01355
01356 @param columnIndex the first column is 1, the second is 2, ...
01357 @return the column value; if the value is SQL <code>NULL</code>, the
01358 value returned is <code>null</code>
01359 }
01360 function TZRowAccessor.GetDate(ColumnIndex: Integer;
01361 var IsNull: Boolean): TDateTime;
01362 begin
01363 {$IFNDEF DISABLE_CHECKING}
01364 CheckColumnConvertion(ColumnIndex, stDate);
01365 {$ENDIF}
01366 Result := 0;
01367 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
01368 begin
01369 case FColumnTypes[ColumnIndex - 1] of
01370 stDate, stTime, stTimestamp:
01371 Result := Int(PDateTime(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^);
01372 stString, stUnicodeString:
01373 Result := Trunc(AnsiSQLDateToDateTime(GetString(ColumnIndex, IsNull)));
01374 end;
01375 IsNull := False;
01376 end else
01377 IsNull := True;
01378 end;
01379
01380 {**
01381 Gets the value of the designated column in the current row
01382 of this <code>ResultSet</code> object as
01383 a <code>java.sql.Time</code> object in the Java programming language.
01384
01385 @param columnIndex the first column is 1, the second is 2, ...
01386 @return the column value; if the value is SQL <code>NULL</code>, the
01387 value returned is <code>null</code>
01388 }
01389 function TZRowAccessor.GetTime(ColumnIndex: Integer;
01390 var IsNull: Boolean): TDateTime;
01391 begin
01392 {$IFNDEF DISABLE_CHECKING}
01393 CheckColumnConvertion(ColumnIndex, stTime);
01394 {$ENDIF}
01395 Result := 0;
01396 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
01397 begin
01398 case FColumnTypes[ColumnIndex - 1] of
01399 stDate, stTime, stTimestamp:
01400 Result := Frac(PDateTime(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^);
01401 stString, stUnicodeString:
01402 Result := Frac(AnsiSQLDateToDateTime(GetString(ColumnIndex, IsNull)));
01403 end;
01404 IsNull := False;
01405 end else
01406 IsNull := True;
01407 end;
01408
01409 {**
01410 Gets the value of the designated column in the current row
01411 of this <code>ResultSet</code> object as
01412 a <code>java.sql.Timestamp</code> object in the Java programming language.
01413
01414 @param columnIndex the first column is 1, the second is 2, ...
01415 @return the column value; if the value is SQL <code>NULL</code>, the
01416 value returned is <code>null</code>
01417 @exception SQLException if a database access error occurs
01418 }
01419 function TZRowAccessor.GetTimestamp(ColumnIndex: Integer;
01420 var IsNull: Boolean): TDateTime;
01421 begin
01422 {$IFNDEF DISABLE_CHECKING}
01423 CheckColumnConvertion(ColumnIndex, stTimestamp);
01424 {$ENDIF}
01425 Result := 0;
01426 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
01427 begin
01428 case FColumnTypes[ColumnIndex - 1] of
01429 stDate, stTime, stTimestamp:
01430 Result := PDateTime(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^;
01431 stString, stUnicodeString:
01432 Result := AnsiSQLDateToDateTime(GetString(ColumnIndex, IsNull));
01433 end;
01434 IsNull := False;
01435 end else
01436 IsNull := True;
01437 end;
01438
01439 {**
01440 Gets the value of the designated column in the current row
01441 of this <code>ResultSet</code> object as
01442 a stream of ASCII characters. The value can then be read in chunks from the
01443 stream. This method is particularly
01444 suitable for retrieving large <char>LONGVARCHAR</char> values.
01445 The JDBC driver will
01446 do any necessary conversion from the database format into ASCII.
01447
01448 <P><B>Note:</B> All the data in the returned stream must be
01449 read prior to getting the value of any other column. The next
01450 call to a <code>getXXX</code> method implicitly closes the stream. Also, a
01451 stream may return <code>0</code> when the method
01452 <code>InputStream.available</code>
01453 is called whether there is data available or not.
01454
01455 @param columnIndex the first column is 1, the second is 2, ...
01456 @return a Java input stream that delivers the database column value
01457 as a stream of one-byte ASCII characters; if the value is SQL
01458 <code>NULL</code>, the value returned is <code>null</code>
01459 }
01460 function TZRowAccessor.GetAsciiStream(ColumnIndex: Integer;
01461 var IsNull: Boolean): TStream;
01462 var
01463 TempBlob: IZBlob;
01464 begin
01465 {$IFNDEF DISABLE_CHECKING}
01466 CheckColumnConvertion(ColumnIndex, stAsciiStream);
01467 {$ENDIF}
01468 TempBlob := GetBlobObject(FBuffer, ColumnIndex);
01469 if (TempBlob <> nil) and not TempBlob.IsEmpty then
01470 Result := TempBlob.GetStream
01471 else Result := nil;
01472 IsNull := Result = nil;
01473 end;
01474
01475 {**
01476 Gets the value of a column in the current row as a stream of
01477 Gets the value of the designated column in the current row
01478 of this <code>ResultSet</code> object as
01479 as a stream of Unicode characters.
01480 The value can then be read in chunks from the
01481 stream. This method is particularly
01482 suitable for retrieving large<code>LONGVARCHAR</code>values. The JDBC driver will
01483 do any necessary conversion from the database format into Unicode.
01484 The byte format of the Unicode stream must be Java UTF-8,
01485 as specified in the Java virtual machine specification.
01486
01487 <P><B>Note:</B> All the data in the returned stream must be
01488 read prior to getting the value of any other column. The next
01489 call to a <code>getXXX</code> method implicitly closes the stream. Also, a
01490 stream may return <code>0</code> when the method
01491 <code>InputStream.available</code>
01492 is called whether there is data available or not.
01493
01494 @param columnIndex the first column is 1, the second is 2, ...
01495 @return a Java input stream that delivers the database column value
01496 as a stream in Java UTF-8 byte format; if the value is SQL
01497 <code>NULL</code>, the value returned is <code>null</code>
01498 }
01499 function TZRowAccessor.GetUnicodeStream(ColumnIndex: Integer;
01500 var IsNull: Boolean): TStream;
01501 var
01502 TempBlob: IZBlob;
01503 begin
01504 {$IFNDEF DISABLE_CHECKING}
01505 CheckColumnConvertion(ColumnIndex, stUnicodeStream);
01506 {$ENDIF}
01507 TempBlob := GetBlobObject(FBuffer, ColumnIndex);
01508 if (TempBlob <> nil) and not TempBlob.IsEmpty then
01509 Result := TempBlob.GetStream
01510 else Result := nil;
01511 IsNull := Result = nil;
01512 end;
01513
01514 {**
01515 Gets the value of a column in the current row as a stream of
01516 Gets the value of the designated column in the current row
01517 of this <code>ResultSet</code> object as a binary stream of
01518 uninterpreted bytes. The value can then be read in chunks from the
01519 stream. This method is particularly
01520 suitable for retrieving large <code>LONGVARBINARY</code> values.
01521
01522 <P><B>Note:</B> All the data in the returned stream must be
01523 read prior to getting the value of any other column. The next
01524 call to a <code>getXXX</code> method implicitly closes the stream. Also, a
01525 stream may return <code>0</code> when the method
01526 <code>InputStream.available</code>
01527 is called whether there is data available or not.
01528
01529 @param columnIndex the first column is 1, the second is 2, ...
01530 @return a Java input stream that delivers the database column value
01531 as a stream of uninterpreted bytes;
01532 if the value is SQL <code>NULL</code>, the value returned is <code>null</code>
01533 }
01534 function TZRowAccessor.GetBinaryStream(ColumnIndex: Integer;
01535 var IsNull: Boolean): TStream;
01536 var
01537 TempBlob: IZBlob;
01538 begin
01539 {$IFNDEF DISABLE_CHECKING}
01540 CheckColumnConvertion(ColumnIndex, stBinaryStream);
01541 {$ENDIF}
01542 TempBlob := GetBlobObject(FBuffer, ColumnIndex);
01543 if (TempBlob <> nil) and not TempBlob.IsEmpty then
01544 Result := TempBlob.GetStream
01545 else Result := nil;
01546 IsNull := Result = nil;
01547 end;
01548
01549 {**
01550 Returns the value of the designated column in the current row
01551 of this <code>ResultSet</code> object as a <code>Blob</code> object
01552 in the Java programming language.
01553
01554 @param ColumnIndex the first column is 1, the second is 2, ...
01555 @return a <code>Blob</code> object representing the SQL <code>BLOB</code> value in
01556 the specified column
01557 }
01558 function TZRowAccessor.GetBlob(ColumnIndex: Integer;
01559 var IsNull: Boolean): IZBlob;
01560 begin
01561 {$IFNDEF DISABLE_CHECKING}
01562 CheckColumnIndex(ColumnIndex);
01563 if not (FColumnTypes[ColumnIndex - 1] in [stAsciiStream, stBinaryStream,
01564 stUnicodeStream]) then
01565 begin
01566 raise EZSQLException.Create(
01567 Format(SCanNotAccessBlobRecord,
01568 [ColumnIndex, DefineColumnTypeName(FColumnTypes[ColumnIndex - 1])]));
01569 end;
01570 {$ENDIF}
01571
01572 Result := GetBlobObject(FBuffer, ColumnIndex);
01573 IsNull := Result = nil;
01574 if Result = nil then
01575 begin
01576 Result := TZAbstractBlob.CreateWithStream(nil);
01577 SetBlobObject(FBuffer, ColumnIndex, Result);
01578 end;
01579 end;
01580
01581 {**
01582 Gets the value of the designated column in the current row
01583 of this <code>ResultSet</code> object as a <code>Variant</code> value.
01584
01585 @param columnIndex the first column is 1, the second is 2, ...
01586 @return the column value; if the value is SQL <code>NULL</code>, the
01587 value returned is <code>null</code>
01588 }
01589 function TZRowAccessor.GetValue(ColumnIndex: Integer): TZVariant;
01590 var
01591 ValuePtr: Pointer;
01592 IsNull: Boolean;
01593 begin
01594 IsNull := False;
01595 if FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0 then
01596 begin
01597 ValuePtr := @FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1];
01598 case FColumnTypes[ColumnIndex - 1] of
01599 stByte:
01600 begin
01601 Result.VType := vtInteger;
01602 Result.VInteger := PShortInt(ValuePtr)^;
01603 end;
01604 stShort:
01605 begin
01606 Result.VType := vtInteger;
01607 Result.VInteger := PSmallInt(ValuePtr)^;
01608 end;
01609 stInteger:
01610 begin
01611 Result.VType := vtInteger;
01612 Result.VInteger := PInteger(ValuePtr)^;
01613 end;
01614 stLong:
01615 begin
01616 Result.VType := vtInteger;
01617 Result.VInteger := PInt64(ValuePtr)^;
01618 end;
01619 stFloat:
01620 begin
01621 Result.VType := vtFloat;
01622 Result.VFloat := PSingle(ValuePtr)^;
01623 end;
01624 stDouble:
01625 begin
01626 Result.VType := vtFloat;
01627 Result.VFloat := PDouble(ValuePtr)^;
01628 end;
01629 stBigDecimal:
01630 begin
01631 Result.VType := vtFloat;
01632 Result.VFloat := PExtended(ValuePtr)^;
01633 end;
01634 stBoolean:
01635 begin
01636 Result.VType := vtBoolean;
01637 Result.VBoolean := PWordBool(ValuePtr)^;
01638 end;
01639 stDate, stTime, stTimestamp:
01640 begin
01641 Result.VType := vtDateTime;
01642 Result.VDateTime := PDateTime(ValuePtr)^;
01643 end;
01644 stString:
01645 begin
01646 Result.VType := vtString;
01647 Result.VString := PChar(ValuePtr);
01648 end;
01649 stUnicodeString:
01650 begin
01651 Result.VType := vtUnicodeString;
01652 Result.VUnicodeString := PWideChar(ValuePtr);
01653 end;
01654 stBytes, stAsciiStream, stBinaryStream:
01655 begin
01656 Result.VType := vtString;
01657 Result.VString := GetString(ColumnIndex, IsNull);
01658 end;
01659 stUnicodeStream:
01660 begin
01661 Result.VType := vtUnicodeString;
01662 Result.VUnicodeString := GetUnicodeString(ColumnIndex, IsNull);
01663 end;
01664 else
01665 Result.VType := vtNull;
01666 end;
01667 end else
01668 Result.VType := vtNull;
01669 end;
01670
01671
01672
01673
01674
01675 {**
01676 Gives a not nullable column a null value.
01677
01678 The <code>SetXXX</code> methods are used to Set column values in the
01679 current row or the insert row. The <code>SetXXX</code> methods do not
01680 Set the underlying database; instead the <code>SetRow</code>
01681 or <code>insertRow</code> methods are called to Set the database.
01682
01683 @param columnIndex the first column is 1, the second is 2, ...
01684 }
01685 procedure TZRowAccessor.SetNotNull(ColumnIndex: Integer);
01686 begin
01687 {$IFNDEF DISABLE_CHECKING}
01688 CheckColumnConvertion(ColumnIndex, stString);
01689 {$ENDIF}
01690 if (FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 1)
01691 and (FColumnTypes[ColumnIndex - 1] in [stAsciiStream, stBinaryStream,
01692 stUnicodeStream]) then
01693 begin
01694 SetBlobObject(FBuffer, ColumnIndex, nil);
01695 end;
01696 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
01697 end;
01698
01699 {**
01700 Gives a nullable column a null value.
01701
01702 The <code>SetXXX</code> methods are used to Set column values in the
01703 current row or the insert row. The <code>SetXXX</code> methods do not
01704 Set the underlying database; instead the <code>SetRow</code>
01705 or <code>insertRow</code> methods are called to Set the database.
01706
01707 @param columnIndex the first column is 1, the second is 2, ...
01708 }
01709 procedure TZRowAccessor.SetNull(ColumnIndex: Integer);
01710 begin
01711 {$IFNDEF DISABLE_CHECKING}
01712 CheckColumnConvertion(ColumnIndex, stString);
01713 {$ENDIF}
01714 if (FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] = 0)
01715 and (FColumnTypes[ColumnIndex - 1] in [stAsciiStream, stBinaryStream,
01716 stUnicodeStream]) then
01717 begin
01718 SetBlobObject(FBuffer, ColumnIndex, nil);
01719 end;
01720 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 1;
01721 end;
01722
01723 {**
01724 Sets the designated column with a <code>boolean</code> value.
01725 The <code>SetXXX</code> methods are used to Set column values in the
01726 current row or the insert row. The <code>SetXXX</code> methods do not
01727 Set the underlying database; instead the <code>SetRow</code> or
01728 <code>insertRow</code> methods are called to Set the database.
01729
01730 @param columnIndex the first column is 1, the second is 2, ...
01731 @param x the new column value
01732 }
01733 procedure TZRowAccessor.SetBoolean(ColumnIndex: Integer; Value: Boolean);
01734 var
01735 TempInt: Integer;
01736 begin
01737 {$IFNDEF DISABLE_CHECKING}
01738 CheckColumnConvertion(ColumnIndex, stBoolean);
01739 {$ENDIF}
01740 if Value then TempInt := 1
01741 else TempInt := 0;
01742
01743 case FColumnTypes[ColumnIndex - 1] of
01744 stBoolean:
01745 begin
01746 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
01747 PWordBool(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^ := Value;
01748 end;
01749 stByte: SetByte(ColumnIndex, TempInt);
01750 stShort: SetShort(ColumnIndex, TempInt);
01751 stInteger: SetInt(ColumnIndex, TempInt);
01752 stLong: SetLong(ColumnIndex, TempInt);
01753 stFloat: SetFloat(ColumnIndex, TempInt);
01754 stDouble: SetDouble(ColumnIndex, TempInt);
01755 stBigDecimal: SetBigDecimal(ColumnIndex, TempInt);
01756 stString, stUnicodeString:
01757 if Value then SetString(ColumnIndex, 'True')
01758 else SetString(ColumnIndex, 'False');
01759 end;
01760 end;
01761
01762 {**
01763 Sets the designated column with a <code>byte</code> value.
01764 The <code>SetXXX</code> methods are used to Set column values in the
01765 current row or the insert row. The <code>SetXXX</code> methods do not
01766 Set the underlying database; instead the <code>SetRow</code> or
01767 <code>insertRow</code> methods are called to Set the database.
01768
01769
01770 @param columnIndex the first column is 1, the second is 2, ...
01771 @param x the new column value
01772 }
01773 procedure TZRowAccessor.SetByte(ColumnIndex: Integer;
01774 Value: ShortInt);
01775 begin
01776 {$IFNDEF DISABLE_CHECKING}
01777 CheckColumnConvertion(ColumnIndex, stByte);
01778 {$ENDIF}
01779 case FColumnTypes[ColumnIndex - 1] of
01780 stBoolean: SetBoolean(ColumnIndex, Value <> 0);
01781 stByte:
01782 begin
01783 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
01784 PShortInt(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^ := Value;
01785 end;
01786 stShort: SetShort(ColumnIndex, Value);
01787 stInteger: SetInt(ColumnIndex, Value);
01788 stLong: SetLong(ColumnIndex, Value);
01789 stFloat: SetFloat(ColumnIndex, Value);
01790 stDouble: SetDouble(ColumnIndex, Value);
01791 stBigDecimal: SetBigDecimal(ColumnIndex, Value);
01792 stString, stUnicodeString: SetString(ColumnIndex, IntToStr(Value));
01793 end;
01794 end;
01795
01796 {**
01797 Sets the designated column with a <code>short</code> value.
01798 The <code>SetXXX</code> methods are used to Set column values in the
01799 current row or the insert row. The <code>SetXXX</code> methods do not
01800 Set the underlying database; instead the <code>SetRow</code> or
01801 <code>insertRow</code> methods are called to Set the database.
01802
01803 @param columnIndex the first column is 1, the second is 2, ...
01804 @param x the new column value
01805 }
01806 procedure TZRowAccessor.SetShort(ColumnIndex: Integer; Value: SmallInt);
01807 begin
01808 {$IFNDEF DISABLE_CHECKING}
01809 CheckColumnConvertion(ColumnIndex, stShort);
01810 {$ENDIF}
01811 case FColumnTypes[ColumnIndex - 1] of
01812 stBoolean: SetBoolean(ColumnIndex, Value <> 0);
01813 stByte: SetByte(ColumnIndex, Value);
01814 stShort:
01815 begin
01816 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
01817 PSmallInt(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^ := Value;
01818 end;
01819 stInteger: SetInt(ColumnIndex, Value);
01820 stLong: SetLong(ColumnIndex, Value);
01821 stFloat: SetFloat(ColumnIndex, Value);
01822 stDouble: SetDouble(ColumnIndex, Value);
01823 stBigDecimal: SetBigDecimal(ColumnIndex, Value);
01824 stString, stUnicodeString:
01825 SetString(ColumnIndex, IntToStr(Value));
01826 end;
01827 end;
01828
01829 {**
01830 Sets the designated column with an <code>int</code> value.
01831 The <code>SetXXX</code> methods are used to Set column values in the
01832 current row or the insert row. The <code>SetXXX</code> methods do not
01833 Set the underlying database; instead the <code>SetRow</code> or
01834 <code>insertRow</code> methods are called to Set the database.
01835
01836 @param columnIndex the first column is 1, the second is 2, ...
01837 @param x the new column value
01838 }
01839 procedure TZRowAccessor.SetInt(ColumnIndex: Integer; Value: Integer);
01840 begin
01841 {$IFNDEF DISABLE_CHECKING}
01842 CheckColumnConvertion(ColumnIndex, stInteger);
01843 {$ENDIF}
01844 case FColumnTypes[ColumnIndex - 1] of
01845 stBoolean: SetBoolean(ColumnIndex, Value <> 0);
01846 stByte: SetByte(ColumnIndex, Value);
01847 stShort: SetShort(ColumnIndex, Value);
01848 stInteger:
01849 begin
01850 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
01851 PInteger(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^ := Value;
01852 end;
01853 stLong: SetLong(ColumnIndex, Value);
01854 stFloat: SetFloat(ColumnIndex, Value);
01855 stDouble: SetDouble(ColumnIndex, Value);
01856 stBigDecimal: SetBigDecimal(ColumnIndex, Value);
01857 stString, stUnicodeString:
01858 SetString(ColumnIndex, IntToStr(Value));
01859 end;
01860 end;
01861
01862 {**
01863 Sets the designated column with a <code>long</code> value.
01864 The <code>SetXXX</code> methods are used to Set column values in the
01865 current row or the insert row. The <code>SetXXX</code> methods do not
01866 Set the underlying database; instead the <code>SetRow</code> or
01867 <code>insertRow</code> methods are called to Set the database.
01868
01869 @param columnIndex the first column is 1, the second is 2, ...
01870 @param x the new column value
01871 }
01872 procedure TZRowAccessor.SetLong(ColumnIndex: Integer; Value: Int64);
01873 begin
01874 {$IFNDEF DISABLE_CHECKING}
01875 CheckColumnConvertion(ColumnIndex, stLong);
01876 {$ENDIF}
01877 case FColumnTypes[ColumnIndex - 1] of
01878 stBoolean: SetBoolean(ColumnIndex, Value <> 0);
01879 stByte: SetByte(ColumnIndex, Value);
01880 stShort: SetShort(ColumnIndex, Value);
01881 stInteger: SetInt(ColumnIndex, Value);
01882 stLong:
01883 begin
01884 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
01885 PInt64(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^ := Value;
01886 end;
01887 stFloat: SetFloat(ColumnIndex, Value);
01888 stDouble: SetDouble(ColumnIndex, Value);
01889 stBigDecimal: SetBigDecimal(ColumnIndex, Value);
01890 stString, stUnicodeString:
01891 SetString(ColumnIndex, IntToStr(Value));
01892 end;
01893 end;
01894
01895 {**
01896 Sets the designated column with a <code>float</code> value.
01897 The <code>SetXXX</code> methods are used to Set column values in the
01898 current row or the insert row. The <code>SetXXX</code> methods do not
01899 Set the underlying database; instead the <code>SetRow</code> or
01900 <code>insertRow</code> methods are called to Set the database.
01901
01902 @param columnIndex the first column is 1, the second is 2, ...
01903 @param x the new column value
01904 }
01905 procedure TZRowAccessor.SetFloat(ColumnIndex: Integer; Value: Single);
01906 begin
01907 {$IFNDEF DISABLE_CHECKING}
01908 CheckColumnConvertion(ColumnIndex, stFloat);
01909 {$ENDIF}
01910 case FColumnTypes[ColumnIndex - 1] of
01911 stBoolean: SetBoolean(ColumnIndex, Value <> 0);
01912 stByte: SetByte(ColumnIndex, Trunc(Value));
01913 stShort: SetShort(ColumnIndex, Trunc(Value));
01914 stInteger: SetInt(ColumnIndex, Trunc(Value));
01915 stLong: SetLong(ColumnIndex, Trunc(Value));
01916 stFloat:
01917 begin
01918 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
01919 PSingle(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^ := Value;
01920 end;
01921 stDouble: SetDouble(ColumnIndex, Value);
01922 stBigDecimal: SetBigDecimal(ColumnIndex, Value);
01923 stString, stUnicodeString:
01924 SetString(ColumnIndex, FloatToSQLStr(Value));
01925 end;
01926 end;
01927
01928 {**
01929 Sets the designated column with a <code>double</code> value.
01930 The <code>SetXXX</code> methods are used to Set column values in the
01931 current row or the insert row. The <code>SetXXX</code> methods do not
01932 Set the underlying database; instead the <code>SetRow</code> or
01933 <code>insertRow</code> methods are called to Set the database.
01934
01935 @param columnIndex the first column is 1, the second is 2, ...
01936 @param x the new column value
01937 }
01938 procedure TZRowAccessor.SetDouble(ColumnIndex: Integer; Value: Double);
01939 begin
01940 {$IFNDEF DISABLE_CHECKING}
01941 CheckColumnConvertion(ColumnIndex, stDouble);
01942 {$ENDIF}
01943 case FColumnTypes[ColumnIndex - 1] of
01944 stBoolean: SetBoolean(ColumnIndex, Value <> 0);
01945 stByte: SetByte(ColumnIndex, Trunc(Value));
01946 stShort: SetShort(ColumnIndex, Trunc(Value));
01947 stInteger: SetInt(ColumnIndex, Trunc(Value));
01948 stLong: SetLong(ColumnIndex, Trunc(Value));
01949 stFloat: SetFloat(ColumnIndex, Value);
01950 stDouble:
01951 begin
01952 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
01953 PDouble(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^ := Value;
01954 end;
01955 stBigDecimal: SetBigDecimal(ColumnIndex, Value);
01956 stString, stUnicodeString:
01957 SetString(ColumnIndex, FloatToSQLStr(Value));
01958 end;
01959 end;
01960
01961 {**
01962 Sets the designated column with a <code>java.math.BigDecimal</code>
01963 value.
01964 The <code>SetXXX</code> methods are used to Set column values in the
01965 current row or the insert row. The <code>SetXXX</code> methods do not
01966 Set the underlying database; instead the <code>SetRow</code> or
01967 <code>insertRow</code> methods are called to Set the database.
01968
01969 @param columnIndex the first column is 1, the second is 2, ...
01970 @param x the new column value
01971 }
01972 procedure TZRowAccessor.SetBigDecimal(ColumnIndex: Integer; Value: Extended);
01973 begin
01974 {$IFNDEF DISABLE_CHECKING}
01975 CheckColumnConvertion(ColumnIndex, stBigDecimal);
01976 {$ENDIF}
01977 case FColumnTypes[ColumnIndex - 1] of
01978 stBoolean: SetBoolean(ColumnIndex, Value <> 0);
01979 stByte: SetByte(ColumnIndex, Trunc(Value));
01980 stShort: SetShort(ColumnIndex, Trunc(Value));
01981 stInteger: SetInt(ColumnIndex, Trunc(Value));
01982 stLong: SetLong(ColumnIndex, Trunc(Value));
01983 stFloat: SetFloat(ColumnIndex, Value);
01984 stDouble: SetDouble(ColumnIndex, Value);
01985 stBigDecimal:
01986 begin
01987 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
01988 PExtended(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^ := Value;
01989 end;
01990 stString, stUnicodeString:
01991 SetString(ColumnIndex, FloatToSQLStr(Value));
01992 end;
01993 end;
01994
01995 {**
01996 Sets the designated column with a <code>String</code> value.
01997 The <code>SetXXX</code> methods are used to Set column values in the
01998 current row or the insert row. The <code>SetXXX</code> methods do not
01999 Set the underlying database; instead the <code>SetRow</code> or
02000 <code>insertRow</code> methods are called to Set the database.
02001
02002 @param columnIndex the first column is 1, the second is 2, ...
02003 @param x the new column value
02004 }
02005 procedure TZRowAccessor.SetPChar(ColumnIndex: Integer; Value: PChar);
02006 begin
02007 {$IFNDEF DISABLE_CHECKING}
02008 CheckColumnConvertion(ColumnIndex, stString);
02009 {$ENDIF}
02010 case FColumnTypes[ColumnIndex - 1] of
02011 stString:
02012 begin
02013 if Value <> nil then
02014 begin
02015 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
02016 StrLCopy(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1], Value,
02017 FColumnLengths[ColumnIndex - 1] - 1);
02018 end else
02019 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 1;
02020 end;
02021 else
02022 SetString(ColumnIndex, Value);
02023 end;
02024 end;
02025
02026 {**
02027 Sets the designated column with a <code>String</code> value.
02028 The <code>SetXXX</code> methods are used to Set column values in the
02029 current row or the insert row. The <code>SetXXX</code> methods do not
02030 Set the underlying database; instead the <code>SetRow</code> or
02031 <code>insertRow</code> methods are called to Set the database.
02032
02033 @param columnIndex the first column is 1, the second is 2, ...
02034 @param x the new column value
02035 }
02036 procedure TZRowAccessor.SetString(ColumnIndex: Integer; Value: string);
02037 var
02038 TempStr: string;
02039 IsNull: Boolean;
02040 begin
02041 {$IFNDEF DISABLE_CHECKING}
02042 CheckColumnConvertion(ColumnIndex, stString);
02043 {$ENDIF}
02044 IsNull := False;
02045 case FColumnTypes[ColumnIndex - 1] of
02046 stBoolean:
02047 begin
02048 TempStr := UpperCase(Value);
02049 SetBoolean(ColumnIndex, (TempStr = 'Y') or (TempStr = 'T')
02050 or (TempStr = 'YES') or (TempStr = 'TRUE'));
02051 end;
02052 stByte: SetByte(ColumnIndex, StrToIntDef(Value, 0));
02053 stShort: SetShort(ColumnIndex, StrToIntDef(Value, 0));
02054 stInteger: SetInt(ColumnIndex, StrToIntDef(Value, 0));
02055 stLong: SetLong(ColumnIndex, StrToIntDef(Value, 0));
02056 stFloat: SetFloat(ColumnIndex, SQLStrToFloatDef(Value, 0));
02057 stDouble: SetDouble(ColumnIndex, SQLStrToFloatDef(Value, 0));
02058 stBigDecimal: SetBigDecimal(ColumnIndex, SQLStrToFloatDef(Value, 0));
02059 stString:
02060 begin
02061 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
02062 StrPLCopy(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1], Value,
02063 FColumnLengths[ColumnIndex - 1] - 1);
02064 end;
02065 stUnicodeString: SetUnicodeString(ColumnIndex, Value);
02066 stBytes: SetBytes(ColumnIndex, StrToBytes(Value));
02067 stDate: SetDate(ColumnIndex, AnsiSQLDateToDateTime(Value));
02068 stTime: SetTime(ColumnIndex, AnsiSQLDateToDateTime(Value));
02069 stTimestamp: SetTimestamp(ColumnIndex, AnsiSQLDateToDateTime(Value));
02070 stAsciiStream, stUnicodeStream, stBinaryStream:
02071 GetBlob(ColumnIndex, IsNull).SetString(Value);
02072 end;
02073 end;
02074
02075 {**
02076 Sets the designated column with a <code>WideString</code> value.
02077 The <code>SetXXX</code> methods are used to Set column values in the
02078 current row or the insert row. The <code>SetXXX</code> methods do not
02079 Set the underlying database; instead the <code>SetRow</code> or
02080 <code>insertRow</code> methods are called to Set 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 TZRowAccessor.SetUnicodeString(ColumnIndex: Integer;
02086 Value: WideString);
02087 begin
02088 {$IFNDEF DISABLE_CHECKING}
02089 CheckColumnConvertion(ColumnIndex, stString);
02090 {$ENDIF}
02091 case FColumnTypes[ColumnIndex - 1] of
02092 stUnicodeString:
02093 begin
02094 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
02095 Value := System.Copy(Value, 1, FColumnLengths[ColumnIndex - 1] div 2 - 1);
02096
02097 if Length(Value) > 0 then
02098 System.Move(PWideString(Value)^, Pointer(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^, Length(Value) * 2 + 2)
02099 else
02100 PWideChar(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^ := #0;
02101 end;
02102 else
02103 SetString(ColumnIndex, Value);
02104 end;
02105 end;
02106
02107 {**
02108 Sets the designated column with a <code>byte</code> array value.
02109 The <code>SetXXX</code> methods are used to Set column values in the
02110 current row or the insert row. The <code>SetXXX</code> methods do not
02111 Set the underlying database; instead the <code>SetRow</code> or
02112 <code>insertRow</code> methods are called to Set the database.
02113
02114 @param columnIndex the first column is 1, the second is 2, ...
02115 @param x the new column value
02116 }
02117 procedure TZRowAccessor.SetBytes(ColumnIndex: Integer; Value: TByteDynArray);
02118 var
02119 I: Integer;
02120 TempShort: SmallInt;
02121 begin
02122 {$IFNDEF DISABLE_CHECKING}
02123 CheckColumnConvertion(ColumnIndex, stBytes);
02124 {$ENDIF}
02125 if Value <> nil then
02126 begin
02127 case FColumnTypes[ColumnIndex - 1] of
02128 stBytes:
02129 begin
02130 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
02131 TempShort := MinIntValue([High(Value) + 1, FColumnLengths[ColumnIndex - 1]
02132 - SizeOf(SmallInt)]);
02133 PSmallInt(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^ :=
02134 TempShort;
02135 for I := 0 to TempShort - 1 do
02136 begin
02137 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1
02138 + SizeOf(SmallInt) + I] := Value[I];
02139 end;
02140 end;
02141 else
02142 SetString(ColumnIndex, BytesToStr(Value));
02143 end;
02144 end else
02145 SetNull(ColumnIndex);
02146 end;
02147
02148 {**
02149 Sets the designated column with a <code>java.sql.Date</code> value.
02150 The <code>SetXXX</code> methods are used to Set column values in the
02151 current row or the insert row. The <code>SetXXX</code> methods do not
02152 Set the underlying database; instead the <code>SetRow</code> or
02153 <code>insertRow</code> methods are called to Set the database.
02154
02155 @param columnIndex the first column is 1, the second is 2, ...
02156 @param x the new column value
02157 }
02158 procedure TZRowAccessor.SetDate(ColumnIndex: Integer; Value: TDateTime);
02159 begin
02160 {$IFNDEF DISABLE_CHECKING}
02161 CheckColumnConvertion(ColumnIndex, stTimestamp);
02162 {$ENDIF}
02163 case FColumnTypes[ColumnIndex - 1] of
02164 stDate:
02165 begin
02166 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
02167 PDateTime(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^ :=
02168 Trunc(Value);
02169 end;
02170 stTimestamp: SetTimestamp(ColumnIndex, Trunc(Value));
02171 stString, stUnicodeString:
02172 SetString(ColumnIndex, FormatDateTime('yyyy-mm-dd', Value));
02173 end;
02174 end;
02175
02176 {**
02177 Sets the designated column with a <code>java.sql.Time</code> value.
02178 The <code>SetXXX</code> methods are used to Set column values in the
02179 current row or the insert row. The <code>SetXXX</code> methods do not
02180 Set the underlying database; instead the <code>SetRow</code> or
02181 <code>insertRow</code> methods are called to Set the database.
02182
02183 @param columnIndex the first column is 1, the second is 2, ...
02184 @param x the new column value
02185 }
02186 procedure TZRowAccessor.SetTime(ColumnIndex: Integer; Value: TDateTime);
02187 begin
02188 {$IFNDEF DISABLE_CHECKING}
02189 CheckColumnConvertion(ColumnIndex, stTime);
02190 {$ENDIF}
02191 case FColumnTypes[ColumnIndex - 1] of
02192 stTime:
02193 begin
02194 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
02195 PDateTime(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^ :=
02196 Frac(Value);
02197 end;
02198 stTimestamp: SetTimestamp(ColumnIndex, Frac(Value));
02199 stString, stUnicodeString:
02200 SetString(ColumnIndex, FormatDateTime('hh:nn:ss', Value));
02201 end;
02202 end;
02203
02204 {**
02205 Sets the designated column with a <code>java.sql.Timestamp</code>
02206 value.
02207 The <code>SetXXX</code> methods are used to Set column values in the
02208 current row or the insert row. The <code>SetXXX</code> methods do not
02209 Set the underlying database; instead the <code>SetRow</code> or
02210 <code>insertRow</code> methods are called to Set the database.
02211
02212 @param columnIndex the first column is 1, the second is 2, ...
02213 @param x the new column value
02214 }
02215 procedure TZRowAccessor.SetTimestamp(ColumnIndex: Integer; Value: TDateTime);
02216 begin
02217 {$IFNDEF DISABLE_CHECKING}
02218 CheckColumnConvertion(ColumnIndex, stTimestamp);
02219 {$ENDIF}
02220 case FColumnTypes[ColumnIndex - 1] of
02221 stDate: SetDate(ColumnIndex, Value);
02222 stTime: SetTime(ColumnIndex, Value);
02223 stTimestamp:
02224 begin
02225 FBuffer.Columns[FColumnOffsets[ColumnIndex - 1]] := 0;
02226 PDateTime(@FBuffer.Columns[FColumnOffsets[ColumnIndex - 1] + 1])^ := Value;
02227 end;
02228 stString, stUnicodeString:
02229 SetString(ColumnIndex, FormatDateTime('yyyy-mm-dd hh:nn:ss', Value));
02230 end;
02231 end;
02232
02233 {**
02234 Sets the designated column with an ascii stream value.
02235 The <code>SetXXX</code> methods are used to Set column values in the
02236 current row or the insert row. The <code>SetXXX</code> methods do not
02237 Set the underlying database; instead the <code>SetRow</code> or
02238 <code>insertRow</code> methods are called to Set the database.
02239
02240 @param columnIndex the first column is 1, the second is 2, ...
02241 @param x the new column value
02242 }
02243 procedure TZRowAccessor.SetAsciiStream(ColumnIndex: Integer; Value: TStream);
02244 var
02245 IsNull: Boolean;
02246 begin
02247 {$IFNDEF DISABLE_CHECKING}
02248 CheckColumnConvertion(ColumnIndex, stAsciiStream);
02249 {$ENDIF}
02250 IsNull := False;
02251 GetBlob(ColumnIndex, IsNull).SetStream(Value);
02252 end;
02253
02254 {**
02255 Sets the designated column with a binary stream value.
02256 The <code>SetXXX</code> methods are used to Set column values in the
02257 current row or the insert row. The <code>SetXXX</code> methods do not
02258 Set the underlying database; instead the <code>SetRow</code> or
02259 <code>insertRow</code> methods are called to Set the database.
02260
02261 @param columnIndex the first column is 1, the second is 2, ...
02262 @param x the new column value
02263 @param length the length of the stream
02264 }
02265 procedure TZRowAccessor.SetBinaryStream(ColumnIndex: Integer; Value: TStream);
02266 var
02267 IsNull: Boolean;
02268 begin
02269 {$IFNDEF DISABLE_CHECKING}
02270 CheckColumnConvertion(ColumnIndex, stBinaryStream);
02271 {$ENDIF}
02272 IsNull := False;
02273 GetBlob(ColumnIndex, IsNull).SetStream(Value);
02274 end;
02275
02276 {**
02277 Sets the designated column with a character stream value.
02278 The <code>SetXXX</code> methods are used to Set column values in the
02279 current row or the insert row. The <code>SetXXX</code> methods do not
02280 Set the underlying database; instead the <code>SetRow</code> or
02281 <code>insertRow</code> methods are called to Set the database.
02282
02283 @param columnIndex the first column is 1, the second is 2, ...
02284 @param x the new column value
02285 }
02286 procedure TZRowAccessor.SetUnicodeStream(ColumnIndex: Integer;
02287 Value: TStream);
02288 var
02289 IsNull: Boolean;
02290 begin
02291 IsNull := False;
02292 {$IFNDEF DISABLE_CHECKING}
02293 CheckColumnConvertion(ColumnIndex, stUnicodeStream);
02294 {$ENDIF}
02295 GetBlob(ColumnIndex, IsNull).SetStream(Value);
02296 end;
02297
02298 {**
02299 Sets the blob wrapper object to the specified column.
02300 @param ColumnIndex the first column is 1, the second is 2, ...
02301 @param Value a blob wrapper object to be set.
02302 }
02303 procedure TZRowAccessor.SetBlob(ColumnIndex: Integer; Value: IZBlob);
02304 begin
02305 {$IFNDEF DISABLE_CHECKING}
02306 CheckColumnIndex(ColumnIndex);
02307 if not (FColumnTypes[ColumnIndex - 1] in [stAsciiStream, stBinaryStream,
02308 stUnicodeStream]) then
02309 begin
02310 raise EZSQLException.Create(
02311 Format(SCanNotAccessBlobRecord,
02312 [ColumnIndex, DefineColumnTypeName(FColumnTypes[ColumnIndex - 1])]));
02313 end;
02314 {$ENDIF}
02315
02316 SetBlobObject(FBuffer, ColumnIndex, Value);
02317 end;
02318
02319 {**
02320 Sets the designated column with a <code>Variant</code> value.
02321 The <code>SetXXX</code> methods are used to Set column values in the
02322 current row or the insert row. The <code>SetXXX</code> methods do not
02323 Set the underlying database; instead the <code>SetRow</code> or
02324 <code>insertRow</code> methods are called to Set the database.
02325
02326 @param columnIndex the first column is 1, the second is 2, ...
02327 @param x the new column value
02328 }
02329 procedure TZRowAccessor.SetValue(ColumnIndex: Integer; Value: TZVariant);
02330 begin
02331 case Value.VType of
02332 vtNull: SetNull(ColumnIndex);
02333 vtBoolean: SetBoolean(ColumnIndex, Value.VBoolean);
02334 vtInteger: SetLong(ColumnIndex, Value.VInteger);
02335 vtFloat: SetBigDecimal(ColumnIndex, Value.VFloat);
02336 vtString: SetString(ColumnIndex, Value.VString);
02337 vtUnicodeString: SetUnicodeString(ColumnIndex, Value.VUnicodeString);
02338 vtDateTime: SetTimestamp(ColumnIndex, Value.VDateTime);
02339 end;
02340 end;
02341
02342 end.