UTL file exception handling oracle 11g

We use oracle 11g
We use UTL file and exception handling in many place. Thanks in advance.
We have many utl program and we are writing same exception handling code ,copy and paste .
It is possible to create new UTL exception procedure and call it.
I am not sure how to write generic UTL exception procedure and reuse the same.
I am learning oracle etl files method.
Please advise.
sample program 1 :
DECLARE
fileHandler UTL_FILE.FILE_TYPE;
BEGIN
fileHandler := UTL_FILE.FOPEN('test_dir', 'test_file.txt', 'W');
UTL_FILE.PUTF(fileHandler, 'Writing TO a file\n');
UTL_FILE.FCLOSE(fileHandler);
EXCEPTION
when utl_file.invalid_path then
raise_application_error(-20001,
'INVALID_PATH: File location or filename was invalid.');
when utl_file.invalid_mode then
raise_application_error(-20002,
'INVALID_MODE: The open_mode parameter in FOPEN was invalid.');
when utl_file.invalid_filehandle then
raise_application_error(-20002,
'INVALID_FILEHANDLE: The file handle was invalid.');
when utl_file.invalid_operation then
raise_application_error(-20003,
'INVALID_OPERATION: The file could not be opened or operated on as requested.');
when utl_file.read_error then
raise_application_error(-20004,
'READ_ERROR: An operating system error occurred during the read operation.');
when utl_file.write_error then
raise_application_error(-20005,
'WRITE_ERROR: An operating system error occurred during the write operation.');
when utl_file.internal_error then
raise_application_error(-20006,
'INTERNAL_ERROR: An unspecified error in PL/SQL.');
when utl_file.invalid_filename then
raise_application_error(-20010, 'The filename parameter is invalid.');
WHEN OTHERS THEN
IF UTL_FILE.IS_OPEN(fileHandler ) THEN
UTL_FILE.FCLOSE (fileHandler );
END IF;
RAISE;
END;
How to write generic procedure of utl exception handling ?
please advise.
create or replace procedure sp_utl_exception
begin
when utl_file.invalid_path then
raise_application_error(-20001,
'INVALID_PATH: File location or filename was invalid.');
when utl_file.invalid_mode then
raise_application_error(-20002,
'INVALID_MODE: The open_mode parameter in FOPEN was invalid.');
when utl_file.invalid_filehandle then
raise_application_error(-20002,
'INVALID_FILEHANDLE: The file handle was invalid.');
when utl_file.invalid_operation then
raise_application_error(-20003,
'INVALID_OPERATION: The file could not be opened or operated on as requested.');
when utl_file.read_error then
raise_application_error(-20004,
'READ_ERROR: An operating system error occurred during the read operation.');
when utl_file.write_error then
raise_application_error(-20005,
'WRITE_ERROR: An operating system error occurred during the write operation.');
when utl_file.internal_error then
raise_application_error(-20006,
'INTERNAL_ERROR: An unspecified error in PL/SQL.');
when utl_file.invalid_filename then
raise_application_error(-20010, 'The filename parameter is invalid.');
WHEN OTHERS THEN
IF UTL_FILE.IS_OPEN(fileHandler ) THEN
UTL_FILE.FCLOSE (fileHandler );
END IF;
RAISE;
end;

Mahesh Kaila wrote:
Hello,
Common procedure to log exception in log file
create or replace procedure sp_utl_exception (log_dir varchar2, log_file varchar2, exception_msg varchar2)
is
hnd_file   UTL_FILE.file_type;
begin
hnd_file := UTL_FILE.fopen (log_dir, log_file, 'A');
UTL_FILE.put_line (hnd_file, exception_msg);
UTL_FILE.fclose (hnd_file);
exception
when others
then
raise;
end;
Very poor implementation.
a) Absolutely no need for that exception handler in there. It should be removed.
b) As it's a procedure for logging exceptions relating to UTL_FILE, it would seem error prone to be logging the errors with UTL_FILE. For example, what is it supposed to do if the exception is raised because of lack of disk space in those file locations? How is it going to write out the exception with the disk full? Also, if the exception handler is used by multiple processes, then only 1 process at a time can access the log file to write it's exceptions, so it doesn't scale well. Better logging is done by having an autonomous transaction procedure that writes log/trace messages to dedicated table(s). That also means that the logs etc. can be viewed, as appropriate, from any client using SQL (either manually or through a application written to view logs etc.), rather than requiring physical/remote access to the server o/s to go and view the contents of the file, which in itself could lock the file and prevent any process from writing further logs whilst it's being used.

