在一次项目开发过程中需要从不同的数据库(eg: db1=ORACLE;db2=SYBASE)中取出数据方如同一个数据窗口中作为报表. 思路如下:
1. 创建两个tabular型的Datawindow, dw_oracle, dw_sybase.
2. 创建一个composite的Datawindow"dw_cmpst". 在这个数据窗口中置入dw_oracle和dw_syabse. 分别命名为"dw_orcl"和"dw_sbs".
3. 在脚本中写入如下的语句:
DataWindowChild ldwc_report
Transaction NEW_SQLCA;
CONNECT USING SQLCA; // 使用默认的事务对象
dw_cmpst.GetChild( "dw_orcl", ldwc_report) // get a reference to
the first report in the composite
ldwc_report.SetTransObject( SQLCA)
ldwc_report.Retrieve()
DISCONNECT USING SQLCA;
NEW_SQLCA = CREATE Transaction // 第二个事务对象
NEW_SQLCA.DBMS = "SYC Sybase System 10/11"
NEW_SQLCA.Database = "database"
NEW_SQLCA.LogPass = "password"
NEW_SQLCA.ServerName = "sybase_server"
NEW_SQLCA.LogId = "logid"
NEW_SQLCA.