f_pbd_update.srf 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. $PBExportHeader$f_pbd_update.srf
  2. $PBExportComments$自动更新PBD-- 函数
  3. global type f_pbd_update from function_object
  4. end type
  5. forward prototypes
  6. global subroutine f_pbd_update (string f_dwname, transaction f_tran)
  7. end prototypes
  8. global subroutine f_pbd_update (string f_dwname, transaction f_tran);//f_pbd_update('all',sqlca)//强行更新PBD中所有的数据窗口
  9. //f_pbd_update('',sqlca)//比较日期和时间,更新PBD中所有跟后台的时间不一致的数据窗口
  10. //f_pbd_update('dw_xxx',sqlca)//更新PBD中指定的dw_xxx数据窗口
  11. string ls_con,ls[4],ls_dwsave,ls_datetime,ls_rid,ls_dw,ls_pbd,ls_err
  12. long li,li_rows,ll1,ll2,ll3,ll4
  13. BLOB lblob
  14. ls_pbd="exportdw.pbd"
  15. datastore lds,lds2
  16. lds=create datastore
  17. lds.dataobject='dw_rpts'
  18. lds2=create datastore
  19. lds2.dataobject='dw_rpt_cysx'
  20. lds.settransobject(f_tran)
  21. if f_dwname='' or f_dwname='all' then
  22. ls_con="rfilt='database' and rdname>'0'"//为了减轻此功能更新时间,前台打印dw语法从数据库取
  23. // ls_con="rdname>'0'"//此语句将把所有dw语法更新
  24. else
  25. ls_con="rdname='"+f_dwname+"'"
  26. end if
  27. f_myretrieve2(lds,ls_con)
  28. li_rows=lds.rowcount()
  29. ls[1]=LibraryDirectory(ls_pbd,Dirall!)
  30. lds2.ImportString(ls[1])
  31. lds2.setfilter("pos(#3,'<time:')>0")
  32. lds2.filter()
  33. for li=1 to li_rows
  34. ls_dwsave=lds.getitemstring(li,'rdname')
  35. ls_datetime=lds.getitemstring(li,'rdatetime')
  36. ll1=lds2.find("#1='"+ls_dwsave+"'",1,9999)
  37. if ll1>0 then
  38. ls[2]=f_rsx2(lds2.getitemstring(ll1,3),'<time:','>')
  39. else
  40. ls[2]=''
  41. end if
  42. //PBD中dw时间<>报表最后修改时间,要重新产生dw1
  43. if ls_datetime<>ls[2] or f_dwname='all' then//f_dwname='all'不管日期比较
  44. openwithparm(w_rpt_message,'%正在生成'+ls_dwsave+',请等候......')
  45. ls_rid=lds.getitemstring(li,'rid')
  46. selectblob rsyntax into :lblob from reports where rid=:ls_rid using f_tran;
  47. if f_tran.sqlcode=0 THEN
  48. ls_dw=string(lblob)
  49. if isnull(ls_dw) or ls_dw='' then continue
  50. ls[4]=lds.getitemstring(li,'rcname')+' <time:'+ls_datetime+'>'
  51. if LibraryImport(ls_pbd,ls_dwsave,ImportDataWindow!,ls_dw,ls[3],ls[4])=1 then
  52. else
  53. ls_err=ls_err+char(13)+'创建'+ls_dwsave+'时的错误:'+ls[3]
  54. end if
  55. end if
  56. close(w_rpt_message)
  57. end if
  58. next
  59. destroy lds
  60. destroy lds2
  61. if ls_err>'' then messagebox('提示',ls_err)
  62. return
  63. end subroutine