祝愿大家身体健康!

 站点注册  找回密码
 站点注册

QQ登录

只需一步,快速开始

查看: 5317|回复: 1

[转帖]如何动态改编数据窗口的数据源

[复制链接]

[转帖]如何动态改编数据窗口的数据源

[复制链接]
ehxz

主题

0

回帖

58万

积分

管理员

积分
588671
贡献
在线时间
小时
2007-6-26 12:12:09 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?站点注册

×

如何动态改编数据窗口的数据源

 
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.)

 

共享共进共赢Sharing And Win-win Results
SYBASEBBS - 免责申明1、欢迎访问“SYBASEBBS.COM”,本文内容及相关资源来源于网络,版权归版权方所有!本站原创内容版权归本站所有,请勿转载!
2、本文内容仅代表作者观点,不代表本站立场,作者自负,本站资源仅供学习研究,请勿非法使用,否则后果自负!请下载后24小时内删除!
3、本文内容,包括但不限于源码、文字、图片等,仅供参考。本站不对其安全性,正确性等作出保证。但本站会尽量审核会员发表的内容。
4、如本帖侵犯到任何版权问题,请立即告知本站 ,本站将及时删除并致以最深的歉意!客服邮箱:admin@sybasebbs.com
lovelyni

主题

0

回帖

76

积分

注册会员

积分
76
贡献
在线时间
小时
2007-12-19 22:11:33 | 显示全部楼层
不错
共享共进共赢Sharing And Win-win Results
您需要登录后才可以回帖 登录 | 站点注册

本版积分规则

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com

QQ|Archiver|PowerBuilder(PB)BBS社区 ( 鲁ICP备2021027222号-1 )

GMT+8, 2024-11-24 13:04 , Processed in 0.131089 second(s), 8 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表