f_setsysoplog.srf 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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