条件查询数据窗口问题

stone100 2011-04-06 04:08:07
string v_ym, v_retail_cat_id, v_sql, v_old_sql, v_bz, v_retail_cat_name,v_title,v_flag,v_retail_category_id,xianju
long title_width,columns
// Year & Month
if integer(em_statistics_month.text) > 9 then
v_ym = em_statistics_year.text + em_statistics_month.text
else
v_ym = em_statistics_year.text + "0" + em_statistics_month.text
end if
// Papers & Magazines
If rb_1.Checked Then
v_flag = '0' // papers
v_bz = '报纸'
End If
If rb_2.Checked Then
v_flag = '1' // magazines
v_bz = '杂志'
End If
If rb_3.Checked Then
v_retail_category_id='01'
v_bz='邮发'+v_bz
elseif rb_4.checked then
v_retail_category_id='03'
v_bz='代销'+v_bz
elseif rb_5.checked then
v_retail_category_id='02'
v_bz='特发'+v_bz
End If
v_title=v_ym+'月'+v_bz+'各单位每天到货款'

// Assing text content
dw_arrived_sheet_report.modify("title.text='"+v_title+"'")
select count(distinct order_date) into :columns FROM arrived_sheet
WHERE ARRIVED_SHEET.SHEET_MONTH = :v_ym AND
f_get_bkzl(bkdh,substr(period_number,1,4)) = :v_flag AND
arrived_sheet.amount <> 0 and retail_category_id=:v_retail_category_id;

title_width=long(dw_arrived_sheet_report.object.grand_sum_account.x)
title_width=title_width+long(dw_arrived_sheet_report.object.grand_sum_account.width)
title_width=title_width+(columns -1)*long(dw_arrived_sheet_report.object.account.width)
dw_arrived_sheet_report.object.title.width=title_width
dw_arrived_sheet_report.object.date.width=title_width
dw_arrived_sheet_report.object.grand_sum_account.width
dw_arrived_sheet_report.retrieve(v_ym,v_flag,v_retail_category_id)
dw_arrived_sheet_report.object.mfactaccount.visible=0
dw_arrived_sheet_report.object.magio.visible=0

*********************重点重点*重点重点重点重点重点重点**********************************************************************************
if rb_7.checked then
//--------------------------------------------------------------------------
// int li_col //显示所有的列名
// string ls_name
// for li_col = 1 to long(dw_arrived_sheet_report.object.datawindow.column.count)
// ls_name = dw_arrived_sheet_report.describe("#"+string(li_col)+".name")
// messagebox("column name",ls_name)
// next
//----------------------------------------------------------------------------
xianju='10'
dw_arrived_sheet_report.setfilter("company_company_category_id<>'"+xianju+"'")
dw_arrived_sheet_report.filter()
end if

if rb_8.checked then
xianju='10'
dw_arrived_sheet_report.setfilter("company_company_category_id='"+xianju+"'")
dw_arrived_sheet_report.filter()
end if


最后那处执行时,总是全部显示了所以数据,不能按company_company_category_id='"+xianju+"'来,并且报“Expression is not valid”,求指教
...全文
296 31 打赏 收藏 转发到动态 举报
写回复
用AI写文章
31 条回复
切换为时间正序
请发表友善的回复…
发表回复
yyoinge 2011-07-25
  • 打赏
  • 举报
回复
retrieve argument 的类型为 string array 不是 string
stone100 2011-05-10
  • 打赏
  • 举报
回复
按楼上做的,一查询报“Retrieve argument 4 does not match expected type”
yyoinge 2011-05-06
  • 打赏
  • 举报
回复
你应该改为:
string flags[]
If rb_6.Checked Then
flags = {'0','1'}
End If
If rb_7.Checked Then
flags = {'0'}
End If
If rb_8.Checked Then
flags = {'1'}
End If
dw_1.retrieve(flags)
yyoinge 2011-05-06
  • 打赏
  • 举报
回复
F1中的内容:
This example also illustrates retrieval arguments. Assume dw_EmpHist contains this SQL SELECT statement and emps is defined as a number array:

SELECT EmpNbr, Sal, Rgn From Employee

WHERE EmpNbr IN (:emps)

These statements cause dw_EmpHist to retrieve Employees from the database whose employee numbers are values in the array emps:

Double emps[3]

emps[1] = 100

emps[2] = 200

emps[3] = 300

dw_EmpHist.Retrieve(emps)

stone100 2011-05-06
  • 打赏
  • 举报
回复
上面的问题解决的差不多了,但是又出个新问题:
If rb_6.Checked Then
flags = '0,1'
End If
If rb_7.Checked Then
flags = '0'
End If
If rb_8.Checked Then
flags = '1'
End If

sql是:"select * from company where company.flags in(:flags))",现在是flags='0' 和flags='1'都能出正确答案,flags='0,1'出不来,求各位高手帮助
stone100 2011-04-22
  • 打赏
  • 举报
