Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. CREATE OR REPLACE FUNCTION Control_Reports_Pg.daily_control_reports_fn () RETURNS bigint AS $body$
  2. DECLARE
  3. V_Return smallint;
  4. C_Function_Name varchar(200) := 'Daily_Control_Reports_Fn';
  5.  
  6. BEGIN
  7. V_Return := control_reports_pg.control_reports_fn(1::bigint,'daily_log_control_file.txt'::text,'/PostgreSQL/comb_logs'::text);
  8. RETURN V_Return;
  9. EXCEPTION
  10. WHEN OTHERS THEN
  11. PERFORM control_reports_pg.send_error_mail(SQLERRM ,C_Function_Name);
  12. RETURN 1;
  13. END;
  14. $body$
  15. LANGUAGE PLPGSQL
  16. SECURITY DEFINER
  17. ;
  18.  
  19. CREATE OR REPLACE FUNCTION Control_Reports_Pg.control_reports_fn (P_Report_Type bigint, P_Log_File_Name text,C_Path text) RETURNS bigint AS
  20. $body$
  21. DECLARE
  22.  
  23. V_Return smallint;
  24. V_Function_Return smallint:=1;
  25. C_Daily_Reports varchar(300);
  26.  
  27. C_Function_Name varchar(200) := 'Control_Reports_Fn';
  28. Rec_Daily_Reports CONTROL_REPORTS%ROWTYPE;
  29. G_Log_File_Type UTL_FILE.FILE_TYPE;
  30.  
  31. BEGIN
  32.  
  33. -- Open Log File
  34. --PERFORM control_reports_pg.send_error_mail(C_Path ,C_Function_Name);
  35. G_Log_File_Type := UTL_FILE.FOPEN(C_Path, P_Log_File_Name,'w');
  36.  
  37. C_Daily_Reports := 'SELECT REPORT_ORDER,PROCEDURE_NAME,DIRECTORY_NAME,FILE_NAME,TITLE FROM CONTROL_REPORTS WHERE RUN_FLAG=1 AND REPORT_TYPE=' || P_Report_Type || ' ORDER BY REPORT_ORDER';
  38.  
  39. -- RAISE NOTICE '%',C_Daily_Reports;
  40. FOR Rec_Daily_Reports IN EXECUTE C_Daily_Reports LOOP
  41.  
  42.  
  43. PERFORM UTL_FILE.PUT_LINE(G_Log_File_Type,'Procedure_Name = '||Rec_Daily_Reports.Procedure_Name);
  44. PERFORM UTL_FILE.PUT_LINE(G_Log_File_Type,'start time= '|| to_char(clock_timestamp(),'dd/mm/yyyy hh24:mi:ss'));
  45. V_Return := control_reports_pg.chrg_in_bill_not_in_crm_fn(Rec_Daily_Reports.Directory_Name,
  46. Rec_Daily_Reports.File_Name,
  47. Rec_Daily_Reports.Title);
  48.  
  49.  
  50. IF V_Return = 0 THEN
  51. V_Function_Return := 0;
  52. END IF;
  53. ............
  54.  
  55. mydb=> select control_reports_pg.control_reports_fn(1::bigint,'daily_log_control_file.txt'::text,'/PostgreSQL/comb_logs'::text);
  56. NOTICE: FUNC : Control_Reports_Fn, SQLERRM: invalid input syntax for integer: "Chrg_In_Bill_Not_In_Crm_Fn"
  57. NOTICE: Message : invalid input syntax for integer: "Chrg_In_Bill_Not_In_Crm_Fn", Func : Control_Reports_Fn
  58. CONTEXT: SQL statement "SELECT control_reports_pg.send_error_mail(SQLERRM ,C_Function_Name)"
  59. PL/pgSQL function control_reports_pg.control_reports_fn(bigint,text,text) line 339 at PERFORM
  60.  
  61. chrg_in_bill_not_in_crm_fn
  62. ----------------------------
  63. 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement