f_setsysoplog.srf 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. $PBExportHeader$f_setsysoplog.srf
  2. global type f_setsysoplog from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_setsysoplog (string arg_logtype, string arg_dscrp, ref string arg_msg, boolean arg_ifcommit)
  6. end prototypes
  7. global function integer f_setsysoplog (string arg_logtype, string arg_dscrp, ref string arg_msg, boolean arg_ifcommit);//f_setsysoplog(arg_logtype,arg_dscrp,arg_msg,arg_ifcommit)
  8. int rslt = 1
  9. long logid = 0,maxid
  10. //****trycreate_sys_oplog
  11. long cnt
  12. string createsql_string,t_str
  13. //createsql_string="create table sys_oplog ( logid int not null primary key, logtype char (20) not null default ('') , dscrp varchar (250) not null default ('') ,optime datetime null, opemp char(10) null )"
  14. //t_str="select count(*) from sys_oplog"
  15. //
  16. //execute immediate :t_str;
  17. //if sqlca.sqlcode<>0 then //不存在该表,建立
  18. //
  19. // execute immediate :createsql_string ;
  20. //
  21. // if sqlca.sqlcode<>0 then
  22. // arg_msg='建立表sys_oplog失败>>'+sqlca.sqlerrtext
  23. // rollback ;
  24. // rslt=0
  25. // goto ext
  26. // else
  27. // commit ;
  28. // end if
  29. //end if
  30. //********************
  31. select max(logid) into :maxid from sys_oplog;
  32. if sqlca.sqlcode <> 0 then
  33. maxid = 10
  34. end if
  35. if isnull(maxid) then maxid = 10
  36. logid = maxid + 1
  37. insert into sys_oplog
  38. ( logid,
  39. logtype,
  40. dscrp,
  41. optime,
  42. opemp )
  43. values ( :logid,
  44. :arg_logtype,
  45. :arg_dscrp,
  46. getdate(),
  47. :publ_operator ) ;
  48. if sqlca.sqlcode <> 0 then
  49. rollback;
  50. rslt = 0
  51. goto ext
  52. end if
  53. ext:
  54. if rslt = 1 and arg_ifcommit then
  55. commit;
  56. end if
  57. return rslt
  58. end function