datastore.Retrieve() 返回-1代码如下大家帮帮忙看下

zijiezhuang 2009-02-18 03:43:47
创建的代码如下
datastore dw_8
dw_8 = create datastore
ls_dh = dh1
ls_cph = cph1
new_sql = "select xmh,ylh,hsjs,sui,sl,id from cost where dh ='" +ls_dh+"'"
new_syntax = SQLCA.SyntaxFromSQL(new_sql, 'Style(Type= grid)', error_syntaxfromSQL)
IF Len(error_syntaxfromSQL) > 0 THEN
messagebox("错误", error_syntaxfromSQL)
ELSE
dw_8.Create(new_syntax, error_create)
IF Len(error_create) > 0 THEN
messagebox("错误", error_create)
END IF
END IF
dw_8.SetTransObject(SQLCA)
i_count = dw_8.Retrieve()

程序刚开始执行的前面的数据都没有问题,到1800多条左右i_count开始返回值变成了-1
我在数据库用select xmh,ylh,hsjs,sui,sl,id from cost where dh ='带入当时调试的值'都是有数据.
各位帮帮忙看看是什么问题,跟数据量有关系吗
...全文
429 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
zijiezhuang 2009-02-19
  • 打赏
  • 举报
回复
做了DW数据都可以返回
sjq521521 2009-02-19
  • 打赏
  • 举报
回复
请问LZ按jlwei888方法做了吗
sjlion 2009-02-19
  • 打赏
  • 举报
回复
“SetTransObject(SQLCA) 就可以了不用销毁datastore”我是没有听说过的。PB虽然有自己的垃圾清理机制来释放内存,但为保险起见,特别是你这样大量的循环create,还是自己destory的好
zijiezhuang 2009-02-19
  • 打赏
  • 举报
回复
虽然PB我不懂,但destroy dw_8 是销毁dw_8!我还是懂的,我之前有查了很多这方面的。
很多人都说SetTransObject(SQLCA) 就可以了不用销毁datastore.
zijiezhuang 2009-02-19
  • 打赏
  • 举报
回复
对不起啦,我以为只要给出重要的那一部分代码就可以了,下面去全部的代码 上面给的那段代码是在下面的of_updatedj里面
string ls_dh ,ls_cph,ls_gs,ls_fh,ls_hzy,ls_mc
int i_cou,i_sel,i = 1,i_count,ii,p=1
string error_syntaxfromSQL, error_create
string new_sql, new_syntax
dec ld_hr,ld_usd,ld_rmb,ld_zcb
datastore dw_11
date ld_date
dw_11 = create datastore
i_sel = messagebox('提示','是否要更新当前的单据的价格??',question!,yesno!)
if i_sel <> 1 then return -1
st_1.visible = true
st_2.visible = true
new_sql = "select dh as dh,cph as cph from finished where cph is not null and gsbh = '"+g_user_yhbh+"'"
new_syntax = SQLCA.SyntaxFromSQL(new_sql, 'Style(Type= grid)', error_syntaxfromSQL)
IF Len(error_syntaxfromSQL) > 0 THEN

messagebox("错误", error_syntaxfromSQL)

ELSE

dw_11.Create(new_syntax, error_create)

IF Len(error_create) > 0 THEN

messagebox("错误", error_create)

END IF

END IF
dw_11.SetTransObject(SQLCA)
i_count = dw_11.Retrieve()

hpb_1.maxposition = i_count
do while i <= i_count
ls_dh = dw_11.getitemstring(i,'dh')
ls_cph = dw_11.getitemstring(i,'cph')
if not isnull(ls_cph) and ls_cph <> '' then
/////-------原金额--
select je into :ld_zcb from cost where dh = :ls_dh and xmm ='总成本' using sqlca;
commit using sqlca;
select gs,fh,hzy,gg into :ls_gs,:ls_fh,:ls_hzy,:ls_mc from finished where dh = :ls_dh using sqlca;
commit using sqlca;
st_2.text = ls_dh
of_updatedj(ls_dh,ls_cph)
of_update(ls_dh)
string ls_hr
ls_hr = string(ld_hr)
//-----------------刷新汇率价格
select hl into :ld_hr from hlb where bb = 'USD' using sqlca;
select je into :ld_rmb from cost where dh = :ls_dh and xmm ='总成本' using sqlca;
update finished set yx = :ld_rmb/:ld_hr,nx=:ld_rmb,bb1='1 : '+ :ls_hr where dh = :ls_dh using sqlca;
commit using sqlca;