回复
楼上的高手,请从头看,就成明白我的问题了。我后面的只是在试用其他方法解决问题时,发生的新的错误
njwup 2011-04-20
  • 打赏
  • 举报
回复

能否给详细地说下?是否SQL语句里的select中也要加上这个字段?还是直接将:dw_arrived_sheet_report.setfilter("company_company_category_id='"+xianju+"'")
换成dw_arrived_sheet_report.SetSQLSelect("company_company_category_id='"+xianju+"'")
???
select 中不一定要该字段,在where 条件中需有该字段
如:
string ls_sql,xianju
xianju='10'
ls_sql='select 字段1,字段2 form 表1 where 表1.category_id=~''+xianju+'~''
dw_arrived_sheet_report.SetSQLSelect(ls_sql)
dw_arrived_sheet_report.retrieve()

jimwoo 2011-04-15
  • 打赏
  • 举报
回复
[Quote=引用 21 楼 stone100 的回复:]
现在改成这样,报错“Select error: Column lists do not match”,并且执行时会弹出提示框,要我输入原本就有的三个参数。

代码如下:
v_old_sql = dw_arrived_sheet_report.GetSqlSelect()
if rb_8.checked then
v_sql=" and company_company_category_……
[/Quote]
直接写SQL了就不用参数了,把datawindow里面的三个参数删掉
stone100 2011-04-15
  • 打赏
  • 举报
回复
高手们,请指点指点
stone100 2011-04-14
  • 打赏
  • 举报
回复
自已顶下
stone100 2011-04-13
  • 打赏
  • 举报
回复
现在改成这样,报错“Select error: Column lists do not match”,并且执行时会弹出提示框,要我输入原本就有的三个参数。

代码如下:
v_old_sql = dw_arrived_sheet_report.GetSqlSelect()
if rb_8.checked then
v_sql=" and company_company_category_id<>'10'"

dw_arrived_sheet_report.SetSqlSelect( v_old_sql + v_sql )
dw_arrived_sheet_report.SetTransObject(sqlca)
dw_arrived_sheet_report.Retrieve()
end if
灰色轨迹 2011-04-08
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 stone100 的回复:]
说实话,还真没有这个列
[/Quote]

数据窗中没有这个列你用filter()过滤肯定会报错了~
stone100 2011-04-08
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 njwup 的回复:]
尽管表中有,但dw中没有的列,肯定不能用作为filt的条件!如果是交叉表dw,还是在sql语句中用where吧,用SetSQLSelect()更换查询条件应当能实现。
[/Quote]

能否给详细地说下?是否SQL语句里的select中也要加上这个字段?还是直接将:dw_arrived_sheet_report.setfilter("company_company_category_id='"+xianju+"'")
换成dw_arrived_sheet_report.SetSQLSelect("company_company_category_id='"+xianju+"'")
???
zqycn 2011-04-08
  • 打赏
  • 举报
回复
company_category_id='"+xianju+"'"
字段是整型的应为
company_category_id="+xianju
tyt2058 2011-04-08
  • 打赏
  • 举报
回复
你在第二次的setfilter()前用下retrieve(),试试
stone100 2011-04-07
  • 打赏
  • 举报
回复
说实话,还真没有这个列,这是个竖表转横表的显示,company_company_category_id='10'这就是一个条件,可有可无的。
最后的显示结果应为:
单位 1号 2号 3号…………号 合计
A部门 10 200 30 50 N
B部门 30 140 20 30 N
C部门 20 100 50 40 N
这样地。 company_company_category_id=10是指单位的某个类型为‘10’.
xuam 2011-04-07
  • 打赏
  • 举报
回复
那奇怪了,你的DW有没有这个列:company_company_category_id ?
[Quote=引用 12 楼 stone100 的回复:]
显示的是对的: company_company_category_id='10'
但是还报错“Expression is not valid”
[/Quote]
stone100 2011-04-07
  • 打赏
  • 举报
回复
显示的是对的: company_company_category_id='10'
但是还报错“Expression is not valid”
xuam 2011-04-07
  • 打赏
  • 举报
回复
我的意思你的过滤条件不对,显示出来看看错在哪里.
[Quote=引用 10 楼 stone100 的回复:]
楼上,我主要的问题是这个不能实现,不是那个弹出框
if rb_8.checked then
xianju='10'
dw_arrived_sheet_report.setfilter("company_company_category_id='"+xianju+"'")
dw_arrived_sheet_report.filter()
end if
[/Quote]
stone100 2011-04-07
  • 打赏
  • 举报
回复
楼上,我主要的问题是这个不能实现,不是那个弹出框
if rb_8.checked then
xianju='10'
dw_arrived_sheet_report.setfilter("company_company_category_id='"+xianju+"'")
dw_arrived_sheet_report.filter()
end if
加载更多回复(11)

609

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder DataWindow
社区管理员
  • DataWindow社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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