Similar Messages

  • How to change archivelog file size in oracle 11g

    Hello,
    In my oracle 11g database inside flash recovery area how to increase each files size , now it 41 Mb per file iits name is o1_mf_1_161_8mfpwtbj_.arc how to change it to
    the understandable name.
    Thanks and regards

    Hi,
    As you know archived log is create when online log is switch. Archived log size might be maximum equal to online redo log size.
    Because archived log size is copied from online redo log file, if you want change archived redo log size, then you must change online redo log size.
    But you must think, what is advantages and disadvantages of change of online redo log size, it depends direct task LGWR process.
    You can change archived redo log name with change LOG_ARCHIVE_FORMAT parameter.
    See : http://docs.oracle.com/cd/B19306_01/server.102/b14237/initparams103.htm
    Regards
    Mahir M. Quluzade

  • No rootpre.sh file found in Oracle 11g r1 download for AIX

    I downloaded the 11.1.0.6.0 version of Oracle 11g from the website and unzipped it with the unzip_aix on a Power7 system. The files were unzipped into a directory called database. I could not find the rootpre.sh script anywhere. What am I missing?
    The download site mentions a rootpre_aix.zip file for downloads prior to January 2008... confused and unexperienced. Wouldn't any download be after 2008?
    Edited by: user8962451 on Apr 2, 2010 7:34 AM

    Same here. The installation instructions for Oracle in AIX is asking to run the preRoot.sh. Where can I get it this file, since I do not have Oracle CD.

  • Exception HAndling B2B 11g .AQ Integration

    Trying to catch the B2B exception for 850 and send it to SOA. I have used AQ integration for B2B.Please tell me how to implement this in soa

    All the B2B errors/exceptions get enqueued to IP_IN_QUEUE (by default) in a proper format (ipException.xsd defines the structure) and has recipient name b2berroruser. You may create your own process for dequeing those exception messages and perform error handling.
    You may also configure a custom error queue (JMS) if you do not want to use IP_IN_QUEUE (which is an AQ). For all details, you may refer the user guide -
    http://download.oracle.com/docs/cd/E17904_01/integration.1111/e10229/app_except.htm#BCEIEEFF
    Regards,
    Anuj

  • Is there any limitation to create file watcher in oracle 11g scheduler

    Hi,
    Below are the version details where I am working.
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE 11.2.0.2.0 Production"
    TNS for 32-bit Windows: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    I tried to create a file watcher. But I got below error.
    begin
        dbms_scheduler.create_file_watcher
          (file_watcher_name => 'file_watcher',
           directory_path => 'F:\Aswadhati\workfile',
           file_name => 'example.txt',
           credential_name => 'external_user',
           enabled => TRUE);
    end;
    Error report:
    ORA-03001: unimplemented feature
    ORA-06512: at "SYS.DBMS_ISCHED", line 3702
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 2632
    ORA-06512: at line 2
    03001. 00000 -  "unimplemented feature"
    *Cause:    This feature is not implemented.
    *Action:   None.

    In the enterprise edition I am able to create all the below objects.But The job is not running after file arrival.
    Could you please me in this case also.
    BEGIN
      DBMS_SCHEDULER.create_credential(
        credential_name => 'LOCAL_CREDENTIAL',
        username        => 'upncommon',
        password        => '*******');
    END;
    BEGIN
      DBMS_SCHEDULER.create_file_watcher(
        file_watcher_name => 'test_file_watcher',
        directory_path    => '/home/upncommon/pub',
        file_name         => 'sample2.sh',
        credential_name   => 'LOCAL_CREDENTIAL',
        destination       => NULL,
        enabled           => FALSE);
    END;
    BEGIN
      DBMS_SCHEDULER.create_program(
        program_name        => 'file_watcher_test_prog',
        program_type        => 'STORED_PROCEDURE',
        program_action      => 'PROC_SCH',
        number_of_arguments => 1,
        enabled             => FALSE);
    END;
    BEGIN
      DBMS_SCHEDULER.define_metadata_argument(
        program_name       => 'file_watcher_test_prog',
        metadata_attribute => 'event_message',
        argument_position  => 1);
    END;
    BEGIN
      DBMS_SCHEDULER.create_job(
        job_name        => 'file_watcher_test_job',
        program_name    => 'file_watcher_test_prog',
        event_condition => NULL,
        queue_spec      => 'test_file_watcher',
        auto_drop       => FALSE,
        enabled         => FALSE);
    END;
    BEGIN
      DBMS_SCHEDULER.set_attribute('file_watcher_test_job','parallel_instances',TRUE);
    END;
    EXEC DBMS_SCHEDULER.enable('test_file_watcher');
    EXEC DBMS_SCHEDULER.enable('file_watcher_test_prog');
    EXEC DBMS_SCHEDULER.enable('file_watcher_test_job');

  • Fault/Exception handling in 11g

    Does anyone have any best practices or approaches they can share on how to deal with faults (at the BPMN process level, not human tasks) in 11g?
    I'm referring mostly to system faults, not business faults.

    Maybe I should have looked at the new schema first.... : }
    It's now reference:
    <?xml version="1.0" encoding="UTF-8"?>
    <faultPolicyBindings version="2.0.1" xmlns="http://schemas.oracle.com/bpel/faultpolicy">
    *<reference faultPolicy="GetDateFaultPolicy">*
    <name>GetDateService</name>
    *</reference>*
    </faultPolicyBindings>
    Edited by: Brutus35 on Sep 16, 2010 10:42 AM

  • Oracle 11g init.ora file

    1) I am a bit confused with init.ora file format in oracle 11g. In addition=
    to the usual entries that are prefixed with *.<parameter>, it also has ent=
    ries prefixed with <sid>.__<parameter>. I am not able to find an explanatio=
    n of these <sid>__ entries from oracle 11g documentation. I am told by a co=
    lleague that they are for instance, to cater for multiple-instances databa=
    ses. Is that correct?
    2) The presence of the <sid>.__ entries confuse me since some parameters ap=
    pear in both <sid>__ and *. sections. What if the values for the same param=
    eter are different, which one is used by oracle? I guess it's the <sid>.__ =
    one?=20
    3) In my case the database has only 1 instance, so I guess I can remove all=
    <sid>.__ entries and only work with *. entries?
    Thanks
    Long

    Hi,
    the entries with double underscore in the spfile that you mention are not new in 11g but also show up in 10g.
    They are caused by the background process MMAN (Memory Manager), that is active if you set SGA_TARGET>0 (in 10g) rsp. MEMORY_TARGET>0 (in 11g).
    This MMAN modifies the Oracle Memory components like the shared pool and the buffer cache, using performance statistics captured by the MMON (Manageability Monitor) and storing the new size of the component in the spfile in order to make that size persistent through instance restarts.
    The prefix of the SID is meaningless in case of a non-RAC database.
    Kind regards
    Uwe
    http://uhesse.wordpress.com

  • Spooling file in Oracle 11g

    Hi,
    I am spooling one file from database(oracle 11g), but the output file contains jumbled line as compare to original source file.
    I am using following script to spool out the source?:
    spool pkg_ta_search.sql     
         select text from all_source where name = upper('pkg_ta_search');
    spool off
    I even used the order by line clause but still I am getting the same reult.
    Thanks
    Kaushal

    Hii, Kaushal,
    Welcome to the forum!
    Both the package spec (or head) and the package body will have the same name. You need to add something to the WHERE clause (or the ORDER BY clause) to keep them separate.
    You probably want something like this:
    SELECT       text
    FROM       user_source               -- or all_source; see note below
    WHERE       name     = 'PKG_TA_SEARCH'
    AND       type     = 'PACKAGE BODY'     -- Or just 'PACKAGE'
    ORDER BY  line;Maybe there are other schemas that also have a package called 'PKG_TA_SEARCH'. User_source contains information about objects in your schema only. If the package really is in another schema, the you have to use all_souce, but add
    AND       owner = 'FUBAR'    -- or whateverto the WHERE clause.

  • Oracle 11g : Directory and UTL_FILE - ORA-29280: invalid directory path

    Hi,
    I have Oracle 11g server on a UNIX box and im accessing it through an Oracle client on a windows box.
    Im new to File operations in Oracle 11g. Have couple of questions;
    1. Can i create a directory in Oracle using CREATE DIRECTORY statment which points to my local machine (windows: on which Oracle client is running).
    for e.g. CREATE OR REPLACE DIRECTORY c_temp AS 'd:\test';
    2. If i can create such a directory, can i use the UTL_FILE.fopen command to open a file from the windows machine and append some text to it.
    Or
    We can only create direcories that are present in the Oracle Server?
    Your help is appreciated.
    Thanks.
    Edited by: user533016 on Feb 1, 2011 3:14 AM

    user533016 wrote:
    Hi,
    I have Oracle 11g server on a UNIX box and im accessing it through an Oracle client on a windows box.
    Im new to File operations in Oracle 11g. Have couple of questions;
    1. Can i create a directory in Oracle using CREATE DIRECTORY statment which points to my local machine (windows: on which Oracle client is running).
    for e.g. CREATE OR REPLACE DIRECTORY c_temp AS 'd:\test';
    2. If i can create such a directory, can i use the UTL_FILE.fopen command to open a file from the windows machine and append some text to it.Though it is not recommended, you could do this with a samba share (I haven't tried it myself yet).
    Or
    We can only create direcories that are present in the Oracle Server?That's what is recommended for various reasons.

  • MYSQL to Oracle 11G R2

    Hello
    I am trying to import a MySQL dump file to a Oracle 11G R2 database. Has anyone done this before? I have sqldeveloper installed but, am not sure if I can use that tool to import a .sql MySQL file. Anyone know of a good reference guide..or even better has anyone done this before?
    Brian Sims

    I am still stuck, so I think I can use the offline method in SQL Developer but I am not sure how to create the migration repository? Any ideas. I check in the documentation link but it does not give a good explanation of what to do for offline migrations. Do you or anyone know of a document that goes into that more deeply?
    The guy that gave me this data dump was doing me a favor I would rather not ask him to export it a different way if I did not absolutely have to.
    Any help would be appreciated, Thanks
    Brian Sims

  • Oracle 11g: Block Corruption in SYSAUX File

    Hello All,
    I am facing Data corruption issue in the SYSAUX file.
    We are using Oracle 11G (Microsoft 32 bit) and our system is running in noarchivelog mode.
    Following are the errors in the alert log.
    e:\sc\sc15.2\databases\oracleconfig\diag\rdbms\enmscsdb\nm45\trace\nm45_p000_5944.trc
    Corrupt block relative dba: 0x0088a9f8 (file 2, block 567800)
    Fractured block found during buffer read
    Data in bad block:
    type: 6 format: 2 rdba: 0x0088a9f8
    last change scn: 0x0000.0b3bb7c7 seq: 0x1 flg: 0x04
    spare1: 0x0 spare2: 0x0 spare3: 0x0
    consistency value in tail: 0xc7000601
    check value in block header: 0xee6b
    computed block checksum: 0x72c6
    Reread of rdba: 0x0088a9f8 (file 2, block 567800) found same corrupted data
    Thu Jan 22 16:46:44 2009
    SMON: Restarting fast_start parallel rollback
    SMON: ignoring slave err,downgrading to serial rollback
    ORACLE Instance nm45 (pid = 12) - Error 1578 encountered while recovering transaction (9, 11) on object 458.
    Errors in file e:\sc\sc15.2\databases\oracleconfig\diag\rdbms\enmscsdb\nm45\trace\nm45_smon_6492.trc:
    ORA-01578: ORACLE data block corrupted (file # 2, block # 567800)
    ORA-01110: data file 2: 'E:\SC\SC15.2\DATABASES\ORACLECONFIG\SYSAUXNM45.ORA'
    Thu Jan 22 16:46:45 2009
    Trace dumping is performing id=[cdmp_20090122164645]
    Corrupt Block Found
    TSN = 1, TSNAME = SYSAUX
    RFN = 2, BLK = 567800, RDBA = 8956408
    OBJN = 458, OBJD = 458, OBJECT = I_WRI$_OPTSTAT_HH_OBJ_ICOL_ST, SUBOBJECT =
    SEGMENT OWNER = SYS, SEGMENT TYPE = Index Segment
    Following query indicates the corruption is in index.
    SQL> SELECT tablespace_name, segment_type, owner, segment_name FROM dba_extents
    WHERE file_id = 2 and 567800 between block_id AND block_id + blocks - 1;
    TABLESPACE_NAME SEGMENT_TYPE OWNER
    SEGMENT_NAME
    SYSAUX INDEX SYS
    I_WRI$_OPTSTAT_HH_OBJ_ICOL_ST
    ==============
    DBverify output:
    ==============
    E:\SC\SC15.2\Databases\OracleConfig>dbv file=SYSAUXNM45.ORA blocksize=8192
    DBVERIFY: Release 11.1.0.7.0 - Production on Thu Jan 22 16:59:11 2009
    Copyright (c) 1982, 2007, Oracle. All rights reserved.
    DBVERIFY - Verification starting : FILE = E:\SC\SC15.2\Databases\OracleConfig/SY
    SAUXNM45.ORA
    DBV-00200: Block, DBA 8956312, already marked corrupt
    Page 567800 is influx - most likely media corrupt
    Corrupt block relative dba: 0x0088a9f8 (file 2, block 567800)
    Fractured block found during dbv:
    Data in bad block:
    type: 6 format: 2 rdba: 0x0088a9f8
    last change scn: 0x0000.0b3bb7c7 seq: 0x1 flg: 0x04
    spare1: 0x0 spare2: 0x0 spare3: 0x0
    consistency value in tail: 0xc7000601
    check value in block header: 0xee6b
    computed block checksum: 0x72c6
    DBVERIFY - Verification complete
    Total Pages Examined : 1623864
    Total Pages Processed (Data) : 540984
    Total Pages Failing (Data) : 0
    Total Pages Processed (Index): 964944
    Total Pages Failing (Index): 0
    Total Pages Processed (Other): 17849
    Total Pages Processed (Seg) : 0
    Total Pages Failing (Seg) : 0
    Total Pages Empty : 100086
    Total Pages Marked Corrupt : 2
    Total Pages Influx : 1
    Total Pages Encrypted : 0
    Highest block SCN : 190789648 (0.190789648)
    SQL> select * from v$database_block_corruption;
    FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO
    2 567800 1 0 FRACTURED
    2 567704 1 0 FRACTURED
    How to resolve this issue.
    Thanks
    With Regards
    Hemant Joshi.

    Drop and re-creating the index would be better than re-building the index.
    Check the metalink note: Identify the corruption extension using RMAN/DBV/ANALYZE etc - 836658.1
    Note 28814.1 - Handling Oracle Block Corruptions in Oracle7/8/8i/9i/10g
    Note 472231.1 - How to identify all the Corrupted Objects in the Database reported by RMAN
    ORA-1578 Main Reference Index for Solutions -830997.1

  • How to handle Exceptions in Oracle Report Builder 10.1.2.0.2?

    We are using Oracle Reports Builder 10g 10.1.2.0.2, Windows XP with Oracle 10g database. The reports are converted into JSP reports.
    How and where do we write exception handling code in Reports Builder? We want to achieve the following:
    1. Display a customized JSP page with customized error message
    2. Allow users to cancel the report execution, if possible and then direct them to the parameter form with all the values they entered before.
    Once we write these codes in the Oracle Report Builder where will it show in .jsp files?
    Thanks
    Hemant

    this link may be helpful:
    http://www.oracle.com/webapps/online-help/reports/10.1.2/topics/htmlhelp_rwbuild_hs/rwwhthow/whatare/pformobj/a_pf_web.htm

  • Ora 24960 exception with VC9 and Oracle 11g - 11.1.0.6.0 client

    Hi,
    We have developed a OCCI client application using 10g express edition and visual studio 2003. It was working fine. Now we have migrated to 11g (11.1.0.6.0) client with visual studio 2008. VC version 9. We have migrated all .dll and .lib files based on oracles following link.
    http://www.oracle.com/technology/tech/oci/occi/occidownloads.html
    Now while trying to make connection it's throwing ORA 24960 exception. (the attribute OCI_ATTR_USERNAME is greater than the maximum allowable length of 255)
    but the attribute length is very less.
    connection = env->createConnection (oraUser,OraPass,conne);
    Anybody can help immediately please?

    Hi,
    Are you compiling in debug mode and using the Instant Client SDK by chance? If so, I suggest taking a look at My Oracle Support Note:747933.1 (ORA-24960 Error When Trying to Connect in Debug Mode With OCCI Instant Client). Essentially the issue is that the OCCI files included with Instant Client SDK do not include the oraocci11d.lib library.
    Regards,
    Mark

  • Does anybody know how Oracle load large N-Triple file into Oracle 11g R1?

    Does anybody know how Oracle load large N-Triple(NT) file into Oracle 11g R1 by using sql*loader according to their benchmark results?
    Their benchmark results indicate they have over come the large data set problem.
    http://www.oracle.com/technology/tech/semantic_technologies/htdocs/performance.html
    It means they have loaded LUBM 8000(1.068 Billion+ Triples) into Oracle successfully, but there is no detailed steps provided. For instance, 32-bit or 64-bit platform they used, only one NT file being used corresponding to one dataset or several NT files?
    Is there any exception occured during the loading process if the NT file beyond 60GB? When using jena to generate NT file against LUBM(8000), the size of the NT file would definitely beyond 60GB.
    We are dividing such large NT file into several small ones? Is it a good approach? I'm hesitating to do so!

    A Linux 32-bit platform was used for bulk-load of LUBM-8000 1.106 billion (before duplicate elimination) RDF triples into Oracle.
    Multiple gzipped N-Triple files were used to hold the LUBM-8000 data. zcat was used on all these files together to send the complete data into a named pipe. SQL*Loader used this named pipe as the input data file to load the data into a staging table in Oracle. Once the staging table was loaded, the sem_apis.bulk_load_from_staging_table API was used to load the data into Oracle Semantic Store.
    (Additional details in http://www.oracle.com/technology/tech/semantic_technologies/htdocs/performance.html )
    Thanks.

  • Not getting email notifications in Oracle AIA Exception handling

    We are using Oracle AIA Exception Handling feature. In the BPEL process , we have catch branches defined. From the catch brances we are invoking AIAAsyncErrorHandlerBPELProcess.
    In case of an exception , the instance of AIAAsyncErrorHandlerBPELProcess and AIAReadJMSNotification is being created. We have configured ns_emails.xml and user_properties.xml as per the documentation.
    We are not receiving any emails.
    I have tried a BPEL process with email activity. Email was sent from this process.
    Kindly let us know the issue.

    Please ensure you are following all 4 steps mentioned in this blog article, http://blogs.oracle.com/aia/2009/09/aia_error_notifications.html.
    If the issue still persists, please look for an error message in opmn log file and post it here.
    Regards
    Rohit

Maybe you are looking for