if round(ld_zcb,4) <> round(ld_rmb,4) and ld_zcb > 0 then
select count(*) into :ii from jglsb where dh = :ls_cph and tg is null using sqlca;
commit using sqlca;
if ii > 0 then
update jglsb set tg ='2' where dh = :ls_cph and tg is null using sqlca;
commit using sqlca; //没又改掉就被删除
end if
insert into jglsb(dh,cph,mc,ynx,xnx,gs,fh,hzy,xgy,xzrq) values
(:ls_dh,:ls_cph,:ls_mc,:ld_zcb,:ld_rmb,:ls_gs,:ls_fh,:ls_hzy,:g_user_name,:gd_rqsj) using sqlca;
commit using sqlca;
end if
end if
hpb_1.position = i
i++
loop

update zlk set updatename = updatename+ '('+:g_user_yhbh+')' where updatename not like '%('+:g_user_yhbh+')%' or updatename is null using sqlca;
commit using sqlca;
update gz_set set updatename =updatename+ '('+:g_user_yhbh+')' where updatename not like '%('+:g_user_yhbh+')%' or updatename is null using sqlca;
commit using sqlca;
update hlb set updatename =updatename+ '('+:g_user_yhbh+')' where updatename not like '%('+:g_user_yhbh+')%' or updatename is null using sqlca;
commit using sqlca;
update material set updatename =updatename+ '('+:g_user_yhbh+')' where (updatename not like '%('+:g_user_yhbh+')%' or updatename ='') and updatename <>'NEW' using sqlca;
commit using sqlca;
st_1.visible = false
st_2.visible = false
messagebox('提示','更新完毕!!')
dw_2.retrieve('%('+g_user_yhbh+')%')

--函数of_update_dj()
string ls_dh ,ls_xmh ,ls_ylh ,ls_cph ,ls_dw
string error_syntaxfromSQL, error_create
string new_sql, new_syntax
dec d_dj ,d_hsjs,d_sui,d_sl,d_je
int i_count,i_col = 1,i_coun
long i_id
boolean b_yes
datetime d_xgrq1,d_xgrq2
datastore dw_8
dw_8 = create datastore
ls_dh = dh1
ls_cph = cph1
connect using stock;
new_sql = "select xmh,ylh,hsjs ,sui,sl,id from cost where dh ='" +ls_dh+"'"
new_syntax = SQLCA.SyntaxFromSQL(new_sql, 'Style(Type= grid)', error_syntaxfromSQL)
IF Len(error_syntaxfromSQL) > 0 THEN

messagebox("错误", error_syntaxfromSQL)

ELSE

dw_8.Create(new_syntax, error_create)

IF Len(error_create) > 0 THEN

messagebox("错误", error_create)

END IF

