PageRenderTime 92ms CodeModel.GetById 61ms app.highlight 22ms RepoModel.GetById 1ms app.codeStats 1ms

/EndTask/2008.04.16 ?????/Oracle Data Access Components(ODAC) v6/Source/Ora.pas

http://xinhaining-dianjianyiqi-tongxunchengxu.googlecode.com/
Pascal | 1895 lines | 1387 code | 344 blank | 164 comment | 0 complexity | 71b7f3352559866357afc8cf587bcc65 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1
   2//////////////////////////////////////////////////
   3//  Oracle Data Access Components
   4//  Copyright (c) 1998-2006 Core Lab. All right reserved.
   5//  Oracle DataSet
   6//  Created:            05.03.98
   7//  Last modified:      21.02.03
   8//////////////////////////////////////////////////
   9
  10{$IFNDEF CLR}
  11{$I Odac.inc}
  12{$R-} // for ftBFile
  13unit Ora;
  14{$ENDIF}
  15
  16interface
  17uses
  18{$IFDEF CLR}
  19  Windows, SysUtils, Classes, Variants, System.IO, System.XML, System.Text,
  20{$ENDIF}
  21{$IFDEF WIN32}
  22  Windows, SysUtils, Classes, StdVcl, CLRClasses, CRXml,
  23{$ENDIF}
  24{$IFDEF LINUX}
  25  SysUtils, Classes, CLRClasses, CRXml,
  26{$ENDIF}
  27{$IFDEF NET}OraNet, {$ENDIF}
  28{$IFDEF VER6P}SqlTimSt, {$ENDIF}
  29  MemUtils, DB, MemData, MemDS, CRAccess, DBAccess, CRConnectionPool, OraCall, OraClasses,
  30  OraError, OraObjects, OraConnectionPool;
  31
  32{$IFDEF NET}
  33  {$NOINCLUDE OraNet}
  34{$ENDIF}
  35
  36
  37
  38{$I OdacVer.inc}
  39
  40const
  41  ftObject = ftADT;
  42  ftTable = ftDataSet;
  43  ftBFile = 100;
  44  ftLabel = 101;
  45{$IFNDEF VER6P}
  46  ftTimeStamp = 102;
  47{$ENDIF}
  48  ftIntervalYM = 103;
  49  ftIntervalDS = 104;
  50
  51  ftTimeStampTZ = 105;
  52  ftTimeStampLTZ = 106;
  53
  54  ftNumber = 107;
  55
  56  ftXML = 108;
  57  ftFixedWideChar = 109;
  58
  59  DEFAULT_TRACE_FILE_SIZE = 0;
  60  UNLIMITED_TRACE_FILE_SIZE = -1;
  61
  62type
  63  TOraSession = class;
  64  TOraDataSet = class;
  65  TOraSQL = class;
  66  TOraUpdateSQL = class;
  67  TOraParam = class;
  68  TOraParams = class;
  69
  70  TSubFieldType = (stNone, stOraBlob, stOraClob);
  71  TCharLength = 0..6;
  72
  73{ TOraSession }
  74
  75  TConnectChangeEvent = procedure (Sender: TObject; Connected: boolean) of object;
  76
  77  TFailoverState = (fsEnd, fsAbort, fsReauth, fsBegin, fsError);
  78  TFailoverType = (ftNone, ftSession, ftSelect, ftTransaction);
  79  TFailoverEvent = procedure (Sender: TObject; FailoverState: TFailoverState; FailoverType: TFailoverType; var Retry: boolean) of object;
  80  TOptimizerMode = (omDefault, omFirstRows1000, omFirstRows100, omFirstRows10, omFirstRows1, omFirstRows, omAllRows, omChoose, omRule);
  81
  82  TOraSessionOptions = class (TDAConnectionOptions)
  83  private
  84    FUseOCI7: boolean;
  85    FDirect: boolean;
  86    FEnableIntegers: boolean;
  87    FIsDateLanguageStored: boolean;
  88    FIsDateFormatStored: boolean;
  89    FEnableNumbers: boolean;
  90    FCharLength: TCharLength;
  91    FCharset: string;
  92    FUseUnicode: boolean;
  93    FDateFormat: string;
  94    FDateLanguage: string;
  95    FOptimizerMode: TOptimizerMode;
  96    FConnectionTimeout: integer;
  97    FStatementCache: boolean;
  98    FStatementCacheSize: integer;
  99    FClientIdentifier: string;
 100
 101    function GetCharLength: TCharLength;
 102    procedure SetCharLength(Value: TCharLength);
 103    procedure SetCharset(Value: string);
 104    procedure SetUseUnicode(Value: boolean);
 105    function GetDateLanguage: string;
 106    procedure SetDateLanguage(Value: string);
 107    function GetDateFormat: string;
 108    procedure SetDateFormat(Value: string);
 109    procedure SetEnableIntegers(Value: boolean);
 110    procedure SetEnableNumbers(Value: boolean);
 111    function GetConvertEOL: boolean;
 112    procedure SetConvertEOL(Value: boolean);
 113    procedure SetNeverConnect(Value: boolean);
 114    function GetNeverConnect: boolean;
 115    procedure SetUseOCI7(Value: boolean);
 116    function GetNet: boolean;
 117    procedure SetNet(Value: boolean);
 118    procedure SetDirect(Value: boolean);
 119    procedure SetOptimizerMode(Value: TOptimizerMode);
 120    procedure SetStatementCache(Value: boolean);
 121    procedure SetStatementCacheSize(Value: integer);
 122    procedure SetClientIdentifier(const Value: string);
 123  protected
 124    procedure AssignTo(Dest: TPersistent); override;
 125    procedure SetDisconnectedMode(Value: boolean); override;
 126
 127  public
 128    constructor Create(Owner: TCustomDAConnection);
 129  {$IFNDEF NET}
 130    property Net: boolean read GetNet write SetNet default False;  // obsolete
 131    property Direct: boolean read FDirect write SetDirect default False;
 132  {$ENDIF}
 133
 134  published
 135    property CharLength: TCharLength read GetCharLength write SetCharLength default 1;
 136    property Charset: string read FCharset write SetCharset;
 137    property UseUnicode: boolean read FUseUnicode write SetUseUnicode default False;
 138    property ConvertEOL: boolean read GetConvertEOL write SetConvertEOL default False;
 139    property DateFormat: string read GetDateFormat write SetDateFormat stored FIsDateFormatStored;
 140    property DateLanguage: string read GetDateLanguage write SetDateLanguage stored FIsDateLanguageStored;
 141    property EnableIntegers: boolean read FEnableIntegers write SetEnableIntegers default True;
 142    property EnableNumbers: boolean read FEnableNumbers write SetEnableNumbers default False;
 143    property NeverConnect: boolean read GetNeverConnect write SetNeverConnect stored False default False;// obsolete
 144    property UseOCI7: boolean read FUseOCI7 write SetUseOCI7 default False;
 145    property DisconnectedMode;
 146    property KeepDesignConnected;
 147    property LocalFailover;
 148    property OptimizerMode: TOptimizerMode read FOptimizerMode write SetOptimizerMode default omDefault;
 149    property ConnectionTimeout: integer read FConnectionTimeout write FConnectionTimeout default 0;
 150    property StatementCache: boolean read FStatementCache write SetStatementCache default False;
 151    property StatementCacheSize: integer read FStatementCacheSize write SetStatementCacheSize default 20;
 152    property ClientIdentifier: string read FClientIdentifier write SetClientIdentifier;
 153  {$IFDEF NET}
 154    property Net: boolean read GetNet write SetNet stored False default False;  // obsolete
 155    property Direct: boolean read FDirect write SetDirect default False;
 156  {$ENDIF}
 157  end;
 158
 159  TOraPoolingOptions = class(TPoolingOptions)
 160  private
 161    FPoolingType: TOraPoolingType;
 162    FProxyUsername: string;
 163    FProxyPassword: string;
 164
 165    procedure SetPoolingType(Value: TOraPoolingType);
 166    procedure SetProxyUsername(Value: string);
 167    procedure SetProxyPassword(Value: string);
 168  public
 169    constructor Create(Owner: TCustomDAConnection); override;
 170  published
 171    property PoolType: TOraPoolingType read FPoolingType write SetPoolingType default optLocal;
 172    property ProxyUsername: string read FProxyUsername write SetProxyUsername;
 173    property ProxyPassword: string read FProxyPassword write SetProxyPassword;
 174  end;
 175
 176{ TOraTrace }  
 177
 178{$IFNDEF STD}
 179  TSqlTraceMode = set of (smBasicStatistics, smTypicalStatistics, smAllStatistics,
 180    smBindVariables, smWaitEvents, smTimedStatistics);
 181  TPlSqlTraceMode = set of (pmAllCalls, pmEnabledCalls, pmAllExceptions, pmEnabledExceptions,
 182    pmAllSql, pmEnabledSql, pmAllLines, pmEnabledLines);
 183  TTraceState = set of (tsSqlTrace, tsPlSqlTrace);
 184
 185  TOraTrace = class(TComponent)
 186  private
 187    FSession: TOraSession;
 188    FEnabled: boolean;
 189    FPlSqlTraceMode: TPlSqlTraceMode;
 190    FSqlTraceMode: TSqlTraceMode;
 191    FPlSqlTraceActive: boolean;
 192    FSqlTraceActive: boolean;
 193    FTraceFileIdentifier: string;
 194    FMaxTraceFileSize: integer;
 195
 196    function GetState: TTraceState;
 197    procedure SetSession(Value: TOraSession);
 198    procedure SetEnabled(Value: boolean);
 199    procedure SetTraceFileIdentifier(const Value: string);
 200    procedure SetMaxTraceFileSize(Value: integer);
 201    procedure SetSqlTraceMode(Value: TSqlTraceMode);
 202
 203  protected
 204    FDesignCreate: boolean;
 205
 206    procedure Loaded; override;
 207    procedure InternalSetTraceFileIdentifier;
 208    procedure InternalSetMaxTraceFileSize;
 209    procedure InternalSetSqlTraceMode;
 210    procedure StartTrace;
 211    procedure StopTrace;
 212
 213  public
 214    constructor Create(AOwner: TComponent); override;
 215    destructor Destroy; override;
 216
 217    //DbmsTrace
 218    procedure PlSqlTraceStart;
 219    procedure PlSqlTraceStop;
 220    procedure PlSqlTracePause;
 221    procedure PlSqlTraceResume;
 222    procedure PlSqlTraceComment(const Comment: string);
 223    procedure PlSqlTraceLimit(Limit: integer = 8192);
 224    function PlSqlTraceRunNumber: integer;
 225    //SQLTrace
 226    procedure SqlTraceStart;
 227    procedure SqlTraceStop;
 228    function GetTraceFileName: string;
 229    function GetSessionPID: integer;
 230
 231    property State: TTraceState read GetState;
 232
 233  published
 234    property Session: TOraSession read FSession write SetSession;
 235    property Enabled: boolean read FEnabled write SetEnabled default True;
 236    property SqlTraceMode: TSqlTraceMode read FSqlTraceMode write SetSqlTraceMode
 237      default [smTypicalStatistics, smTimedStatistics];
 238    property PlSqlTraceMode: TPlSqlTraceMode read FPlSqlTraceMode write FPlSqlTraceMode default [];
 239    property TraceFileIdentifier: string read FTraceFileIdentifier write SetTraceFileIdentifier;
 240    property MaxTraceFileSize: integer read FMaxTraceFileSize write SetMaxTraceFileSize default DEFAULT_TRACE_FILE_SIZE;
 241  end;
 242{$ENDIF}  
 243
 244  TOraSession = class (TCustomDAConnection)
 245  private
 246    FDebug: boolean;
 247    FOraSQL: TOraSQL;
 248    FOptions: TOraSessionOptions;
 249    FPoolingOptions: TOraPoolingOptions;
 250    FHomeName: string;
 251    FThreadSafety: boolean;
 252    FConnectMode: TConnectMode;
 253    FOCICallStyle: TOCICallStyle;
 254
 255    FOnConnectChange: TConnectChangeEvent;  // obsolete
 256    FInternalName: string;
 257    FFailoverEvent: TFailoverEvent;
 258    FSchema : string;
 259    FCachedSchema: string;
 260    FProxySession : TOraSession;
 261  {$IFNDEF STD}
 262    FTrace: TOraTrace;
 263  {$ENDIF}
 264
 265    procedure SetThreadSafety(Value: boolean);
 266    function GetOracleVersion: string;
 267    function GetSQL: TOraSQL; virtual;
 268    procedure SetDebug(Value: boolean);
 269    function GetLDA: PLDA;
 270    function GetOCISvcCtx: pOCISvcCtx;
 271    procedure SetOCISvcCtx(Value: pOCISvcCtx);
 272    function GetOCICallStyle: TOCICallStyle;
 273    procedure SetOCICallStyle(Value: TOCICallStyle);
 274    procedure SetOptions(Value: TOraSessionOptions);
 275    procedure SetPoolingOptions(Value: TOraPoolingOptions);
 276    function GetLastError: integer;
 277    procedure SetLastError(Value: integer);
 278    procedure SetHomeName(Value: string);
 279    function GetHome: TOracleHome;
 280    procedure SetHome(Value: TOracleHome);
 281    function GetConnectPrompt: boolean;
 282    procedure SetConnectPrompt(Value: boolean);
 283    procedure SetConnectMode(Value: TConnectMode);
 284
 285    function GetSchema : string;
 286    procedure SetSchema (Value : string);
 287    procedure SetCurrentSchema(SchemaName : string);
 288    function GetCurrentSchema : string;
 289    function GetDefaultSchema : string;
 290    function IsSchemaStored : boolean;
 291
 292    function GetProxySession : TOraSession;
 293    procedure SetProxySession (Value : TOraSession);
 294
 295    procedure SetInternalName(const AValue: string);
 296
 297    procedure GetObjectList(List: TStrings; SQL: string);
 298    procedure CheckDirect;
 299    procedure SetClientIdentifier(const Value: string);
 300  {$IFNDEF STD}
 301    procedure SetTrace(Value: TOraTrace);
 302  {$ENDIF}  
 303
 304  protected
 305    FIConnection: TOCIConnection;
 306  {$IFDEF MSWINDOWS}
 307    FChangeNotifications: TDAList;
 308  {$ENDIF}
 309
 310    procedure CreateIConnection; override;
 311    function GetIConnectionClass: TCRConnectionClass; override;
 312    function GetICommandClass: TCRCommandClass; override;
 313    function GetIRecordSetClass: TCRRecordSetClass; override;
 314
 315    function GetOCIConnection: TOCIConnection;
 316    procedure SetIConnection(Value: TCRConnection); override;
 317
 318    procedure DoConnect; override;
 319    procedure DoDisconnect; override;
 320
 321    procedure AssignTo(Dest: TPersistent); override;
 322
 323
 324    function IsFatalError(E: EDAError): boolean; override;
 325    function IsKeyViolation(E: EDAError): boolean; override;
 326    function GetCompilationError(SQL: string): string;
 327
 328
 329    function SQLMonitorClass: TClass; override;
 330    function ConnectDialogClass: TConnectDialogClass; override;
 331
 332    function CreateOptions: TDAConnectionOptions; override;
 333    function CreatePoolingOptions: TPoolingOptions; override;
 334
 335    function GetTransactionID: string; override;
 336    function LocalTransactionId(CreateTransaction: boolean = False): string;
 337    function GetInTransaction: boolean; override;
 338
 339    procedure SetConnected(Value: boolean); override;
 340    function GetConnectString: string; override;
 341    procedure SetConnectString(Value: string); override;
 342    procedure DoOnFailover(FailoverState: cardinal; FailoverType: cardinal; var Retry: boolean);
 343
 344    function GetCachedSchema: string;
 345
 346    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
 347
 348    procedure SetOptimizerMode(Value: TOptimizerMode);
 349  {$IFNDEF STD}
 350    property Trace: TOraTrace read FTrace write SetTrace;
 351  {$ENDIF}    
 352  public
 353    constructor Create(Owner: TComponent); override;
 354    destructor Destroy; override;
 355
 356  { Transaction control }
 357    procedure StartTransaction; overload; override;
 358    procedure StartTransaction(IsolationLevel: TOraIsolationLevel; const RollbackSegment: string = ''; const Name: string = ''); reintroduce; overload;
 359    procedure Savepoint(const Savepoint: string);
 360    procedure RollbackToSavepoint(const Savepoint: string);
 361
 362    function ParamByName(Name: string): TOraParam;
 363
 364    function ExecSQL(Text: string; const Params: array of variant): variant; override;
 365    function ExecProc(Name: string; const Params: array of variant): variant;
 366
 367    function ExecSQLEx(Text: string; const Params: array of variant): variant;
 368    function ExecProcEx(Name: string; const Params: array of variant): variant;
 369
 370    procedure Ping;
 371    procedure ClearStatementCache;
 372
 373    procedure AssignConnect(Source: TOraSession);
 374
 375    function CreateDataSet: TCustomDADataSet; override;
 376    function CreateSQL: TCustomDASQL; override;
 377
 378    procedure ChangePassword(NewPassword: string);
 379
 380    procedure GetTableNames(List: TStrings); overload; override;
 381    procedure GetTableNames(List: TStrings; AllTables: boolean); reintroduce; overload;
 382    procedure GetStoredProcNames(List: TStrings); overload; override;
 383    procedure GetStoredProcNames(List: TStrings; AllProcs: boolean); reintroduce; overload;
 384    procedure GetSequenceNames(List: TStrings);
 385
 386
 387    property LDA: PLDA read GetLDA;
 388    property OCISvcCtx: pOCISvcCtx read GetOCISvcCtx write SetOCISvcCtx;
 389    property OCICallStyle: TOCICallStyle read GetOCICallStyle write SetOCICallStyle;
 390    property LastError: integer read GetLastError write SetLastError;
 391    property OracleVersion: string read GetOracleVersion;
 392
 393    property SQL: TOraSQL read GetSQL;
 394    property OraSQL: TOraSQL read GetSQL;  // for back compatibility
 395    property InternalName: string read FInternalName write SetInternalName;
 396    property ProxySession : TOraSession read GetProxySession write SetProxySession;
 397  published
 398    property Debug: boolean read FDebug write SetDebug default False;
 399    property ThreadSafety: boolean read FThreadSafety write SetThreadSafety default True;
 400    property ConnectPrompt: boolean read GetConnectPrompt write SetConnectPrompt stored False default True; //obsolette
 401    property ConnectMode: TConnectMode read FConnectMode write SetConnectMode default cmNORMAL;
 402    property Options: TOraSessionOptions read FOptions write SetOptions;
 403
 404    property PoolingOptions: TOraPoolingOptions read FPoolingOptions write SetPoolingOptions;
 405    property Pooling;
 406
 407    property Username;
 408    property Password;
 409    property Server;
 410    property ConnectString;
 411    property AutoCommit;
 412    property Connected stored IsConnectedStored;
 413    property ConnectDialog;
 414    property LoginPrompt;    
 415
 416    property AfterConnect;
 417    property BeforeConnect;
 418    property AfterDisconnect;
 419    property BeforeDisconnect;
 420    property OnLogin;
 421    property OnError;
 422    property OnConnectionLost;
 423
 424  // obsolete
 425    property OnConnectChange: TConnectChangeEvent read FOnConnectChange write FOnConnectChange;
 426    property OnFailover: TFailoverEvent read FFailoverEvent write FFailoverEvent;
 427
 428    property Home: TOracleHome read GetHome write SetHome stored False default ohDefault;
 429    property HomeName: string read FHomeName write SetHomeName;
 430
 431    property Schema : string read GetSchema write SetSchema stored IsSchemaStored;
 432  end;
 433
 434{ TSessionList }
 435  TSessionList = class (TThreadList)
 436  private
 437    function GetCount: integer;
 438    function GetSession(i: integer): TOraSession;
 439  public
 440    property Count: integer read GetCount;
 441    property Items[i: integer]: TOraSession read GetSession; default;
 442  end;
 443
 444{ TOraParam }
 445{$IFNDEF CLR}
 446  VariantPtr = ^variant;
 447{$ENDIF}
 448
 449  TOraParam = class (TDAParam)
 450  private
 451    FTable: boolean;
 452    FNational : boolean;
 453    FDataPtr: Variant;
 454    FParamDescRef: TOraParamDesc;
 455
 456{$IFNDEF CLR}
 457    function GetVarArrayPtr : VariantPtr;
 458{$ENDIF}
 459    procedure CheckIndex(Index: integer);
 460
 461    function GetTable: boolean;
 462    procedure SetTable(Value: boolean);
 463    function GetNational: boolean;
 464    procedure SetNational(Value: boolean);
 465    function GetTableLength: integer;
 466    procedure SetTableLength(Value: integer);
 467
 468    function GetAsCursor: TOraCursor;
 469    procedure SetAsCursor(Value: TOraCursor);
 470    function GetAsOraBlob: TOraLob;
 471    procedure SetAsOraBlob(Value: TOraLob);
 472    function GetAsOraClob: TOraLob;
 473    procedure SetAsOraClob(Value: TOraLob);
 474    function GetAsBFile: TOraFile;
 475    procedure SetAsBFile(Value: TOraFile);
 476    function GetAsObject: TOraObject;
 477    procedure SetAsObject(Value: TOraObject);
 478    function GetAsXML: TOraXML;
 479    procedure SetAsXML(Value: TOraXML);
 480    function GetAsRef: TOraRef;
 481    procedure SetAsRef(Value: TOraRef);
 482    function GetAsArray: TOraArray;
 483    procedure SetAsArray(Value: TOraArray);
 484    function GetAsTable: TOraNestTable;
 485    procedure SetAsTable(Value: TOraNestTable);
 486    function GetAsTimeStamp: TOraTimeStamp;
 487    procedure SetAsTimeStamp(Value: TOraTimeStamp);
 488    function GetAsInterval: TOraInterval;
 489    procedure SetAsInterval(Value: TOraInterval);
 490    function GetAsNumber: TOraNumber;
 491    procedure SetAsNumber(Value: TOraNumber);
 492
 493    function GetItemAsDateTime(Index: integer): TDateTime;
 494    procedure SetItemAsDateTime(Index: integer; Value: TDateTime);
 495
 496    function GetItemAsFloat(Index: integer): double;
 497    procedure SetItemAsFloat(Index: integer; Value: double);
 498
 499    function GetItemAsInteger(Index: integer): integer;
 500    procedure SetItemAsInteger(Index: integer; Value: integer);
 501
 502    function GetItemAsString(Index: integer): string;
 503    procedure SetItemAsString(Index: integer; Value: string);
 504
 505    function GetItemAsTimeStamp(Index: integer): TOraTimeStamp;
 506    procedure SetItemAsTimeStamp(Index: integer; Value: TOraTimeStamp);
 507
 508    function GetItemAsInterval(Index: integer): TOraInterval;
 509    procedure SetItemAsInterval(Index: integer; Value: TOraInterval);
 510
 511    function GetItemAsVariant(Index: integer): variant;
 512    procedure SetItemAsVariant(Index: integer; Value: variant);
 513
 514    function GetItemAsObject(Index: integer): TSharedObject;
 515    procedure SetItemAsObject(Index: integer; Value: TSharedObject);
 516
 517    function GetItemIsNull(Index: integer): boolean;
 518
 519    procedure SetItemText(Index: integer; Value: string);
 520
 521  protected
 522    function IsObjectDataType(DataType: TFieldType): boolean; overload; override;
 523    function IsObjectDataType: boolean; overload;
 524    function IsBlobDataType: boolean; override;
 525{$IFNDEF CLR}
 526    function IsArray : boolean; virtual;
 527{$ENDIF}
 528    procedure SetDataType(Value: TFieldType); override;
 529
 530    function GetSize: integer; override;
 531
 532    function GetAsString: string; override;
 533    procedure SetAsString(Value: string); override;
 534    function GetAsInteger: integer; override;
 535    procedure SetAsInteger(Value: integer); override;
 536    function GetAsFloat: double; override;
 537    procedure SetAsFloat(Value: double); override;
 538    function GetAsVariant: variant; override;
 539    procedure SetAsVariant(const Value: variant); override;
 540  {$IFDEF VER6P}
 541    function GetAsSQLTimeStamp: TSQLTimeStamp; override;
 542    procedure SetAsSQLTimeStamp(const Value: TSQLTimeStamp); override;
 543  {$ENDIF}
 544    function GetIsNull: boolean; override;
 545
 546    procedure CreateObject; override;
 547    procedure DisconnectObject;
 548    procedure FreeItems;
 549
 550    property ParamObject;
 551  public
 552    constructor Create(Collection: TCollection); override;
 553    destructor Destroy; override;
 554
 555    procedure Clear; override;
 556    procedure ItemClear(Index: integer);
 557    procedure Assign(Source: TPersistent); override;
 558    procedure AssignFieldValue(Field: TField; const Value: Variant); override;
 559
 560    procedure SetBlobData(Buffer: IntPtr; Size: integer);
 561
 562    property AsCursor: TOraCursor read GetAsCursor write SetAsCursor;
 563    property AsOraBlob: TOraLob read GetAsOraBlob write SetAsOraBlob;
 564    property AsOraClob: TOraLob read GetAsOraClob write SetAsOraClob;
 565    property AsBFile: TOraFile read GetAsBFile write SetAsBFile;
 566    property AsObject: TOraObject read GetAsObject write SetAsObject;
 567    property AsXML: TOraXML read GetAsXML write SetAsXML;
 568    property AsRef: TOraRef read GetAsRef write SetAsRef;
 569    property AsArray: TOraArray read GetAsArray write SetAsArray;
 570    property AsTable: TOraNestTable read GetAsTable write SetAsTable;
 571    property AsTimeStamp: TOraTimeStamp read GetAsTimeStamp write SetAsTimeStamp;
 572    property AsInterval: TOraInterval read GetAsInterval write SetAsInterval;
 573    property AsNumber: TOraNumber read GetAsNumber write SetAsNumber;
 574
 575    property ItemAsDateTime[Index: integer]: TDateTime read GetItemAsDateTime write SetItemAsDateTime;
 576    property ItemAsFloat[Index: integer]: double read GetItemAsFloat write SetItemAsFloat;
 577    property ItemAsInteger[Index: integer]: integer read GetItemAsInteger write SetItemAsInteger;
 578    property ItemAsString[Index: integer]: string read GetItemAsString write SetItemAsString;
 579    property ItemValue[Index: integer]: variant read GetItemAsVariant write SetItemAsVariant;
 580    property ItemIsNull[Index: integer]: boolean read GetItemIsNull;
 581    property ItemText[Index: integer]: string read GetItemAsString write SetItemText;
 582    property ItemAsTimeStamp[Index: integer]: TOraTimeStamp read GetItemAsTimeStamp write SetItemAsTimeStamp;
 583    property ItemAsInterval[Index: integer]: TOraInterval read GetItemAsInterval write SetItemAsInterval;
 584
 585  // obsolette
 586    property AsBLOBLocator: TOraLob read GetAsOraBlob write SetAsOraBlob;
 587    property AsCLOBLocator: TOraLob read GetAsOraClob write SetAsOraClob;
 588
 589  published
 590    property National : boolean read GetNational write SetNational default False;
 591    property Table: boolean read GetTable write SetTable default False;
 592    property Length: integer read GetTableLength write SetTableLength default 1;
 593  end;
 594
 595{ TOraParams }
 596
 597  TOraParams = class (TDAParams)
 598  private
 599    FOwner: TPersistent;
 600
 601    procedure ReadBinaryData(Stream: TStream);
 602
 603    function GetItem(Index: integer): TOraParam;
 604    procedure SetItem(Index: integer; Value: TOraParam);
 605
 606  protected
 607    procedure Disconnect;
 608    procedure DefineProperties(Filer: TFiler); override;
 609
 610  public
 611    constructor Create(Owner: TPersistent);
 612
 613    function ParamByName(const Value: string): TOraParam;
 614    function FindParam(const Value: string): TOraParam;
 615    property Items[Index: integer]: TOraParam read GetItem write SetItem; default;
 616  end;
 617
 618{ TCursorField }
 619
 620  TCursorField = class (TField)
 621  private
 622    function GetAsCursor: TOraCursor;
 623  protected
 624    function GetValue(var Value: TOraCursor): boolean;
 625
 626  public
 627    constructor Create(Owner: TComponent); override;
 628
 629    property AsCursor: TOraCursor read GetAsCursor;
 630  end;
 631
 632{ TBFileField }
 633
 634  TBFileField = class (TBlobField)
 635  private
 636    FAutoRefresh: boolean;
 637
 638    function GetAsFile: TOraFile;
 639
 640    function GetBlobType: TBlobType;
 641    procedure SetBlobType(Value: TBlobType);
 642
 643    function GetFileDir: string;
 644    procedure SetFileDir(Value: string);
 645    function GetFileName: string;
 646    procedure SetFileName(Value: string);
 647    function GetExists: boolean;
 648
 649  protected
 650    function GetCanModify: boolean; override;
 651    function GetClassDesc: string; override;
 652    function GetValue(var Value: TOraFile): boolean;
 653    function GetIsNull: boolean; override;
 654
 655  public
 656    constructor Create(Owner: TComponent); override;
 657
 658    procedure Refresh;
 659
 660    property FileDir: string read GetFileDir write SetFileDir;
 661    property FileName: string read GetFileName write SetFileName;
 662    property Exists: boolean read GetExists;
 663
 664    property AsFile: TOraFile read GetAsFile;
 665
 666  published
 667    property BlobType: TBlobType read GetBlobType write SetBlobType;
 668    property AutoRefresh: boolean read FAutoRefresh write FAutoRefresh default True;
 669  end;
 670
 671{ TOraDataSetField }
 672
 673  TOraDataSetField = class (TDataSetField)
 674  private
 675    FModified: boolean;
 676
 677  protected
 678    procedure FreeBuffers; override;
 679    function GetAsString: string; override;
 680  public
 681    property Modified: boolean read FModified write FModified;
 682  end;
 683
 684{ TOraReferenceField }
 685
 686  TOraReferenceField = class (TReferenceField)
 687  private
 688    FModified: boolean;
 689
 690  protected
 691    procedure FreeBuffers; override;
 692    function GetAsString: string; override;
 693  public
 694    property Modified: boolean read FModified write FModified;
 695  end;
 696
 697{ TLabelField }
 698
 699  TLabelField = class (TField)
 700  protected
 701    function GetAsVariant: variant; override;
 702
 703  public
 704    constructor Create(Owner: TComponent); override;
 705  end;
 706
 707{ TOraTimeStampField }
 708
 709  TOraTimeStampField = class (TField)
 710  private
 711    FFormat: string;
 712
 713  protected
 714    function GetAsDateTime: TDateTime; override;
 715    procedure SetAsDateTime(Value: TDateTime); override;
 716    function GetAsString: string; override;
 717    procedure SetAsString(const Value: string); override;
 718    function GetAsVariant: variant; override;
 719    procedure SetVarValue(const Value: Variant); override;
 720  {$IFDEF VER6P}
 721    function {$IFDEF CLR}GetAsSqlTimeStamp{$ELSE}GetAsSQLTimeStamp{$ENDIF}: TSQLTimeStamp; override; // anti hint
 722    procedure SetAsSQLTimeStamp(const Value: TSQLTimeStamp); override;
 723  {$ENDIF}
 724    function GetAsTimeStamp: TOraTimeStamp;
 725
 726    procedure DefineProperties(Filer: TFiler); override;
 727    procedure ReadDataType(Reader: TReader);
 728    procedure WriteDataType(Writer: TWriter);
 729
 730    function GetIsNull: Boolean; override;
 731  public
 732    constructor Create(Owner: TComponent); override;
 733    property AsTimeStamp: TOraTimeStamp read GetAsTimeStamp;
 734    procedure SetFieldType(Value: TFieldType); override;
 735
 736  published
 737    property Format: string read FFormat write FFormat;
 738  end;
 739
 740{ TOraIntervalField }
 741
 742  TOraIntervalField = class (TField)
 743  private
 744    FLeadPrecision: integer;
 745    FFracPrecision: integer;
 746
 747  protected
 748    function GetAsString: string; override;
 749    procedure SetAsString(const Value: string); override;
 750    function GetAsVariant: variant; override;
 751    procedure SetVarValue(const Value: Variant); override;
 752    function GetAsInterval: TOraInterval;
 753
 754    procedure DefineProperties(Filer: TFiler); override;
 755    procedure ReadDataType(Reader: TReader);
 756    procedure WriteDataType(Writer: TWriter);
 757
 758    function GetIsNull: Boolean; override;
 759  public
 760    constructor Create(Owner: TComponent); override;
 761    procedure SetFieldType(Value: TFieldType); override;
 762    property AsInterval: TOraInterval read GetAsInterval;
 763
 764  published
 765    property LeadPrecision: integer read FLeadPrecision write FLeadPrecision default 2;
 766    property FracPrecision: integer read FFracPrecision write FFracPrecision default 6;
 767  end;
 768
 769{ TOraNumberField }
 770
 771  TOraNumberField = class (TNumericField)
 772  private
 773    function GetAsNumber: TOraNumber;
 774
 775  protected
 776    function GetAsVariant: variant; override;
 777    procedure SetVarValue(const Value: Variant); override;
 778    function GetAsString: string; override;
 779    procedure SetAsString(const Value: string); override;
 780    function GetAsInteger: integer; override;
 781    procedure SetAsInteger(Value: integer); override;
 782    function GetAsLargeInt: LargeInt;
 783    procedure SetAsLargeInt(Value: LargeInt);
 784    function GetAsFloat: double; override;
 785    procedure SetAsFloat(Value: double); override;
 786
 787    procedure DefineProperties(Filer: TFiler); override;
 788    procedure ReadDataType(Reader: TReader);
 789    procedure WriteDataType(Writer: TWriter);
 790
 791    function GetIsNull: Boolean; override;
 792
 793  public
 794    constructor Create(Owner: TComponent); override;
 795    function IsValidChar(InputChar: char): boolean; override;
 796
 797    property AsNumber: TOraNumber read GetAsNumber;
 798    property AsLargeInt: LargeInt read GetAsLargeInt write SetAsLargeInt;
 799  end;
 800
 801{ TOraXMLField }
 802
 803  TOraXMLField = class (TField)
 804  protected
 805    function GetAsString: string; override;
 806    procedure SetAsString(const Value: string); override;
 807    function GetAsVariant: variant; override;
 808    function GetAsXML: TOraXML;
 809    procedure GetText(var Text: string; DisplayText: Boolean); override;
 810    procedure SetText(const Value: string); override;
 811
 812    procedure DefineProperties(Filer: TFiler); override;
 813    procedure ReadDataType(Reader: TReader);
 814    procedure WriteDataType(Writer: TWriter);
 815
 816    function GetIsNull: Boolean; override;
 817    function GetClassDesc: string; override;
 818
 819  public
 820    constructor Create(Owner: TComponent); override;
 821    procedure Clear; override;
 822    class function IsBlob: Boolean; override;
 823    procedure SetFieldType(Value: TFieldType); override;
 824    property AsXML: TOraXML read GetAsXML;
 825  end;
 826
 827{ TOraDataSet }
 828
 829  TLockMode = (lmNone, lmLockImmediate, lmLockDelayed);
 830  TCheckMode = (cmNone, cmException, cmRefresh);
 831
 832  TRefreshMode = (rmNone, rmAfterInsert, rmAfterUpdate, rmAlways); // obsolete
 833
 834  // obsolete
 835  // new options should not be added to TOraDataSetOptionsDS
 836  TOraDataSetOptionsDS = class (TDADataSetOptions)
 837  private
 838    FAutoClose: boolean;
 839    FFieldsOrigin: boolean;
 840    FDefaultValues: boolean;
 841    FFieldsAsString: boolean;
 842    FDeferredLobRead: boolean;
 843    FCacheLobs: boolean;
 844    FScrollableCursor: boolean;
 845    FRawAsString: boolean;
 846
 847    function GetKeepPrepared: Boolean;
 848    procedure SetKeepPrepared(Value: boolean);
 849    procedure SetAutoClose(Value: boolean);
 850    procedure SetFieldsAsString(Value: boolean);
 851    procedure SetDeferredLobRead(Value: boolean);
 852    procedure SetCacheLobs(Value: boolean);
 853    procedure SetScrollableCursor(Value: boolean);
 854    procedure SetRawAsString(Value: boolean);
 855
 856  protected
 857    procedure AssignTo(Dest: TPersistent); override;
 858  public
 859    constructor Create(Owner: TCustomDADataSet);
 860
 861  published
 862    property KeepPrepared: boolean read GetKeepPrepared write SetKeepPrepared stored False;
 863    property AutoClose: boolean read FAutoClose write SetAutoClose stored False default False;
 864    property FieldsOrigin: boolean read FFieldsOrigin write FFieldsOrigin stored False default False;
 865    property DefaultValues: boolean read FDefaultValues write FDefaultValues stored False default False;
 866    property FieldsAsString: boolean read FFieldsAsString write SetFieldsAsString stored False default False;
 867    property DeferredLobRead: boolean read FDeferredLobRead write SetDeferredLobRead stored False default False;
 868    property CacheLobs: boolean read FCacheLobs write SetCacheLobs stored False default True;
 869    property ScrollableCursor: boolean read FScrollableCursor write SetScrollableCursor stored False default False;
 870    property RawAsString: boolean read FRawAsString write SetRawAsString stored False default False;
 871
 872    property RequiredFields stored False;
 873    property StrictUpdate stored False;
 874    property NumberRange stored False;
 875    property QueryRecCount stored False;
 876    property AutoPrepare stored False;
 877    property ReturnParams stored False;
 878    property TrimFixedChar stored False;
 879    property LongStrings stored False;
 880    property RemoveOnRefresh stored False;
 881    property FlatBuffers stored False;
 882    property DetailDelay stored False;
 883  end;
 884
 885  TOraDataSetOptions = class(TOraDataSetOptionsDS)
 886  private
 887    FTemporaryLobUpdate: boolean;
 888    FExtenededFieldsInfo: boolean;
 889    FReflectChangeNotify: boolean;
 890    FStatementCache: boolean;
 891
 892    procedure SetTemporaryLobUpdate(Value: boolean);
 893    procedure SetExtendedFieldsInfo(Value: boolean);
 894    procedure SetStatementCache(Value: boolean);
 895
 896  protected
 897    procedure AssignTo(Dest: TPersistent); override;
 898
 899  published
 900    property AutoClose stored True;
 901    property FieldsOrigin stored True;
 902    property DefaultValues stored True;
 903    property FieldsAsString stored True;
 904    property DeferredLobRead stored True;
 905    property CacheLobs stored True;
 906    property ScrollableCursor stored True;
 907    property RawAsString stored True;
 908
 909    property RequiredFields stored True;
 910    property StrictUpdate stored True;
 911    property NumberRange stored True;
 912    property QueryRecCount stored True;
 913    property AutoPrepare stored True;
 914    property ReturnParams stored True;
 915    property TrimFixedChar stored True;
 916    property LongStrings stored True;
 917    property RemoveOnRefresh stored True;
 918    property FlatBuffers stored True;
 919    property DetailDelay stored True;
 920
 921    property TemporaryLobUpdate: boolean read FTemporaryLobUpdate write SetTemporaryLobUpdate default False;
 922    property ExtendedFieldsInfo: boolean read FExtenededFieldsInfo write SetExtendedFieldsInfo default False;
 923    property ReflectChangeNotify: boolean read FReflectChangeNotify write FReflectChangeNotify default False;
 924    property StatementCache: boolean read FStatementCache write SetStatementCache default False;
 925
 926    property SetFieldsReadOnly;
 927    property LocalMasterDetail;
 928    property CacheCalcFields;
 929    property FullRefresh;
 930  {$IFDEF HAVE_COMPRESS}
 931    property CompressBlobMode;
 932  {$ENDIF}
 933    property UpdateBatchSize;
 934    property UpdateAllFields;
 935  end;
 936
 937  TSequenceMode = (smInsert, smPost);
 938
 939  TFieldsInfoType = set of (ftFieldOrigin, ftDefaultValues);
 940
 941  TOraSQLGenerator = class(TDASQLGenerator)
 942  private
 943    FSeqReturning: boolean;
 944    FSeqFieldDesc: TCRFieldDesc;
 945  protected
 946    FReturnSB,
 947    FIntoSB: StringBuilder;
 948
 949    function IsBlobDataType(DataType: word): boolean; override;
 950    function FieldIsNull(FieldDesc: TCRFieldDesc; OldValue: boolean; Data: TData; OldRecBuf, NewRecBuf: IntPtr): boolean; override;
 951    function FieldModified(FieldDesc: TCRFieldDesc): boolean; override;
 952
 953    function GenerateIndexName(Name: string): string; override;
 954
 955    function IsSubstituteParamName: boolean; override;
 956    procedure AddParam(SB: StringBuilder; FieldDesc: TFieldDesc; const StatementType: TStatementType; Index: integer = -1; Old: boolean = False); override;
 957
 958    procedure AddFieldToInsertSQL(FieldDesc: TCRFieldDesc; const Index: integer = -1); override;
 959
 960    procedure AddFieldToUpdateSQL(FieldDesc: TCRFieldDesc;
 961      const ModifiedFieldsOnly: boolean;
 962      const Index: integer = -1); override;
 963
 964    procedure GenerateInsertSQL(
 965      const KeyAndDataFields: TKeyAndDataFields;
 966      const ModifiedFieldsOnly: boolean;
 967      const Index: integer = -1); override;
 968
 969    procedure GenerateUpdateSQL(
 970      const KeyAndDataFields: TKeyAndDataFields;
 971      const ModifiedFieldsOnly: boolean;
 972      const Index: integer = -1); override;
 973
 974    procedure GenerateRefreshSQL(
 975      const KeyAndDataFields: TKeyAndDataFields;
 976      const ModifiedFieldsOnly: boolean); override;
 977
 978    procedure GenerateLockSQL(
 979      const KeyAndDataFields: TKeyAndDataFields;
 980      const Index: integer = -1); override;
 981  public
 982    function GenerateSQL(const StatementType: TStatementType;
 983      const ModifiedFieldsOnly: boolean;
 984      Params: TDAParams;
 985      const Index: Integer = -1): string; override;
 986  end;
 987
 988{$IFNDEF STD}
 989{$IFDEF MSWINDOWS}
 990{ TOraChangeNotification }
 991
 992  TOraChangeNotificationEvent = procedure(Sender: TObject; NotifyType: TChangeNotifyEventType;
 993    TableChanges: TNotifyTableChanges) of object;
 994
 995  TOraChangeNotification = class(TComponent)
 996  private
 997    FSession: TOraSession; // used to remove registration in destructor
 998    FEnabled: boolean;
 999    FPersistent: boolean;
