当前位置: 代码迷 >> PB >> 将游标改为数据窗口或datastore,该怎么处理
  详细解决方案

将游标改为数据窗口或datastore,该怎么处理

热度:93   发布时间:2016-04-29 09:02:58.0
将游标改为数据窗口或datastore
现有一个系统是使用游标存储数据,效率特慢,想改成数据窗口或者datastore,但是不会写,请高手指导,希望能给个例子

------解决方案--------------------
方法I:
1,用原游标的SQL 语句创建DW对象.
2,在程序中声明 datastore 并 create
3,把DW对象名作为字符串,赋值给刚申明的 datastore.dataobject
4,datastore.retrieve()

方法II,参照这个函数:
C/C++ code
global type gf_create_ds from function_objectend typeforward prototypesglobal function boolean gf_create_ds (ref transaction at_trans, ref string as_sql, ref datastore ad_datastore)end prototypesglobal function boolean gf_create_ds (ref transaction at_trans, ref string as_sql, ref datastore ad_datastore);//====================================================================// 事件: .gf_create_ds()//--------------------------------// 描述: 全局函数,用SQL 语句构造 datastore//--------------------------------// 参数://     reference      transaction       at_trans        //     reference    string       as_sql          //     reference    datastore    ad_datastore    //--------------------------------// 返回:  boolean//--------------------------------// 作者:    Wangenu        日期: 2009年12月17日//--------------------------------//    Copyright(c) 2009  Wangenu(TM).//--------------------------------// 修改历史:////====================================================================ad_datastore = create datastorestring ls_errsyntaxfromSQLstring ls_errcreatestring ls_newsyntax                    ls_newsyntax = at_trans.syntaxfromsql(as_sql ,'style(type=grid)',ls_errsyntaxfromSQL)if len(ls_errsyntaxfromSQL) > 0 then    messagebox('生成临时表句法错误','提示:~n~n'+ls_errsyntaxfromSQL,stopsign!)    return falseelse    ad_datastore.create(ls_newsyntax,ls_errcreate)    if len(ls_errcreate) > 0 then        messagebox('生成临时表错误','提示:~n~n'+ls_errsyntaxfromSQL,stopsign!)        return false    end if    ad_datastore.settransobject(at_trans)    ad_datastore.retrieve()    end ifreturn trueend function
------解决方案--------------------
探讨
引用:
方法I:
1,用原游标的SQL 语句创建DW对象.
2,在程序中声明 datastore 并 create
3,把DW对象名作为字符串,赋值给刚申明的 datastore.dataobject
4,datastore.retrieve()

方法II,参照这个函数:
C/C++ codeglobal type gf_create_ds from function_object
end type

forward prototypesglobal function boolean gf_create_ds (ref transaction at_trans,refstring as_sql,ref datastore ad_datastore)
end prototypesglobal function boolean gf_create_ds (ref transaction at_trans,refstring as_sql,ref datastore ad_datastore);//====================================================================// 事件: .gf_create_ds()//--------------------------------// 描述: 全局函数,用SQL 语句构造 datastore//--------------------------------// 参数://    reference      transaction      at_trans//    reference    string      as_sql//    reference    datastore    ad_datastore//--------------------------------// 返回:  boolean//--------------------------------// 作者:    Wangenu        日期: 2009年12月17日//--------------------------------//    Copyright(c) 2009  Wangenu(TM).//--------------------------------// 修改历史:////====================================================================

ad_datastore= create datastorestring ls_errsyntaxfromSQLstring ls_errcreatestring ls_newsyntax                   

ls_newsyntax= at_trans.syntaxfromsql(as_sql ,'style(type=grid)',ls_errsyntaxfromSQL)if len(ls_errsyntaxfromSQL)>0 then