我们知道,通过Schema,一个DataAbstracService对应一个数据库;一个服务器可以包含多个DataAbstracService,从而实现对多个数据库的操作。通过事件处理我们可以在一个DataAbstracService中去调用另一个DataAbstracService,从而实现同时操作多个数据库。目前在版本7.0.65中通过在Schema中写脚本还不能做到这一点。本人少量的改写了DataAbstract后,做到了这一点。下面是要修改的两个类定义:

1、修改uDAEcmaScriptWrappers单元文件中的TDAEcmaLDAWrapper类,添加两个方法:

function newLDA(serviceName: string): TDAEcmaLDAWrapper;
    
function executeCommand(commandName: string; parameters: variant): Integer;

    改写下面的方法:

    
function ExecuteMethod(aMethodName: string; aParams: Variant): Variant; override;

   
 procedure IntCreate;

具体实现:

function TDAEcmaLDAWrapper.newLDA(serviceName: string): TDAEcmaLDAWrapper;


var

  Adapter: TDALocalDataAdapter;

begin

  Adapter := TDALocalDataAdapter.Create(serviceName);

  Adapter.SessionID := fLDA.SessionID;

  Result := TDAEcmaLDAWrapperClass(ClassType).Create(Adapter);

end;

function TDAEcmaLDAWrapper.executeCommand(commandName: string; parameters: variant): Integer;


var

  lParams, lOutParams: DataParameterArray;

begin

  lParams := VariantToDataParameterArray(parameters);

  Result := fLDA.ServiceInstance.ExecuteCommandEx(commandName, lParams, lOutParams);

  lOutParams.Free;

end;

function TDAEcmaLDAWrapper.ExecuteMethod(aMethodName: string; aParams: Variant): Variant;

begin

  ......

  
// ============================================添加的代码

  
else 
if aMethodName = 
'newLDA' then begin

    CheckParams(aMethodName,aParams,
);

    Result := newLDA(aParams[
]).AsVariant;

  end

  
else 
if aMethodName = 
'executeCommand' then begin

    CheckParams(aMethodName,aParams,
);

    Result := executeCommand(aParams[
], aParams[
]);

  end

  
//==============================================

  
else begin

    Result := inherited ExecuteMethod(aMethodName,aParams);

  end;

end;

procedure TDAEcmaLDAWrapper.IntCreate;

begin

  RegisterMethod(
'insert');

  RegisterMethod(
'update');

  RegisterMethod(
'remove');

  RegisterMethod(
'discardChanges');

  RegisterMethod(
'applyChanges');

  RegisterMethod(
'selectSQL');

  RegisterMethod(
'selectWhere');

  
//====================================添加的代码

  RegisterMethod(
'newLDA'); 

  RegisterMethod(
'executeCommand');  

  
//====================================

  fDeltas:= TList.Create;

  fDeltaList := TDAEcmaSchemaNamedListWrapper.Create(fDeltas, IntWrap, IntFind);

  fSelectResultList:= TObjectList.Create(True);

end;

、修改uDAScriptContext单元文件中的TDAScriptContext类

function TDAScriptContext.CreateLDA: TDALocalDataAdapter;

begin

  Result := TDALocalDataAdapter.Create(nil);

  Result.ServiceInstance := fOwner;

  Result.DynamicSelect := True;

  
//====================================添加的代码

  Result.SessionID := fOwner.ClientID; 

  
//====================================

end;

OK,修改完成。

下面来看一个实例:

, }) == )
            fail("级联删除失败");
        log(" 级联删除产品信息成功");
    }
}

使用上面的方法,有点像写触发器,但可以同时操作多个数据库,而且可以是不同类型的数据库。此方法可以用来做数据集成平台。

上面的代码已通过测试,欢迎大家指正!