1000    FTimeOut: integer;
1001    FOperations: TChangeNotifyDMLOperations;
1002    FDatasets: TDAList;
1003    FOnChange: TOraChangeNotificationEvent;
1004
1005    procedure SetSession(Value: TOraSession);
1006    procedure SetEnabled(Value: boolean);
1007    procedure SetPersistent(Value: boolean);
1008    procedure SetTimeOut(Value: integer);
1009    procedure SetOperations(Value: TChangeNotifyDMLOperations);
1010    function GetActive: boolean;
1011    function GetPort: integer;
1012    procedure SetPort(Value: integer);
1013
1014  protected
1015    FIChangeNotification: TOCIChangeNotification;
1016
1017    function UsedConnection(Session: TOraSession): TOraSession;
1018    procedure BeginConnection(Session: TOraSession);
1019    procedure EndConnection(Session: TOraSession);
1020    procedure DoOnChange(NotifyType: TChangeNotifyEventType;
1021      TableChanges: TNotifyTableChanges);
1022
1023    property Session: TOraSession read FSession write SetSession;
1024
1025  public
1026    constructor Create(AOwner: TComponent); override;
1027    destructor Destroy; override;
1028
1029    procedure RemoveRegistration(Session: TOraSession);
1030
1031    property Active: boolean read GetActive;
1032    property Port: integer read GetPort write SetPort;
1033
1034  published
1035    property Enabled: boolean read FEnabled write SetEnabled default True;
1036    property Persistent: boolean read FPersistent write SetPersistent default False;
1037    property TimeOut: integer read FTimeOut write SetTimeOut default 0;
1038    property Operations: TChangeNotifyDMLOperations read FOperations write SetOperations
1039      default [cnoInsert, cnoUpdate, cnoDelete];
1040
1041    property OnChange: TOraChangeNotificationEvent read FOnChange write FOnChange;
1042  end;
1043{$ENDIF}
1044{$ENDIF}
1045
1046  TOraDataSet = class (TCustomDADataSet)
1047  private
1048    FLockMode: TLockMode;
1049    FCheckMode: TCheckMode;
1050    FStreamedActive: boolean;
1051    FKeySequence: string;
1052    FKeyFields: string;
1053    FSequenceMode: TSequenceMode;
1054    FDMLRefresh: boolean;
1055    FIsUpdatingFields: boolean;
1056  {$IFNDEF STD}
1057  {$IFDEF MSWINDOWS}
1058    FChangeNotification: TOraChangeNotification;
1059  {$ENDIF}
1060  {$ENDIF}
1061
1062  {$IFDEF WIN32}
1063    FProvIntf: IProvider;
1064  {$ENDIF}
1065    FFieldsInfoRequested: boolean; // Is needed to avoid second execution of GetFieldsInfo
1066
1067    function GetSession: TOraSession;
1068    procedure SetSession(Value: TOraSession);
1069    function GetParams: TOraParams;
1070    procedure SetParams(Value: TOraParams);
1071    procedure SetNonBlocking(Value: boolean);
1072    function GetRowsProcessed: integer;
1073    function GetIsPLSQL: boolean;
1074    function GetSQLType: integer;
1075    function GetCursor: TOraCursor;
1076    function GetOptions: TOraDataSetOptions;
1077    procedure SetCursor(Value: TOraCursor);
1078    procedure SetOptions(Value: TOraDataSetOptions);
1079    procedure SetKeySequence(Value: string);
1080    procedure SetSequenceMode(const Value: TSequenceMode);
1081  {$IFNDEF STD}
1082  {$IFDEF MSWINDOWS}
1083    procedure SetChangeNotification(Value: TOraChangeNotification);
1084  {$ENDIF}
1085  {$ENDIF}
1086
1087  // obsolete
1088    function GetStrictUpdate: boolean;
1089    procedure SetStrictUpdate(Value: boolean);
1090    function GetReturnParams: boolean;
1091    procedure SetReturnParams(Value: boolean);
1092    function GetRefreshMode: TRefreshMode;
1093    procedure SetRefreshMode(Value: TRefreshMode);
1094    function GetOptionsDS: TOraDataSetOptionsDS;
1095    procedure SetOptionsDS(Value: TOraDataSetOptionsDS);
1096
1097 {$IFDEF WIN32}
1098    function GetProvider: IProvider;
1099 {$ENDIF}
1100
1101  protected
1102  { IProviderSupport }
1103    function PreventPSKeyFields(var PSKeyFields: string): boolean; override;  
1104    function PSGetKeyFields: string; override;
1105    function PSGetDefaultOrder: TIndexDef; override;
1106
1107    procedure CheckInactive; override;
1108
1109  protected
1110    FIRecordSet: TOCIRecordSet;
1111    FICommand: TOCICommand;
1112
1113    FHideRowidField: boolean;
1114//  FRowIdField: TField;
1115    FKeyFieldArray: TFieldArray;
1116
1117    procedure CreateIRecordSet; override;
1118    procedure SetIRecordSet(Value: TData{TRecordSet}); override;
1119
1120    procedure CreateCommand; override;
1121
1122    function CreateOptions: TDADataSetOptions; override;
1123
1124    procedure Loaded; override;
1125
1126    function UsedConnection: TCustomDAConnection; override;
1127    procedure Disconnect; override;
1128
1129  { Open/Close }
1130    function IsNeedEditPreconnect: boolean; override;
1131    function IsNeedInsertPreconnect: boolean; override;
1132    function IsPreconnected : boolean; override;
1133
1134  { TablesInfo }
1135    procedure DetectIdentityField; override;
1136
1137    procedure OpenCursor(InfoQuery: boolean); override;
1138    procedure CloseCursor; override;
1139
1140    procedure InternalExecute; override;
1141    function GetRecCount: longint; override;
1142    procedure GetFieldsInfo(FieldsInfoType: TFieldsInfoType); overload;
1143    procedure GetFieldsInfo(); overload;
1144    procedure CheckFieldCompatibility(Field: TField; FieldDef: TFieldDef); override;
1145
1146    procedure DoAfterOpen; override;
1147    procedure DoAfterScroll; override;
1148
1149  { Fields }
1150    function GetFieldClass(FieldType: TFieldType): TFieldClass; override;
1151    function GetFieldType(DataType: word): TFieldType; override;
1152    function IsKeyFields: boolean;
1153    function IsUpdatingFields: boolean;
1154
1155  { Edit }
1156    procedure CreateSQLGenerator; override;
1157
1158    procedure InitRecord(Buffer: TRecordBuffer); override;
1159
1160    function PerformDelete: boolean; override;
1161    function PerformUpdate: boolean; override;
1162
1163    procedure InternalLock; virtual;
1164
1165    procedure CheckUpdateQuery(const StatementType: TStatementType); override;
1166    procedure UpdateExecute(const StatementTypes: TStatementTypes); override;
1167    procedure CheckUpdateSQL(const SQL: string; const StatementTypes: TStatementTypes; out ParamsInfo: TDAParamsInfo); override;
1168    function PerformSQL(const SQL: string; const StatementTypes: TStatementTypes): boolean; override;
1169    function PrepareBatch(SQL: string): string; override;
1170    function RefreshAfterInsertAllowed: boolean; override;
1171
1172    function ShouldPrepareUpdateSQL: boolean; override;
1173
1174    procedure SetDefaultExpressionValue(Field: TField); override;
1175    procedure AssignFieldValue(Param: TDAParam; Field: TField; Old: boolean); override;
1176    procedure GetIdentityField; override;
1177    function GetSavepointName: string;
1178
1179    procedure AssignTo(Dest: TPersistent); override;
1180
1181    procedure SetActive(Value: boolean); override;
1182
1183    procedure SetKeyFields(Value: string); virtual;
1184
1185    function UseAllFields(ForceUseAllKeyFields: boolean): boolean; virtual;
1186    procedure GetKeyAndDataFields(
1187                out KeyAndDataFields: TKeyAndDataFields;
1188                const ForceUseAllKeyFields: boolean); override;
1189    procedure FillKeyFieldArray(const Value: string);
1190
1191    function NeedReturnParams: boolean; override;
1192
1193  { Master/Detail}
1194    function NeedDetailRefresh(Param: TDAParam; FieldValue: TSharedObject): boolean; override;
1195
1196  { Filter/Find/Locate }
1197    procedure CopyFieldValue(const Value: variant; out ValuePtr: IntPtr; out ValueType: integer; FieldDesc: TFieldDesc); override;
1198
1199  { KeySequence }
1200    procedure InternalOpen; override;
1201    procedure InternalClose; override;
1202    procedure GetSequenceNextVal;
1203    procedure InternalInsert; override;
1204
1205    procedure InternalCreateProcCall(Name: string; Overload: integer; NeedDescribe: boolean);
1206
1207  { SQL modify }
1208    function SQLAddWhere(SQLText, Condition: string): string; override;
1209    function SQLDeleteWhere(SQLText: string): string; override;
1210    function SQLSetOrderBy(SQLText: string; Fields: string): string; override;
1211    function SQLGetOrderBy(SQLText: string): string; override;
1212
1213    procedure SetModified(Value: Boolean);
1214    function GetActiveRecBuf(var RecBuf: TRecordBuffer): boolean;
1215    function GetData: TData;
1216
1217  {$IFDEF MSWINDOWS}
1218    procedure ReflectChanges(TableChanges: TNotifyTableChanges);
1219  {$ENDIF}
1220
1221  { XML }
1222    procedure WriteFieldXMLDataType(Field: TField; FieldDesc: TFieldDesc; const FieldAlias: string;
1223      XMLWriter: XMLTextWriter); override;
1224    function GetFieldXMLValue(Field: TField; FieldDesc: TFieldDesc): string; override;
1225
1226    function GetUpdateObject: TOraUpdateSQL;
1227    procedure SetUpdateObject(Value: TOraUpdateSQL);
1228
1229    property IdentityField;
1230  public
1231    constructor Create(Owner: TComponent); override;
1232    destructor Destroy; override;
1233
1234  { Open/Close }
1235    procedure BreakExec;
1236
1237    function Fetched: boolean; override;
1238    function ErrorOffset: integer;
1239    procedure GetErrorPos(var Row,Col: integer);
1240
1241  { Edit }
1242    procedure Lock;
1243    procedure Unlock;
1244
1245    procedure CreateProcCall(Name: string; Overload: integer = 0);
1246    function GetKeyList(TableName: string; List: TStrings): string;
1247
1248    function FindParam(const Value: string): TOraParam;
1249    function ParamByName(const Value: string): TOraParam;
1250
1251    function CreateBlobStream(Field: TField; Mode: TBlobStreamMode): TStream; override;
1252
1253  { Additional data types }
1254    function GetLob(const FieldName: string): TOraLob;
1255    function GetFile(const FieldName: string): TOraFile;
1256  {$HPPEMIT '#ifdef GetObject'}
1257  {$HPPEMIT '#undef GetObject'}
1258  {$HPPEMIT '#endif'}
1259    function GetObject(const FieldName: string): TOraObject;
1260    function GetRef(const FieldName: string): TOraRef;
1261    function GetArray(const FieldName: string): TOraArray;
1262    function GetTable(const FieldName: string): TOraNestTable;
1263    function GetTimeStamp(const FieldName: string): TOraTimeStamp;
1264    function GetInterval(const FieldName: string): TOraInterval;
1265    function GetNumber(const FieldName: string): TOraNumber;
1266
1267    function GetLobLocator(const FieldName: string): TOraLob; // obsolete
1268
1269    property Session: TOraSession read GetSession write SetSession;
1270    property Params: TOraParams read GetParams write SetParams stored False;
1271    property NonBlocking: boolean read FNonBlocking write SetNonBlocking default False;
1272    property RowsProcessed: integer read GetRowsProcessed;
1273    property IsQuery: boolean read GetIsQuery;
1274    property IsPLSQL: boolean read GetIsPLSQL;
1275    property SQLType: integer read GetSQLType;
1276    property Cursor: TOraCursor read GetCursor write SetCursor;
1277    property LockMode: TLockMode read FLockMode write FLockMode;
1278    property CheckMode: TCheckMode read FCheckMode write FCheckMode;
1279    property Options: TOraDataSetOptions read GetOptions write SetOptions;
1280    property KeyFields: string read FKeyFields write SetKeyFields;
1281    property KeySequence: string read FKeySequence write SetKeySequence;
1282    property SequenceMode: TSequenceMode read FSequenceMode write SetSequenceMode default smPost;
1283  {$IFNDEF STD}
1284  {$IFDEF MSWINDOWS}
1285    property ChangeNotification: TOraChangeNotification read FChangeNotification write SetChangeNotification;
1286  {$ENDIF}
1287  {$ENDIF}
1288
1289  // obsolete
1290    property RefreshMode: TRefreshMode read GetRefreshMode write SetRefreshMode stored False;
1291    property DMLRefresh: boolean read FDMLRefresh write FDMLRefresh default False;
1292    property StrictUpdate: boolean read GetStrictUpdate write SetStrictUpdate stored False;
1293    property LocalConstraints stored False;
1294    property ReturnParams: boolean read GetReturnParams write SetReturnParams stored False;
1295    property OptionsDS: TOraDataSetOptionsDS read GetOptionsDS write SetOptionsDS stored False; // is Options
1296    property AutoCommit;
1297
1298  {$IFDEF WIN32}
1299    property Provider: IProvider read GetProvider;
1300  {$ENDIF}
1301    property UpdateObject: TOraUpdateSQL read GetUpdateObject write SetUpdateObject;
1302  end;
1303
1304{ TBFileStream }
1305  TBFileStream = class(TBlobStream)
1306  public
1307    constructor Create(Field: TBlobField; Mode: TBlobStreamMode);
1308    destructor Destroy; override;
1309  end;
1310
1311{ TOraNestedTable }
1312
1313  TOraNestedTable = class (TMemDataSet)
1314  private
1315    function GetTable: TOraNestTable;
1316    procedure SetTable(Value: TOraNestTable);
1317    function GetRef: TOraRef;
1318    procedure SetRef(Value: TOraRef);
1319
1320  protected
1321    procedure CreateIRecordSet; override;
1322
1323  { Open/Close }
1324    procedure OpenCursor(InfoQuery: boolean); override;
1325    procedure CloseCursor; override;
1326
1327    procedure CreateFieldDefs; override;
1328
1329    procedure DoAfterPost; override;
1330    procedure DoBeforeInsert; override;
1331    procedure DoBeforeDelete; override;
1332
1333    function GetCanModify: boolean; override;
1334    procedure SetDataSetField(const Value: TDataSetField); override;
1335
1336  {$IFDEF CLR}
1337    procedure DataEvent(Event: TDataEvent; Info: TObject); override;
1338  {$ELSE}
1339    procedure DataEvent(Event: TDataEvent; Info: longint); override;
1340  {$ENDIF}
1341
1342  { Fields }
1343    function GetFieldClass(FieldType: TFieldType): TFieldClass; override;
1344    function GetFieldType(DataType: word): TFieldType; override;
1345
1346  public
1347    constructor Create(Owner: TComponent); override;
1348
1349    function GetObject(const FieldName: string): TOraObject;
1350
1351    property Table: TOraNestTable read GetTable write SetTable;
1352    property Ref: TOraRef read GetRef write SetRef;
1353
1354  published
1355    property DataSetField;
1356
1357    property Active;
1358    property AutoCalcFields;
1359    property Filtered;
1360    property Filter;
1361    property FilterOptions;
1362    property IndexFieldNames;
1363    property ObjectView default True;
1364
1365    property BeforeOpen;
1366    property AfterOpen;
1367    property BeforeClose;
1368    property AfterClose;
1369    property BeforeInsert;
1370    property AfterInsert;
1371    property BeforeEdit;
1372    property AfterEdit;
1373    property BeforePost;
1374    property AfterPost;
1375    property BeforeCancel;
1376    property AfterCancel;
1377    pro…

Large files files are truncated, but you can click here to view the full file