f_update_ins_flowdef.srf 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. $PBExportHeader$f_update_ins_flowdef.srf
  2. global type f_update_ins_flowdef from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_update_ins_flowdef (boolean arg_ifcommit, ref string arg_msg)
  6. end prototypes
  7. global function integer f_update_ins_flowdef (boolean arg_ifcommit, ref string arg_msg);int rslt=1
  8. long ls_i
  9. long cnt
  10. long ll_flowid,ll_funcid
  11. string ls_flowname,ls_sortnum,ls_flowtype
  12. for ls_i = 1 to UpperBound(s_oaflow_def)
  13. ll_flowid = s_oaflow_def[ls_i].flowid
  14. ls_flowname = s_oaflow_def[ls_i].flowname
  15. ls_sortnum = string(s_oaflow_def[ls_i].flowid)
  16. ls_flowtype = s_oaflow_def[ls_i].flowtype
  17. // ll_funcid = s_oaflow_def[ls_i].funcid
  18. if ll_flowid = 0 or isnull(ll_flowid) then
  19. continue
  20. end if
  21. cnt = 0
  22. select count(*)
  23. into :cnt
  24. from OA_FLOWDEF
  25. where flowid = :ll_flowid using sqlca;
  26. if sqlca.sqlcode<>0 then
  27. rslt = 0
  28. arg_msg = '查询操作失败:'+sqlca.sqlerrtext
  29. goto ext
  30. end if
  31. if cnt=0 then
  32. insert into OA_FLOWDEF
  33. (flowid,flowname,sortnum,flowtype,funcid)
  34. values(:ll_flowid,:ls_flowname,:ls_sortnum,:ls_flowtype,:ll_funcid) using sqlca;
  35. if sqlca.sqlcode<>0 then
  36. rslt = 0
  37. arg_msg = '插入操作失败:'+sqlca.sqlerrtext
  38. goto ext
  39. end if
  40. else
  41. update OA_FLOWDEF
  42. set flowname = :ls_flowname,
  43. sortnum = :ls_sortnum,
  44. flowtype = :ls_flowtype,
  45. funcid = :ll_funcid
  46. where flowid = :ll_flowid using sqlca;
  47. if sqlca.sqlcode<>0 then
  48. rslt = 0
  49. arg_msg = '更新操作失败:'+sqlca.sqlerrtext
  50. goto ext
  51. end if
  52. end if
  53. next
  54. ext:
  55. if arg_ifcommit and rslt=1 then
  56. commit using sqlca;
  57. elseif rslt=0 then
  58. rollback using sqlca;
  59. end if
  60. return rslt
  61. end function