谁有DOA控件的使用说明,介绍什么的?

解决方案 »

  1.   

    Direct Oracle Access
    VERSION 3.3, 六月 1999
    如果你使用DELPHI 或者C++ BULIDER 读取ORACLE数据库, DOA 套件可以给你提供许多方便. 使用DOA 你可以直接读取ORACLE数据库,不需要通过BDEEngine,只需要SQL*Net. 这一点有下面几个优点:
    w 无须分发和安装BDE . 可以使用任何版本的 Delphi or C++Builder开发 Client/Server 程序
    w 不经BDE查询速度会快五倍以上;
    w 自动实现Master/Detail 结构
    w 自动在客户端强制实现server-constraints
    w 使用SERVER端产生值(默认值, 触发器来改变列值)
    w Query By Example方式无须编程即可形成高效的查询。
    w 使用 PL/SQL blocks 实现服务器端的逻辑。
    w 使用array DML 会提高批处理的性能
    w 使用ToraclePackage组件更容易存取包
    w 封装了ORACLE 的系统包 (dbms_alert, dbms_job, utl_file, ...)
    w 支持许多ORACLE特性 (Savepoints, SQLTrace, SetTransaction, ...)
    w 兼容 SQL*Net 1 到 Net8, Personal Oracle Lite 到 Oracle8
    w 可以使用ORACLE中的 LOB's 和 Objects
    组件概况
    Direct Oracle Access由下列组件构成::
    w 使用TOracleSession组件连接Oracle数据库和控制事物. 可以同时使用多个ToracleSession存取不同的数据库. 
    w TOracleLogon组件可以通过一个标准登录对话框让用户为一个ToracleSession组件指定用户名, 密码和数据库。
    w ToracleQuery可以执行任何的SQL语句和PL/SQL块. 它直接调用 SQL*Net是一个非常低层的组件。应在不需要使用data-aware控件浏览查询结果使用ToracleQuery.
    w ToraclePackage为访问ORACLE的包中的函数, 过程, 变量和常数提供了一个方便的接口 。
    w TOracleEvent允许你的应用程序通过一个后台执行的线程对dbms_alert信号和dbms_pipe 消息作出反应。
    w ToracleDataSet为数据感知控件提供数据. 它使用TOracleQuery 检索和更改数据库。
    w ToracleNavigator是一个与TDBNavigator相似的控件.它为QBE方式提供附加的按纽。
    w TOracleProvider 是一个与TProvider相似的控件,通过它可以使用Direct Oracle Access控件建立多层应用.
    为了支持ORACLE8复杂的数据类型, Direct Oracle Access 提供的几个对象封装了LOB Locator (TLOBLocator), Object (TOracleObject) and Reference (TOracleReference). 最后的两个对象只存在与Direct Oracle Access 的Object version中。
    单元 概况
    w Oracle 包括TOracleSession, TOracleLogon, TOracleQuery, TOraclePackage, TOracleEvent, TLOBLocator, TOracleObject and TOracleReference
    w OracleData 包括 TOracleDataSet 
    w OracleNavigator 包括 TOracleNavigator
    w OracleProvider 包括TOracleProvide
    w OracleCI OCI接口
    安装
    安装Direct Oracle Access 控件包 运行setup.exe安装设计时包, 单元和帮助. 
    安装 TOraclewwDataSet for Delphi
    如果你有Woll2Woll's InfoPower 3.01 或更高版本, 你可以安装TOraclwwDataSet 以便使 InfoPower 可以使用Direct Oracle Access. 
    安装 the ToracleProvideR  for Delphi 4 or 5
    如果你使用Delphi 4 or 5的 Client/Server or Enterprise 版, 可以安装TOracleProvider 用Direct Oracle Access来创建多层应用。
    示例
    在 Demos 目录中,包含下列示例
    QueryGrid 允许用户使用任何的SQL语句并可以在一个GRID中观察结果.
    DeptGrid 在grid中查询和修改 dept 表.
    LongRaw 读写long raw 类型.
    ThreadDemo 多线程
    ObjectGrid 操纵 persistent 对象.( Oracle8)
    DeptEmp master/detail 示例。
    PictureDemo Blob 字段示例.
    3Tier Client/Server3层应用.
    PkgApply 使用存储包来为一个DATASET检索数据和实现更新。
     
    TOracleSession 组件
    Unit
    Oracle
    描述
    ToracleSession用来连接数据库,在设好Logon 属性后 (LogonUsername, LogonPassword 和LogonDatabase), 可以使用 LogOn 方法或设置Connected属性为True即可连接数据库.如果想让最终用户来指定 这些logon 属性, 只需使用ToracleLogon组件。
    ToracleSession相当于一个Oracle 数据库session, 因此他需要对事务进行控制. Commit 和 Rollback 方法 用于基本的事务控制,也可以使用 Savepoint 和 RollbackToSavepoint方法来实现更加精确的事务管理. SetTransaction 方法 和 IsolationLevel属性影响其他SESSION改变的数据在本SESSION中的可见性.
    你可以设置它的属性来改变它所控制的其他数据库控件的默认行为。 NullValue 属性表示空值如何返回, Preferences属性包括许多其他的设置.
    比较特殊的情况时使用多线程和动态连接库,分别在各自的部分讨论。
    ToracleSession同时为大多数ORACLE标准包(dbms_alert, dbms_application_info, dbms_job, dbms_output, dbms_pipe and utl_file)提供了一个方便的接口。可以通过封装了这些包的属性来调用在这些标准包中的函数与过程
    示例 –登录
    登录数据库, 需要设置LogonUsername, LogonPassword 和(可选) LogonDatabase属性。然后调用LogOn 方法. 如下面的代码:
    with MySession do
    try
      LogonUsername := 'scott';
      LogonPassword := 'tiger';
      LogonDatabase := 'chicago';
      LogOn;
      ShowMessage('Logged on successfully.');
    except
      on E:EOracleError do ShowMessage(E.Message);
    end;可以用TOracleLogon.Execute函数来代替TOracleSession.LogOn,它控制登录对话框, 允许用户键入另外的username, password 、 database. 如果用户按下CANEL按纽函数返回FALSE, 使用这个函数以后可以用Connected属性来判断登录成功与否。最典型的用法是在emain form 的OnCreate事件中使用下列代码:
    procedure TMainForm.FormCreate(Sender: TObject);
    begin
      MainLogon.Execute;
      if not MainSession.Connected then Halt;
    end;第一次登录会搜寻加载和初始化OCI  DLL (如ora73.dll, ora804.dll 或 oci.dll).如果SQL*Net or Net8 没有正确安装, 可以看到一些带有详细描述的异常。 
    TOracleSession 参考
    这一部分详细阐述TOracleSession所有的属性、方法、事件。TOracleSession.AfterLogOn
    Declaration
    type TOracleSessionEvent = procedure(Sender: TOracleSession) of Object;
    property AfterLogOn: TOracleSessionEvent;
    Description
    这一事件在LOGON发生后调用。.
    See also
    BeforeLogOnTOracleSession.ApplyUpdates
    Declaration
    procedure ApplyUpdates(const DataSets: array of TOracleDataSet; Commit: Boolean);
    Description
    提交缓存更新,如果数据集是 master/detail 关系, 所有的detail dataset同时提交。每一个数据集的CachedUpdates 属性必须设为TRUE.
    如果Commit 参数是True更改会被提交。 如果是False更改不会被提交,可以在调用CommitUpdates or Rollback 之前执行一些附加的行动。
    procedure TDeptForm.ApplyButtonClick(Sender: TObject);
    begin
      // Apply the changes and do not yet commit
      Session.ApplyUpdates([DeptDataSet], False);
      // Perform some checks and commit or rollback accordingly
      if DeptEmpValid then
        Session.CommitUpdates([DeptDataSet])
      else
        Session.Rollback;
    end;
    See also
    CancelUpdates
    CommitUpdates
    TOracleSession.AutoCommit
    Declaration
    property AutoCommit: Boolean;
    Description
    如为true, 每一个update, insert 或 delete 语句会自动提交。在存储过程和PL/SQL块中的更改不能自动提交。a
    WARNING
    T这一属性是含糊的,在以后的版本中将不存在。
    See also
    Commit
    Rollback
    Savepoint
    RollbackToSavepointTOracleSession.BeforeLogOn
    Declaration
    type TOracleSessionEvent = procedure(Sender: TOracleSession) of Object;
    property BeforeLogOn: TOracleSessionEvent;
    Description
    在LogOn之前调用. 如果希望见到 "logging on..." 对话框,可以使用这个事件来触发它。.
    See also
    AfterLogOnTOracleSession.BreakExecution
    Declaration
    procedure BreakExecution;
    Description
    停止当前运行的查询,结果是出现 "ORA-01013, user requested cancel of current operation"的消息.可以用于放弃多线程中耗时长久的查询.TOracleSession.CancelUpdates
    Declaration
    procedure CancelUpdates(const DataSets: array of TOracleDataSet);
    Description
    通过清除改动记录文件来取消对数据库的改动,如果数据集在master/detail关系中是master, detail数据集同时取消,如果每一个数据集的CachedUpdates属性设为True.
    See also
    ApplyUpdates
    CommitUpdatesTOracleSession.CheckConnection
    Declaration
    function CheckConnection(Reconnect: Boolean): TCheckConnectionResult;
    type TCheckConnectionResult = (ccOK, ccError, ccReconnected);
    Description
      

  2.   

    当服务器关机时、数据库已经关闭、网络出现故障、数据库线程被关闭, TOracleSession 这时也会关闭,为检查这种情况和重新连接session,应使用CheckConnection函数. 结果会是下列中的之一:
    ccOK 连接正常.
    ccError 连接出错.
    ccReconnected 连接出错,但重新连接成功.
    使用Reconnect参数来决定发生错误时是否重新连接。注意所有的TOracleDataSet 和TOracleQuery 控件在重新连接后会关闭,有时应使用附加的程序来控制这种情况。TOracleSession.Commit
    Declaration
    procedure Commit;
    Description
    提交当前事务。.
    See also
    Rollback
    Savepoint
    RollbackToSavepoint
    AutoCommitTOracleSession.CommitUpdates
    Declaration
    procedure CommitUpdates(const DataSets: array of TOracleDataSet);
    Description
    ApplyUpdates提交缓存更新,设Commit参数为False。当前数据库事务会被提交,数据集的改动记录也会被清空。如果数据集是master/detail关系中master。Detail数据集的改动同时提交. 每一个数据集的CACHE UPDATE设为TRUE。
    See also
    ApplyUpdates
    CancelUpdatesTOracleSession.Connected
    Declaration
    property Connected: Boolean;
    Description
    显示是否连接数据库。设置这个属性等于调用LogOn 或 LogOff,但它允许在设计时建立连接。
    See also
    LogOn
    LogOff
    RollbackOnDiconnect
    LogonUsername
    LogonPassword
    LogonDatabase
    TOracleLogonTOracleSession.Cursor
    Declaration
    property Cursor: TCursor;
    Description
    允许在 SQL*Net 初始化、登录、或者属性值需要存取数据库时改变鼠标指针的形状。.TOracleSession.DBMS_Alert
    Declaration
    TDBMS_Alert = class(TDBMSPackage)
     procedure Set_Defaults(const Sensitivity: Integer);
     procedure Register(const Name: string);
     procedure Remove(const Name: string);
     procedure RemoveAll;
     procedure WaitAny(out Name: string; out Message: string; out Status: Integer; const TimeOut: Integer);
     procedure WaitOne(const Name: string; out Message: string; out Status: Integer; const TimeOut: Integer);
     procedure Signal(const Name: string; const Message: string);
    end;
    property DBMS_Alert: TDBMS_Alert;
    Description
    dbms_alert 包提供数据库事件异步通告支持.。为等待后台线程事件,可以使用ToracleEvent控件代替. 这个包的详细信息在Server Application Developer's Guide中。
    下面是dbms_alert包中定义的常数:
    wsAlert 等待状态: 警报已发生
    wsTimeOut 等待状态: 超时
    下面演示警报信号'SP'发出消息'EXIT' 并提交:
    with MainSession do
    begin
      DBMS_Alert.Signal('SP', 'EXIT');
      Commit;
    end;TOracleSession.DBMS_Application_Info
    Declaration
    TDBMS_Application_Info = class(TDBMSPackage)
     procedure Set_Module(const Module_Name: string; const Action_Name: string);
     procedure Set_Action(const Action_Name: string);
     procedure Read_Module(out Module_Name: string; out Action_Name: string);
     procedure Set_Client_Info(const Client_Info: string);
     procedure Read_Client_Info(out Client_Info: string);
    end;
    property DBMS_Application_Info: TDBMS_Application_Info;
    Description
    dbms_appilication_info(// 包用于Oracle Trace和SQL跟踪工具记录执行模块的名称或者记录不同模块性能表现的数据库事务. 这个包的详细信息在Server Tuning Guide.
    下列事例在main form的OnCreate事件中使用Set_Client_Info过程。程序标题出现在这个SESSION的v$session表中.
    procedure TMainForm.FormCreate(Sender: TObject);
    begin
      with MainSession do
      begin
        Connected := True;
        DBMS_Application_Info.Set_Client_Info(Application.Title);
      end;
    end;TOracleSession.DBMS_Job (Oracle 7.2 or higher)
    Declaration
    TDBMS_Job = class(TDBMSPackage)
     procedure Submit(out Job: Integer; const what: string; const Next_Date: TDateTime; const Interval: string; const No_Parse: Boolean);
     procedure Remove(const Job: Integer);
     procedure Change(const Job: Integer; const What: string; const Next_Date: TDateTime; const Interval: string);
     procedure What(const Job: Integer; const What: String);
     procedure Next_Date(const Job: Integer; const Next_Date: TDateTime);
     procedure Interval(const Job: Integer; const Interval: string);
     procedure Broken(const Job: Integer; const Broken: Boolean; const Next_Date: TDateTime);
     procedure Run(const Job: Integer);
    end;
    property DBMS_Job: TDBMS_Job;
    Description
    dbms_job包中的过程可以用来管理在工作序列中的工作。 这个包的详细信息在Server Administrator's Guide.
    下面的例子设定从明天开始每一天4:00,调用PL/SQL过程Clean_Up('ALL') :
    procedure TMainForm.ButtonClick(Sender: TObject);
    var Job: Integer; 
    begin
      MainSession.DBMS_Job.Submit(Job, 'Clean_Up(''ALL'');', Date + 1 + StrToTime('04:00'), 'sysdate + 2', True);
      ShowMessage('Job ' + IntToStr(Job) + ' scheduled');
    end;TOracleSession.DBMS_Output
    Declaration
    TDBMS_Output = class(TDBMSPackage)
     procedure Enable(const Buffer_Size: Integer);
     procedure Disable;
     procedure Put(const a: Variant);
     procedure Put_Line(const a: Variant);
     procedure New_Line;
     procedure Get_Line(out Line: string; out Status: integer);
     procedure Get_Lines(out Lines: string; var NumLines: Integer);
    end;
    property DBMS_Output: TDBMS_Output;
    Description
    dbms_output package可以发送消息或接收存储过程、包、触发器发出的消息。包中的Put 和 Put_Line过程可以用来把信息存入缓冲区,以备稍后用于包中的Get_Line或 Get_Lines 过程。这个包的详细信息在 Application Developer's Guide.
    下面是dbms_alert包中定义的常数:
    glSuccess Get line: 成功
    glNoMoreLines Get line:没有更多消息
      

  3.   

    下列的例子输出调用存储过程,并显示存储过程产生的信息:
    procedure TMainForm.ButtonClick(Sender: TObject);
    var Status: Integer;
        Line: string;
    begin
      // Enable output for a maximum of 100,000 bytes
      MainSession.DBMS_Output.Enable(100000);
      // Call the procedure
      MyProcedure.Execute;
      // Retrieve all lines and display them in a memo
      Memo.Clear;
      repeat
        MainSession.DBMS_Output.Get_Line(Line, Status);
        if Status <> glSuccess then Break;
        Memo.Lines.Add(Line);
      until False;
    end;TOracleSession.DBMS_Pipe
    Declaration
    TDBMS_Pipe = class(TDBMSPackage)
     procedure Pack_Message(const Item: Variant);
     procedure Pack_Message_Raw(const Item: string);
     procedure Pack_Message_Rowid(const Item: string);
     procedure Unpack_Message(out Item: Variant);
     procedure Unpack_Message_Raw(out Item: string);
     procedure Unpack_Message_Rowid(out Item: string);
     function  Next_Item_Type: Integer;
     function  Create_Pipe(const PipeName: string; const MaxPipeSize: Integer; const Private: Boolean): Integer;
     function  Remove_Pipe(const PipeName: string): Integer;
     function  Send_Message(const PipeName: string; const TimeOut: Integer; const MaxPipeSize: Integer): Integer;
     function  Receive_Message(const PipeName: string; const TimeOut: Integer): Integer;
     procedure Reset_Buffer;
     procedure Purge(const PipeName: string);
     function  Unique_Session_Name: string;
    end;
    property DBMS_Pipe: TDBMS_Pipe;
    Description
    dbms_pipe允许在一个事例中的多个SESSION互相通讯. Oracle 管道类似于UNIX中的管道, Oracle 管道 不是用操作系统管道机制来实现的。Oracle 管道暂存于 (SGA)区. 这个包的详细信息在 Server Application Developer's Guide.
    下面是dbms_pipe包中定义的常数
    cpSuccess 创建管道: 成功
    rpSuccess 删除管道: 成功
    smSuccess 发送消息: 成功
    smTimedOut 发送消息: 超时
    smInterrupted 发送消息: 中断
    rmSuccess 接收消息: 成功
    rmTimedOut 接收消息: 超时
    rmRecordTooBig 接收消息: 记录过大
    rmInterrupted 接收消息: 中断
    niNoMoreItems 下一项: No more items
    niVarchar2 下一项: Varchar2
    niNumber 下一项: Number
    niRowid 下一项: Rowid
    niDate 下一项: Date
    niRaw 下一项: Raw
    下面的例子向名为'MYPIPE'管道发送文本 'Button pressed' 和当前日期:
    procedure TMainForm.ButtonClick(Sender: TObject);
    begin
      with MainSession.DBMS_Pipe do
      begin
        Pack_Message('Button pressed');
        Pack_Message(Now);
        if Send_Message('MYPIPE', 60, 8192) = smSuccess then 
          ShowMessage('Message sent');
      end;
    end;TOracleSession.DesignConnection
    Declaration
    property DesignConnection: Boolean;
    Description
    在设计时使用的连接可能并不适合最总用户.设置DesignConnection属性True, 设记时的值将在运行时的清空。
    w Connected
    w LogonUsername
    w LogonPassword
    w LogonDatabase
    这样就可以无须更改直接分发程序,而设计时总有一个可用连接。TOracleSession.ErrorMessage
    Declaration
    function ErrorMessage(ErrorCode: Integer): string;
    Description
    返回与ErrorCode关联的消息. 可以在 "Oracle Server Messages Guide"找到响应的消息.
    See also
    ReturnCodeTOracleSession.ExpirationMessage (Oracle8 only)
    Declaration
    property ExpirationMessage: string;
    Description
    运行时属性包括一条因一个帐号已经过期而登录失败的出错信息。
    See also
    SetPasswordTOracleSession.ExternalLDA
    Declaration
    property ExternalLDA: Pointer;
    Description
    运行时属性把ToracleSession关联到另外一个程序的LDA (Logon Data Area)或存取SESSION的LDA区。设置这个属性等于调用LOGON。 设置ExternalLDA为nil等于调用LogOff.
    这个属性在开发DLL时非常有用。
    Warning
    这个属性在Net8不存在. 如果要使用ExternalLDA,应设置UseOCI7属性为True. TOracleSession.FlushObjects (Oracle8 only)
    Declaration
    procedure FlushObjects;
    Description
    Besides flushing each individual modified object instance in the cache, you can also flush all modified instances at once in one single network roundtrip, thereby reducing network traffic. You can do so by calling the Commit method of the session, in which case your transaction will be ended. You can also call the FlushObjects method of the session to flush all objects without committing the current transaction.TOracleSession.InTransaction
    Declaration
    function InTransaction: Boolean;
    Description
    显示SESSION中是否有事务。TOracleSession.IsolationLevel
    Declaration
    type TIsolationLevelOption = (ilUnchanged, ilReadCommitted, ilSerializable);
    property IsolationLevel: TIsolationLevelOption;
    Description
    决定Oracle如何控制数据的并发性。设置IsolationLevel为ilReadCommited可以看到其他session已经提交的事务. 设置为ilSerializable只能看到自己启动事务以前提交的记录。 
    当IsolationLevel 设置为stUnchanged, OraclE实例中的ISOLATION_LEVEL参数决定了如何数据并发控制。
    See also
    SetTransactionTOracleSession.LogOff
    Declaration
    procedure LogOff;
    Description
    这个存储过程终止与数据库的连接。当一个session 实例销毁时自动调用。
    See also
    LogOn
    Connected
    RollbackOnDisconnectTOracleSession.LogOn
    Declaration
    procedure LogOn;
    Description
    登录到数据库上。如session已经登录则它首先logged off.
    如果出错,则一个EoracleError异常出现。
    See also
    LogOff
    Connected
    LogonUsername
    LogonPassword
    LogonDatabase
    TOracleLogonTOracleSession.LogonDatabase
    Declaration
    property LogonDatabase: string;
    Description
    这个属性与LogonUsername和LogonPassword一起构成LogOn过程的登录字符串:Username/Password@Database.
    See also
    LogOn
    LogOff
    Connected
    LogonUsername
    LogonPassword
    TOracleLogonTOracleSession.LogonPassword
    Declaration
    property LogonPassword: string;
    Description
    这个属性与LogonUsername和LogonDatabase一起构成LogOn过程的登录字符串:Username/Password@Database。
    See also
    LogOn
    LogOff
    Connected
    LogonUsername
    LogonDatabase
    TOracleLogonTOracleSession.LogonUsername
    Declaration
    property LogonUsername: string;
    Description
    这个属性与LogonPassword和LogonDatabase一起构成LogOn过程的登录字符串:Username/Password@Database。
    You can also assign a complete connect string as above to LogonUsername. After connecting to the database, the three properties will reflect the actual values.
    See also
    LogOn
    LogOff
    Connected
    LogonPassword
    LogonDatabase
    TOracleLogonTOracleSession.MessageTable
    Declaration
    property MessageTable: string;
    Description
    ToracleDataSe控件通过一个消息表把由primary key, unique key, foreign key 和 check constraints引起出错消息翻译出来,消息的名称在session 定义并象下面一样:
    create table my_messages
    (
      Constraint_Name varchar2(30) not null,
      Actions         varchar2(3)  not null,
      Parent_Child    varchar2(1)  not null, 
      Error_Message   varchar2(2000)
    );
      

  4.   

    Constraint_Name 违反约束的名称.
    Actions 当inserts ('I'), updates ('U') and deletes ('D')时显示出错信息可以将几个字母组合起来如 'IU' 表示插入与修改。也可以用'*' 来表示所有的更改动作。
    Parent_Child 当违反应用完整性时显示的出错信息。用P或C表示。之一字段仅当有外键时有用,也可以用'*' 来表示约束。
    Error_Message 所显示的实际出错信息。
    Example
    Employees表有一个在empno列名为emp_pk主键、在deptno 列有一个外键emp_dept_fk。则应定义下列消息: messages could be defined:
    Constr_Name  Actions  PC Message
    EMP_PK       *        * Employee number already exists
    EMP_DEPT_FK  *        C Department does not exist
    EMP_DEPT_FK  D        P Cannot delete department while employees exist
    EMP_DEPT_FK  U        P Cannot change department number while employees exist
    See also
    TOracleDataSet.EnforceConstraints
    TOracleDataSet.UseMessageTableTOracleSession.NullValue
    Declaration
    type TNullValueOption = (nvNull, nvUnAssigned);
    property NullValue: TNullValueOption;
    Description
    当你检索的列或变量为空时NullValue 属性决定实际得到的值。如 NullValue = nvNull,则得到一个值为空的variant, 其表现如下::
    w 当把Null伏给一个非variant的变量会出现EvariantError异常。
    w 为验证值是否为空应使用VarIsNull(v) 
    w 如在空上使用关系运算符。把空但做一个较小的值
    w 如在空上使用非关系运算符。把空但空值处理
    如NullValue = nvUnAssigned,将得到一个未负值的variant,其特征如下:
    w 当使用UnAssigned 给一个非variant变量负值时, 它转换为 0, '' or zero date
    w 要检测结果是否为UnAssigned,应使用VarIsEmpty(v)
    w 如在UnAssigned 关系运算符出现EvariantError异常。 
    w 如在UnAssigned非关系运算符出现EvariantError异常。TOracleSession.OnChange
    Declaration
    type TOracleSessionEvent = procedure(Sender: TOracleSession) of Object;
    property OnChange: TOracleSessionEvent;
    Description
    当connected 或 disconnected调用.可用于使菜单项使能。.TOracleSession.OptimizerGoal
    Declaration
    type TOptimizerGoalOption = (ogUnchanged, ogChoose, ogFirstRows, ogAllRows, ogRule)
    property OptimizerGoal: TOptimizerGoalOption;
    Description
    决定ORACLE如何为一个SQL语句选择优化路径. 更加详细的信息在 "Oracle 7 Server Concepts" 中.TOracleSession.POLite
    Declaration
    function POLite: Boolean;
    Description
    当连接的是Personal Oracle时为true,当已连接时有效。TOracleSession.Preferences
    Declaration
    property Preferences: TSessionPreferences;
    Description
    这一属性可以影响其他连接这个SESSION的控件的表现。可以更改下列几个属性 T:
    property FloatPrecision: Integer;
    最大精度为Double.设为0将一个非整形数当作为一个浮点数, 虽然Double有15 位小数点.但设为non-zero值将使用一个字符串可以表示更高精度数值. 数值在SEVER端使用当前国家与语言设置转化为字符串。设置这个属性影响OracleQuery 和ToracleDataSet控件.
    property IntegerPrecision: Integer;
    Maximum precision to be represented an integer field. Setting this property to 0 will cause all integer numbers with a precision of 9 digits or less to be represented as an integer, and all other numbers as a floating point value, depending on the FloatPrecision preference. This preference affects fields in TOracleQuery and TOracleDataSet components.
    property SmallIntPrecision: Integer;
    Maximum precision to be represented as a small integer field (SmallInt). Setting this property to 0 will cause all integer numbers with a precision of 4 digits or less to be represented as a small integer. This preference only affects fields in the TOracleDataSet component, since the TOracleQuery component does not have small integer fields. The default value of this property is -1, so that small integer fields will never occur.
    property UseOCI7: Boolean;
    Use OCI7 on Net8 for this session. Setting this property to True will cause the session to use the old, but more stable SQL*Net 2.3 functions in Net8. This can be helpful in case of Net8 problems, but can only be used if your application is not using any Net8 specific objects (TLOBLocator, TOracleObject and TOracleReference).
    property ConvertCRLF: Boolean;
    Convert between CRLF pairs (Client) and LF (Server). In an Oracle Database, multiple lines of text are separated by just a linefeed (#10) character. On the Windows Operating System, the carriage return / linefeed (#13 / #10) combination is used. Direct Oracle Access will automatically convert between these two conventions. Setting this preference to False will disable this conversion. Use this preference with care.
    property TrimStringFields: Boolean;
    Remove trailing spaces from TOracleDataSet fields when fetching varchar2 and char columns from the database. These trailing spaces usually just get in the way when modifying string fields, so this property is True by default.TOracleSession.ReturnCode
    Declaration
    function ReturnCode: Integer;
    Description
    最后执行过程的返回码. 返回码可以在"Oracle Server Messages Guide".找到。
    See also
    ErrorMessageTOracleSession.Rollback
    Declaration
    procedure Rollback;
    Description
    回滚当前事务.
    See also
    Commit
    Savepoint
    RollbackToSavepoint
    AutoCommitTOracleSession.RollbackOnDisconnect
    Declaration
    property RollbackOnDisconnect: Boolean;
    Description
    这一属性决定当LogOf或Connected 设为FALSE或释放一个ToracleSession控件是否在断开连接时回滚事务.。如果应用程序没有释放一个ToracleSession控件而结束, ORACLE 服务器将回滚事务.TOracleSession.RollbackToSavepoint
    Declaration
    procedure RollbackToSavepoint(const ASavepoint: string);
    Description
    回滚当前事务到前一个已标识的Savepoint
    See also
    Commit
    Rollback
    Savepoint
    AutoCommitTOracleSession.Savepoint
    Declaration
    procedure Savepoint(const ASavepoint: string);
    Description
    Identifies a point in a transaction to which you can later roll back. In the parameter, you can pass any name to identify the savepoint.
    See also
    Commit
    Rollback
    RollbackToSavepoint
    AutoCommitTOracleSession.ServerVersion
    Declaration
    function ServerVersion: string;
    Description
    Returns a string containing the version of the database that the session is connected to (something like 'Personal Oracle7 Release 7.2.2.3.1').TOracleSession.SetPassword
    Declaration
    procedure SetPassword(const NewPassword: string);
    Description
    改变当前用户口令。在Oracle7中SESSION必须已连接,在Oracle8密码可以在不连接服务器时设置。
    Password expiration
    在Oracle8可以行使密码到期的权利,可以设置口令的生存期, 警告期(警告用户密码已过期),使用期 (在一特定时间段不允许口令重复).
    ToracleLogon控件口令自动到期。 当警告期时发出一条口令即将到期的消息,并询问用户是否立即要改变口令。在警告期后ToracleLogon控件强迫用户改变口令或登录失败。
    为在程序中不使用ToracleLogon而支持这种机制ToracleSession使用ExpirationMessage属性和SetPassword方法。
    当警告期时成功登录后, ExpirationMessage 属性包括Oracle警告信息(离口令到期还有几天)。
    当警告期后调用LOGON后,需要改变口令(SetPassword支持并不实际登录而改口令)。使用时需设LogonUsername, LogonPassword (原口令)和 LogonDatabase属性,最后调用SetPassword方法。如调用成功则口令改变,但没有连接数据库。连接数据库需再次调用LOGON。
    下列登录数据库的事例,在警告期发出一条警告当口令到期时将询问新口令。: 
    with MySession do
    try
      LogonUsername := UsernameEdit.Text;
      LogonPassword := PasswordEdit.Text;
      LogonDatabase := DatabaseEdit.Text;
      LogOn;
      if ExpirationMessage <> '' then 
        ShowMessage(ExpirationMessage)
      else 
        ShowMessage('Logged on successfully.');
    except
      on E:EOracleError do
      begin
        if E.ErrorCode <> 28001 then
          ShowMessage(E.Message);
        else try // ORA-28001, The account has expired
          SetPassword(GetNewPassword);
          Logon;
        except
          on E:EOracleError do ShowMessage(E.Message);
        end;
      end;
    end;
      

  5.   

    在TOracleSession 以连接时也可以调用SetPassword. 在调用SetPassword后, 仍保持连接. 对 SQL*Net 1.x or 2.x只能在以连接时调用SetPassword. 否则会得到 "Not logged on" 异常.TOracleSession.SetTransaction
    Declaration
    type TTransactionMode = (tmReadOnly, tmReadWrite, tmReadCommitted, tmSerializable);
    procedure SetTransaction(const ATransactionMode: TTransactionMode);
    Description
    设置事务为tmReadOnly, tmReadWrite, tmReadCommitted or tmSerializable.可以使用这一属性越过IsolationLevel 属性。在事务结束后, 下一个事务的模式从IsolationLevel中产生
    See also
    IsolationLevelTOracleSession.SQLTrace
    Declaration
    type TSQLTraceOption = (stUnchanged, stTrue, stFalse);
    property SQLTrace: TSQLTraceOption;
    Description
    这一属性可以SQL trace 发挥或失去作用,当设为stTrue, 可以用Oracle's tkprof工具来分析SQL语句统计关于 CPU 时间, 消耗时间, 磁盘 I/O, 及其它方面. "Oracle 7 Server Tuning"有关于tkprof进一步的阐述.
    当设为stUnchanged, Oracle 实例的初始化参数SQL_TRACE 决定SQL发挥或失去作用。TOracleSession.ThreadSafe
    Declaration
    property ThreadSafe: Boolean;
    Description
    设为true, 在这一SESSION可以使用多线程. 可以使用不同的线程介入不同的Session而无须设这个属性为True.
    在多线程开发部分有进一步的描述。TOracleSession.UTL_File (Oracle 7.3 or higher)
    Declaration
    TUTL_File = class(TDBMSPackage)
     function  FOpen(const Location: string; const Filename: string; const Open_Mode: string): TUTL_File_Type;
     function  Is_Open(const AFile: TUTL_File_Type): Boolean;
     procedure FClose(var AFile: TUTL_File_Type);
     procedure FClose_All;
     procedure Get_Line(const AFile: TUTL_File_Type; out Buffer: string);
     procedure Put(const AFile: TUTL_File_Type; const Buffer: string);
     procedure New_Line(const AFile: TUTL_File_Type; const Lines: Cardinal);
     procedure Put_Line(const AFile: TUTL_File_Type; const Buffer: string);
     procedure Putf(const AFile: TUTL_File_Type; const Format: string; const Args: array of string);
     procedure FFlush(const AFile: TUTL_File_Type);
    end;
    property UTL_File: TUTL_File;
    Description
    utl_file包在7。3版以后提供. 他在服务器为PL/SQL增加提供了文件I/O. 进一步的描述在 Server Application Developer's Guide.
    大多utl_file包中的函数和过程使用TUTL_File_Type型文件句柄,。可以声明一个变量为TUTL_File_Type型文件句柄来标识文件. 下面的例子在UNIX 目录 /transfer/output 声明一个文件类型并写入内容到一个MEMO中:
    procedure TMainForm.ButtonClick(Sender: TObject);
    var Handle: TUTL_File_type;
    begin
      with MainSession do
      begin
        Handle := UTL_File.FOpen('/transfer/output', 'info.txt', 'w');
        for i := 0 to Memo.Lines.Count - 1 do
          UTL_File.Put_Line(Handle, Memo.Lines[i]);
        UTL_File.FClose(Handle);
      end;
    end;不象其它包, utl_file异常需用户定义。这些用户定义异常翻译成 EUTL_File_Error. 包括下列值
    ufInvalidPath 文件位置或文件名不正确
    ufInvalidMode 打开模式不正确
    ufInvalidFilehandle 文件句柄无效
    ufInvalidOperation 文件无法打开或操作
    ufReadError 读文件时操作系统出错
    ufWriteError 写文件时操作系统出错
    ufInternalError PL/SQL未定义错误
    事例如下:
    procedure TMainForm.ButtonClick(Sender: TObject);
    var Handle: TUTL_File_type;
    begin
      with MainSession do
      try
        Handle := UTL_File.FOpen('/transfer/output', 'info.txt', 'w');
        for i := 0 to Memo.Lines.Count - 1 do
          UTL_File.Put_Line(Handle, Memo.Lines[i]);
        UTL_File.FClose(Handle);
      except
        on E: EUTL_File_Error do
        begin
          if E.Error = ufInvalidPath then
            ShowMessage('/transfer/output is not a valid file location');
          else
            ShowMessage(E.Message);
        end;
      end;
    end;