f_setwarebalc_log.srf 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. $PBExportHeader$f_setwarebalc_log.srf
  2. global type f_setwarebalc_log from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_setwarebalc_log (long arg_balcdateint, long arg_storageid, integer arg_type, ref string arg_msg, boolean arg_ifcommit)
  6. end prototypes
  7. global function integer f_setwarebalc_log (long arg_balcdateint, long arg_storageid, integer arg_type, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  8. DateTime server_datetime
  9. SELECT Top 1 getdate() INTO :server_datetime FROM u_user;
  10. IF sqlca.SQLCode <> 0 THEN
  11. rslt = 0
  12. arg_msg = "查询操作失败,日期 "
  13. GOTO ext
  14. END IF
  15. IF arg_type = 0 THEN //结存
  16. INSERT INTO u_warebalc_log
  17. (balcdateint,
  18. storageid,
  19. opemp,
  20. opdate)
  21. VALUES
  22. (:arg_balcdateint,
  23. :arg_storageid,
  24. :publ_operator,
  25. :server_datetime);
  26. IF sqlca.SQLCode <> 0 THEN
  27. rslt = 0
  28. arg_msg = '插入结存日志失败'+'~n'+sqlca.SQLErrText
  29. GOTO ext
  30. END IF
  31. ELSE //反结存
  32. DELETE FROM u_warebalc_log
  33. WHERE balcdateint = :arg_balcdateint
  34. AND storageid = :arg_storageid;
  35. IF sqlca.SQLCode <> 0 THEN
  36. rslt = 0
  37. arg_msg = '删除结存日志失败'+'~n'+sqlca.SQLErrText
  38. GOTO ext
  39. END IF
  40. END IF
  41. ext:
  42. IF rslt = 0 THEN
  43. ROLLBACK;
  44. ELSEIF arg_ifcommit AND rslt = 1 THEN
  45. COMMIT;
  46. END IF
  47. RETURN rslt
  48. end function