END IF
dw_8.SetTransObject(SQLCA)
i_count = dw_8.Retrieve()
cost where dh = :ls_dh order by xmh using sqlca;
do while i_count >= i_col
ls_xmh = dw_8.getitemstring(i_col,'xmh')
ls_ylh = dw_8.getitemstring(i_col,'ylh')
d_hsjs = dw_8.getitemnumber(i_col,'hsjs')
d_sui = dw_8.getitemnumber(i_col,'sui')
d_sl = dw_8.getitemnumber(i_col,'sl')
i_id = dw_8.getitemnumber(i_col,'id')
if i_id < 0 then
i_id = i_id * -1
end if
d_dj =0.00
b_yes = false
if (trim(ls_xmh) = 'A' or trim(ls_xmh) ='C') and not isnull(ls_ylh) then
select dj ,xgrq into :d_dj,:d_xgrq1 from zlk where cph = :ls_ylh using sqlca;
if d_dj <>0.00 and not isnull(d_dj) then
update cost set ckdj = :d_dj where dh = :ls_dh and ylh =:ls_ylh and id = :i_id using sqlca;
select count(*) into :i_coun from finished where dh = :dh1 and girq >=:d_xgrq1 ;
if i_coun =0 or isnull(i_coun) then
end if
b_yes = true
end if
elseif (trim(ls_xmh) = 'B' or trim(ls_xmh) ='H') and not isnull(ls_ylh) then
select dj,dw into :d_dj,:ls_dw from material where ylh = :ls_ylh using stock;
if d_dj <>0.00 and not isnull(d_dj) then
update cost set ckdj = :d_dj where dh = :ls_dh and ylh =:ls_ylh and id = :i_id and dw =:ls_dw using sqlca;
b_yes = true
end if
elseif trim(ls_xmh) = 'D' and not isnull(ls_ylh) then
select dj ,xgrq into :d_dj,:d_xgrq2 from gz_set where bh = :ls_ylh using sqlca;
if d_dj <> 0.00 and not isnull(d_dj) then
update cost set ckdj =:d_dj where dh =:ls_dh and ylh =:ls_ylh and id = :i_id using sqlca;
select count(*) into :i_coun from finished where dh = :dh1 and girq >=:d_xgrq2 ;
if i_coun =0 or isnull(i_coun) then
end if
b_yes = true
end if
end if
commit using sqlca;
if isnull(d_hsjs) or d_hsjs = 0 then
d_hsjs = 1
elseif isnull(d_sui) or d_sui = 0 then
d_sui = 1
elseif isnull(d_sl) or d_sl = 0 then
d_sl = 1
end if
if d_hsjs >0 and not isnull(ls_ylh) and ls_ylh <>'%' and b_yes = true then
d_je = d_dj / d_hsjs / d_sui * d_sl
d_dj = d_dj / d_hsjs / d_sui
update cost set je = :d_je ,dj = :d_dj where dh = :ls_dh and ylh =:ls_ylh and id = :i_id using sqlca;
elseif d_hsjs <0 and not isnull(ls_ylh) and ls_ylh <> '%' and b_yes = true then
d_je = d_dj * d_hsjs / d_sui * d_sl * -1
d_dj = d_dj * d_hsjs / d_sui * -1
update cost set je = :d_je ,dj = :d_dj where dh = :ls_dh and ylh = :ls_ylh and id = :i_id using sqlca;

end if
commit using sqlca;
i_col = i_col + 1
loop







jlwei888 2009-02-19
  • 打赏
  • 举报
回复
I服了you!
说了半天,你连问题都没说清楚,代码也不全!哪有loop啊!哪有更新啊!
destroy dw_8 是销毁dw_8!

zijiezhuang 2009-02-19
  • 打赏
  • 举报
回复
研究了半天终于找到原因了,不是数据问题。
我在loop 后面加了一句代码 destroy dw_8 。郁闷竟然可以更新了。
原来没加这句就只有部分有更新。真是奇怪的问题。虽然解决了,还是不知道原因。
有知道的告诉小弟一下
pbdesigner 2009-02-18
  • 打赏
  • 举报
回复
检查各栏位长度是否有超过255个字符,检查是否有计算列(后台)计算错误
zijiezhuang 2009-02-18
  • 打赏
  • 举报
回复
2000条是在主表里面,13w条是在明细表 ,主表和明细表的单号是一样的

外面通过每个用户的编号,提取各自的单子的单号和产品号,用do while 循环,上面那个是函数,
update(ls_dh,,ls_cph)进入到里面来,更据明细表里面的各自的项目号,和原料好更新价格
jlwei888 2009-02-18
  • 打赏
  • 举报
回复
晕,现在是你做的有问题,要找原因吗!
不说2000条,怎么又13w了
zijiezhuang 2009-02-18
  • 打赏
  • 举报
回复
datastore dw_8 这边不是有定义了为什么还要做DW?
zijiezhuang 2009-02-18
  • 打赏
  • 举报
回复
做什么DW,我把参数去掉做什么,老大那个表里有13W的数据
jlwei888 2009-02-18
  • 打赏
  • 举报
回复
DW做了吗,这正常吗?

new_sql = "select xmh,ylh,hsjs,sui,sl,id from cost “

把那参数去了,这样能全部显示吗!
zijiezhuang 2009-02-18
  • 打赏
  • 举报
回复
我的意思是说,我把 2000条数据, 前面1000删掉然后执行,没有问题,
把数据还原,把第1001到1999条数据删掉,执行结果都正确
我是以第2000条的数据时候有更新为判断的
zijiezhuang 2009-02-18
  • 打赏
  • 举报
回复
我起初也是这样怀疑的,但是该传的参数都有传进去啊,而且我把数据分成两部分执行.却没有问题
jlwei888 2009-02-18
  • 打赏
  • 举报
回复
如果开始正常,数据多了就不正常,那很可能就是数据问题!

你可以直接做个带参的DW,在PB中直接检索一下试试,看看有问题吗!

610

社区成员

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

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