简体   繁体   English

将oracle迁移到Postgresql UTL_FILE EXCEPTIONS

[英]migrate oracle to Postgresql UTL_FILE EXCEPTIONS

I have the same situation as described in this post: Porting Oracle procedure to PostgreSQL (exception codes from orafce for utl_file module) 我的情况与这篇文章中描述的情况相同:将Oracle过程移植到PostgreSQL(来自orafce的utl_file模块的异常代码)

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'. 我正在使用ora2pg从oracle迁移到postgres,我正在尝试更正'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". 我收到语法错误:错误:“ UTL_FILE”或附近的语法错误。

Please help... 请帮忙...

I've been writing PL/SQL for quite some time and I've never come across the PERFORM imperative. 我已经编写PL / SQL已有一段时间了,而且从未遇到过PERFORM命令。 If this code is to run on an Oracle instance, then I would simply the remove the two "PERFORM" strings. 如果此代码要在Oracle实例上运行,那么我只需删除两个“ PERFORM”字符串。

If this is supposed to run on a POSTGRES instance, then I'd not expect UTL_FILE to exist. 如果应该在POSTGRES实例上运行,那么我不希望存在UTL_FILE。 If it does exist, then maybe the user running the code has not been granted permissions to execute UTL_FILE. 如果确实存在,则可能未授予运行代码的用户执行UTL_FILE的权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM