首页 | 新闻中心| 公司介绍| 产品走廊| 渠道与销售| 技术支持| 下载中心| 用户认证
蓝色快车PB俱乐部论坛--PowerBuilder MIS编程回复发言
>>欢迎您,请先登陆 | 注册 | 发贴排行 | 搜索 | 帮助 | 退出
    蓝色快车PB俱乐部论坛
    PowerBuilder MIS编程
       回复发言

  *为必填项目 常规论坛,只允许注册会员发言

用户名   *您没有注册?
密码   *忘记密码?请与管理员webmaster@besoft.com.cn联系
主题标题   不得超过 50 个汉字
当前心情
  • 将放在帖子的前面
  •                           
                              
    内容

    在此论坛中
  • HTML标签: 不可用
  • UBB标签: 允许
  • 帖图标签: 允许
  • Flash标签: 允许
  • 表情字符转换: 允许
  • 上传图片: 允许
  • 最多16KB

  • 粗体 斜体 下划线 居中 超级连接 Email连接 图片 Flash图片 Shockwave文件 realplay视频文件 Media Player视频文件 QuickTime视频文件 引用 飞行字 移动字 发光字 阴影字
    字体:      字体大小    颜色:
    点击表情图即可在帖子中加入相应的表情
     
    选项

    是否显示您的签名?
    有回复时使用邮件通知您?


     

    --  作者:cpu
    --  发布时间:2003/4/18 11:07:32

    --  如何动态改编数据窗口的数据源
    This script demonstrates how to change the source of a Datawindow dynamically.  
     
      
    Example: You want to switch from a SQL select to a procedure OR you want to change from one procedure to another OR from one select to another. It doesn't matter, as long as the source that you are changing to brings back the same result set as was originally defined for the Datawindow.  
      
    Note1: You may change the source ONLY if the result set does not change (i.e., the number of, type of, and order of columns does not change.)  
      
    Note2: You must predefine all possible arguments to the DataWindow ahead of time. Remember, just because you have an argument defined doesn't mean that you have to use it. But all necessary arguments must be pre-defined. Then the appropriate arguments are referenced by the select or the stored procedure.  
      
    Note3: Update capability may be affected. For example, even if the new source brings back the same data as the old source, if the column names are different, your updateable column list will be invalid (because it was defined against the old columns, not the new).  
      
    However, if the column names are the same, you should be able to redirect updates to the new table by doing a Modify on datawindow.table.updatetable.  
      
    Example of changing from a select source to a stored procedure source  
      
    1. Create a procedure in ASA using following syntax:  
      
    CREATE procedure dbo.sp_test () as  
    select department.dept_id,department.dept_name,employee.emp_lname from  
    DBA.department,DBA.employee  
      
    2. In PB, create a datawindow which has the same select statement as in the stored proc.  
      
    3. Now, you can change the datasource in the script as follows:  
      
    dept_name = "R&D  
      
    w_1.Modify("datawindow.table.select =' ' )  
      
    od_string = "datawindow.table.procedure = ' execute dbo.sp_test;0 '  
      
    rc = dw_1.Modify(mod_string)  
      
    F rc = " THEN  
      
    dw_1.Retrieve ( dept_name, name_str)  
      
    ELSE  
      
    "Change to DW Source Failed)  
      
    END IF  
      
    * You can verify the change in the data source using 'dw_1.Object.Datawindow.Syntax'  
    in the script.  
      
    The following steps demonstrate how to change the source of a Datawindow from select to stored procedure permanently:  
      
    1) Export your Datawindow to a DOS file (using the Library Painter.)  
      
    2) Make a backup copy of the original file (in case you make a mistake and need to drop back!)  
      
    ) Using a text editor like Write or Notepad, open the file and replace the"retrieve = ...  
    line. Using the above example, the "retrieve = line in my datawindow source code might look like this:  
      
    epartment.dept_id~" )) )  
      
    line in the Datawindow source code with the following "procedure = line (assumes the proc is owned by dbo)  
      
    rocedure="execute dbo.sp_test;0  
      
    After making the change, you would import the modified source code back into your PBL. That's it!  
      
    Again, always be sure to make a backup copy of your Datawindow before you import any changes (just in case you inadvertently make a bad change to the source code.)

    ">