0

I have the same situation as described in this post: Porting Oracle procedure to PostgreSQL (exception codes from orafce for utl_file module)

I'm migrating from oracle to postgres with ora2pg and I`m trying to correct the syntax of the exception handling that I have for 'utl_file'. Someone commented a solution in the other post but I didn't understand how to properly apply it.

I have the next code :

   V_Step := 1;

    FOR Rec_Report IN C_Report LOOP

      V_Counter := V_Counter + 1;

      -- Header
      IF V_Counter = 1 THEN

         -- Open File
        V_File_Type := UTL_FILE.FOPEN(V_Dir_Name, V_File_Name,'w');

        V_Step := 2;

        bl_create_flat_file_pg.open_html(V_File_Type);
         .......
         .......
         .......

          V_Step :=10

EXCEPTION
when UTL_FILE.INVALID_PATH then
PERFORM control_reports_pg.send_error_mail('invalid_path 
V_Step'||V_Step,C_Function_Name);
PERFORM UTL_FILE.FCLOSE(V_File_Type);

when UTL_FILE.INVALID_MODE then
PERFORM control_reports_pg.send_error_mail('INVALID_MODE  
 V_Step'||V_Step,C_Function_Name);
     PERFORM  UTL_FILE.FCLOSE(V_File_Type);

Therefore for every step I have a piece of code like this that handles the exception. I get a syntax error : ERROR: syntax error at or near "UTL_FILE".

Please help...

4

1 回答 1

0

我编写 PL/SQL 已经有一段时间了,但我从来没有遇到过 PERFORM 命令。如果此代码要在 Oracle 实例上运行,那么我只需删除两个“PERFORM”字符串。

如果这应该在 POSTGRES 实例上运行,那么我不希望 UTL_FILE 存在。如果确实存在,那么运行代码的用户可能没有被授予执行 UTL_FILE 的权限。

于 2017-07-05T18:18:54.733 回答