pb中怎么查询

zkdxn 2011-06-23 09:32:32
我在sql查询器中用以下语句来查询数据,现在想把它写到pb中,按开始日期和结束日期查询结果。
用的sql语句是
select a,sum(b),sum(c) from
(
select a,b,c from table1,table2
where table1.rq>'开始日期' and table1.rq<'结束日期'
union all
select a,b,c from table3,table4
where table1.rq>'开始日期' and table1.rq<'结束日期'
union all

select a,b,c from table5,table6
where table1.rq>'开始日期' and table1.rq<'结束日期'
union all

select a,b,c from table7,table8
where table1.rq>'开始日期' and table1.rq<'结束日期'
union all

select a,b,c from tab9,table10
where table1.rq>'开始日期' and table1.rq<'结束日期'

) c group by a


我想问的是,我做数据窗口对象时数据源选择什么呢?(因为这里涉及很多个表),应该怎样做一个按日期来查询的功能呢?
...全文
1372 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
AK47 2011-06-26
  • 打赏
  • 举报
回复
学习一下,顶起来。
gzycw 2011-06-26
  • 打赏
  • 举报
回复
直接新建数据窗口直接把语句拷进去就行了,如果条件变化,也可以点查询时,动态改数据窗口的语句的。
ribut9225 2011-06-25
  • 打赏
  • 举报
回复
呵呵,学习了。。。
yyoinge 2011-06-23
  • 打赏
  • 举报
回复
(1)数据源选择 "SQL Select"
(2)然后在弹出select编辑窗口中将Select Tables窗口Cancel掉
(3)选择菜单“Design → Conver To Syntax”
(4)粘贴以下语句到select窗口中
我在sql查询器中用以下语句来查询数据,现在想把它写到pb中,按开始日期和结束日期查询结果。
用的sql语句是
select a,sum(b),sum(c) from
(
select a,b,c from table1,table2
where table1.rq> :rq_start and table1.rq< :rq_end
union all
select a,b,c from table3,table4
where table1.rq> :rq_start and table1.rq< :rq_end
union all

select a,b,c from table5,table6
where table1.rq> :rq_start and table1.rq< :rq_end
union all

select a,b,c from table7,table8
where table1.rq> :rq_start and table1.rq< :rq_end
union all

select a,b,c from tab9,table10
where table1.rq> :rq_start and table1.rq< :rq_end

) c group by a


(5)选择菜单“Design → Retrieval Arguments”,在弹出的Specify Retrieval Arguments窗口中,插入两个变量 :
(Name) (Type)
rq_start datetime
rq_end datetime
然后“OK”
(6)然后“Retrun”即可
(7)实际调用中,带参检索即可
datetiem ldt_start, ldt_end
ldt_start = ...
ldt_end = ...
dw_1.settransobject(sqlca)
dw_1.retrieve(ldt_start, ldt_end)
zhangyh_136 2011-06-23
  • 打赏
  • 举报
回复
新手吧!
数据窗口对象的数据源,可以不选择的,直接写你的sql就是了。然后就是定义检索参数,和选择数据源一样。
建议:
能否把你的检索参数放在外面?
xiyueyi 2011-06-23
  • 打赏
  • 举报
回复
不知道你用的什么版本pb,我的是pb8,步骤是new->datawindow标签,选择窗口格式->数据源(我使用oracle)->选择表->选择字段->然后保存。窗口创建完成

然后点菜单栏的 "SQL",再点“Design → Conver To Syntax”,这时显示的就是你所需要的所有信息的sql语句,把你的条件语句直接加在后面就可以了,或者是设置为查询参数也可以

1,076

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