增强Delphi.RemObject.DataAbstract的脚本功能:多数据库同时操作的更多相关文章

  1. Delphi中使用python脚本读取Excel数据

    Delphi中使用python脚本读取Excel数据2007-10-18 17:28:22标签:Delphi Excel python原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 . ...

  2. Delphi 各版本新特性功能网址收集

    Delphi XE2 三个新功能介绍举例_西西软件资讯  http://www.cr173.com/html/13179_1.html delphi 2007新功能简介-davidxueer-Chin ...

  3. O365 "打开或关闭脚本"功能

    博客地址:http://blog.csdn.net/FoxDave 自定义功能是 SharePoint Online 最具吸引力的功能之一,因为它使管理员和用户可以调整网站和页面的外观以满足组织目 ...

  4. Delphi XE2有什么新功能

    具体内容见PDF Delphi XE2有什么新功能Delphi XE2提供(offers)了令人兴奋(exciting)的新功能,让您能够建立高度可视化的,在Windows,Mac和iOS上的业务应用 ...

  5. (3.5)mysql基础深入——mysqld_safe脚本功能及流程

    (3.5)mysql基础深入——mysqld_safe脚本功能及流程 目录 1.mysqld_safe过程总结 2.mysql_safe启动的好处 3.mysqld_safe 参数 4.mysqld_ ...

  6. 使用PaxScript为Delphi应用增加对脚本的支持

    通过使用PaxScript可以为Delphi应用增加对脚本的支持. PaxScript支持paxC,paxBasic,paxPascle,paxJavaScript(对ECMA-262做了扩展) 四种 ...

  7. SpaceClaim脚本功能(Beta功能)

    本操作仅适用ANSYS SpaceClaim 2016 打开SpaceClaim脚本编辑器的方法有两种 方法一(看截图操作):         方法二(请见后面的实例操作). 创建球体源代码: #定义 ...

  8. 除了binlog2sql工具外,使用python脚本闪回数据(数据库误操作)

    利用binlog日志恢复数据库误操作数据 在人工手动进行一些数据库写操作的时候(比方说数据修改),尤其是一些不可控的批量更新或删除,通常都建议备份后操作.不过不怕万一,就怕一万,有备无患总是好的.在线 ...

  9. 分享一个SQLSERVER脚本(计算数据库中各个表的数据量和每行记录所占用空间)

    分享一个SQLSERVER脚本(计算数据库中各个表的数据量和每行记录所占用空间) 很多时候我们都需要计算数据库中各个表的数据量和每行记录所占用空间 这里共享一个脚本 CREATE TABLE #tab ...

随机推荐

  1. BZOJ 3207: 花神的嘲讽计划Ⅰ( hash + 可持久化线段树 )

    O(NK)暴力搞出所有子串的哈希值, 然后就对哈希值离散化建权值线段树, 就是主席树的经典做法了.总时间复杂度O(NK+(N+Q)logN) ----------------------------- ...

  2. iScroll 4,把禁掉的:active样式还给我~

    iScroll这个移动端的滚动神器大家都非常熟悉了,直到现在仍是实现移动端Web滚动的首选方案之一... 当我接触移动端Web时iScroll已经有两个版本了,iScroll 4和iScroll 5, ...

  3. SQL Server 数据类型陷阱

    1. bit 类型:bit(1) 不要以为它只占一个位,事实上它要占一个字节!也就是说当n < 8 时都是这样的! 2. varchar(n)  这里的n不能大于8000,如果想要比8000大你 ...

  4. oracle查询字符集语句

      (1)查看字符集(三条都是等价的) 复制代码 代码如下: select * from v$nls_parameters  where parameter='NLS_CHARACTERSET'sel ...

  5. RedisService

    package com.sprucetec.bone.common.redis;import com.alibaba.fastjson.JSON;import org.springframework. ...

  6. HDU 4622 Reincarnation(后缀自动机)

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=4622 [题目大意] 给出一个长度不超过2000的字符串,有不超过10000个询问,问[L,R]子串 ...

  7. BZOJ 无数据题集合

    题目 http://www.lydsy.com/JudgeOnline/problem.php?id=1142 http://www.lydsy.com/JudgeOnline/problem.php ...

  8. oralce dubugs

    1,The listener supports no services 2,invalid specification for system parameter LOCAL_LISTENER crea ...

  9. spring集成mongodb封装的简单的CRUD

    1.什么是mongodb         MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案. mongoDB MongoDB是一个介 ...

  10. 【LeetCode】Sum Root to Leaf Numbers

    题目 Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a num ...