UTL FILE or SQLLDR??

I need some opinions about this, I need to load a big file more than 600 fields into a table and I am trying to decide what will be the best method, (sqlldr or UTL_FILE?) I have good luck with sqlldr, I like the report that the CTL file generates, but I am curious about the UTL_FILE, i never done this way but I have good examples that I can follow, I just want to ask you guys before I start coding.
The example of the UTL FILE willl be something like this:
BEGIN
         v_path     :=        'MIDD_DATA' ;
      ---v_path :=         '/u02/sct/dat_files';
      v_file_in1 := UTL_FILE.fopen (v_path, 'finaid.idoc', 'r', '3806');
      w_record_count := 0;
      w_load_date := TRUNC (SYSDATE);
      w_recno := 0;
      BEGIN
         LOOP
            g_bad_ssn_ind := FALSE;
            w_recno := w_recno + 1;
            UTL_FILE.get_line (v_file_in1, v_record);
            w_college_code := RTRIM (SUBSTR (v_record, 0001, 4));
           w_academic_year_code := RTRIM (SUBSTR (v_record, 0005, 2));
            w_idoc_id_number := RTRIM (SUBSTR (v_record, 0007, 7));
            w_student_notification_date := RTRIM (SUBSTR (v_record, 0014, 8));THEN i will insert the variables in the table

If you are loading a file, use SQL*Loader or external tables. There is no reason to write, debug, and maintain all the UTL_FILE code when SQL*Loader and external tables already have it for you.
Justin

Similar Messages

  • How can i create  excel sheet with multiple tabs using utl file?

    how can i create excel sheet with multiple tabs using utl file?
    any one help me?

    Jaggy,
    I gave you the most suitable answer on your own thread yesterday
    Re: How to Generating Excel workbook with multiple worksheets

  • Is there a way on maxdb to force netbackup to use different initSID.utl fil

    (This thread refers to a question that was posted to a blog and where the proper location to handle it is this forum)
    Is there a way on maxdb to force netbackup to use different initSID.utl files ? I have try to do it with different bsi.env file . But if i start the backup it keep on asking for the default bsi.env file in /sapdb/data/wrk/SID directory . I have set the variable BSI.ENV to the new file but it looks like it ignore it. Its on a sun solaris operating system
    Due to security reasons the DBM server process does no longer inherit environment variables from its caller, e.g. dbmcli.
    see PTS 1155045, as especially in the area of external backup tools inheriting environment settings seem to be rather common.
    Idea is to add BSI_ENV to the dbm.cfg file with a command like:
      dbmcli -d ... -u ... dbm_configset BSI_ENV
    For further information please refer to this documentation section
    or for Backint also here 
    Best regards
    Jörg

    Hi Jörg,
    hmmm. I'd guess there are some problem with for which user the environment variables have been defined...
    Anyhow, usually it's easier not to use the environment variables but to provide the dbm-server it's own runtime variables via dbm_configset.
    Check the old thread archive_stage and archive_stage_repeat to different NSR_POOLs for an example application of this.
    regards,
    Lars

  • Utl file in report

    hai all,
    I have to develop a report using utl file.
    Like when the report is given a parameter some four columns are displayed, at the same time i want to write the data in a text file in the server path /usr/tmp.
    used formula column for utl file open , putline etc.
    While running i am getting the error
    REP-1401:'cf_1formula', Fatal PL/SQL error occured.
    ORA-00600:internal error code , argument :[kghal02],[oxo],[],[],[],[],[]
    can anyone suggest me a solution for this or there is any other solution for using utl file in oracle reports.
    I am in urgent need of it.
    Thamks and regards,
    aaditya

    Make sure that the directory you use with UTL_FILE is writable. For example, if you use /abc/xyz, then both directories (abc and xyz) should be writable.

  • Cretaion of UTL.File in Oracle 10G and directory entry in Ora.ini file

    Hi,
    Kindly advise me if:
    (!) we can create a directory and log file in this directory on some other server instead of creating it in the file system of the server where the Oracle 10G database is residing?
    Created directory in Oracle using create or replace directory command.
    My package will be creating a log file using UTL.File in the above directory.
    I want to create this directory on some other server to save my log file/s. Is this possible?
    (2) Also, let me know in Oracle 10G, do we need to add the directory entry (mention above in #1) in the Ora.ini file on the Oracle 10G server?

    Hi,
    1) utl_dir are different from directory object
    2) you cannot create directory on remote server and there is no need to write directory entry on oracle init file (not ini..)
    Acr

  • Error using UTL File

    Hi,
    I am using UTL file to export data to an external file and getting an error which i am unable to reslove... Can anyone help me with this
    SQL> create or replace
    2 procedure MEXICO_NAFTA_CERTIFICATE_EXT (
    3 f_org_id varchar2,
    4 f_customer_nbr_base varchar2,
    5 f_customer_nbr_sufx varchar2,
    6 f_year VARCHAR2)
    7 is
    8 output_file utl_file.file_type;
    9 o_filename VARCHAR2(50):= 'MEXICO_NAFTA_CERTIFICATE_EXT.txt';
    10 o_DataDir CONSTANT VARCHAR2 (30) := '/d014/oradata/temp';
    11 v_CERTIFICATE_NBR fta.SAP_CERTIFICATES_EXTRACT_VIEW.CERTIFICATE_NBR%type;
    12 v_PART171 fta.SAP_CERTIFICATES_EXTRACT_VIEW.PART171%type;
    13 v_INACTIVE_IND fta.SAP_CERTIFICATES_EXTRACT_VIEW.INACTIVE_IND%type;
    14 v_HTS_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.HTS_CDE%type;
    15 v_ORIGINATING_IND fta.SAP_CERTIFICATES_EXTRACT_VIEW.ORIGINATING_IND%type;
    16 v_ISO_COUNTRY_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.ISO_COUNTRY_CDE%type;
    17 v_BASIS_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.BASIS_CDE%type;
    18 v_PRODUCER_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.PRODUCER_CDE%type;
    19 v_CERT_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.CERT_CDE%type;
    20 v_REGIONAL_VALUE_CONTENT_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.REGIONAL_VALUE_CONTENT_CDE%type;
    21 v_PART_NBR fta.SAP_CERTIFICATES_EXTRACT_VIEW.PART_NBR%type;
    22 v_EFFECTIVE_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.EFFECTIVE_DATE%type;
    23 v_EFFECTIVE_FROM_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.EFFECTIVE_FROM_DATE%type;
    24 v_EFFECTIVE_TO_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.EFFECTIVE_TO_DATE%type;
    25 v_TRANSACTION_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.TRANSACTION_DATE%type;
    26
    27
    28 CURSOR Cert_ext IS select certificate_nbr ,
    29 part171,
    30 inactive_ind,
    31 hts_cde,
    32 originating_ind,
    33 iso_country_cde,
    34 basis_cde,
    35 producer_cde,
    36 cert_cde,
    37 regional_value_content_cde,
    38 part_nbr,
    39 effective_date,
    40 effective_from_date,
    41 effective_to_date,
    42 transaction_date
    43 from fta.SAP_CERTIFICATES_EXTRACT_VIEW
    44 where org_id= f_org_id AND
    45 customer_nbr_base= f_customer_nbr_base AND
    46 customer_nbr_sufx = f_customer_nbr_sufx AND
    47 to_char(effective_from_date, 'yy') = f_year AND
    48 to_char(effective_to_date, 'yy') = f_year;
    49
    50 begin
    51
    52 output_File := UTL_FILE.FOPEN (o_DataDir, o_FileName, 'w');
    53
    54 OPEN Cert_ext;
    55 loop
    56
    57 fetch Cert_ext into v_CERTIFICATE_NBR ,
    58 v_PART171 ,
    59 v_INACTIVE_IND,
    60 v_HTS_CDE ,
    61 v_ORIGINATING_IND ,
    62 v_ISO_COUNTRY_CDE ,
    63 v_BASIS_CDE ,
    64 v_PRODUCER_CDE ,
    65 v_CERT_CDE ,
    66 v_REGIONAL_VALUE_CONTENT_CDE ,
    67 v_PART_NBR,
    68 v_effective_date,
    69 v_effective_from_date,
    70 v_effective_to_date,
    71 v_transaction_date ;
    72
    73 UTL_FILE.PUT_LINE (output_File, v_CERTIFICATE_NBR || ' '||
    74 v_PART171 || ' '||
    75 v_INACTIVE_IND || ' '||
    76 v_HTS_CDE || ' '||
    77 v_ORIGINATING_IND || ' '||
    78 v_ISO_COUNTRY_CDE || ' '||
    79 v_BASIS_CDE || ' '||
    80 v_PRODUCER_CDE || ' '||
    81 v_CERT_CDE || ' '||
    82 v_REGIONAL_VALUE_CONTENT_CDE || ' '||
    83 v_PART_NBR || ' '||
    84 to_char(v_EFFECTIVE_DATE, 'mm-dd-yy') || ' '||
    85 to_char(v_EFFECTIVE_FROM_DATE, 'mm-dd-yy') || ' '||
    86 to_char(v_EFFECTIVE_TO_DATE, 'mm-dd-yy') || ' '||
    87 to_char(v_TRANSACTION_DATE, 'mm-dd-yy'));
    88
    89 UTL_FILE.FCLOSE (output_File);
    90 DBMS_OUTPUT.PUT_LINE ('Data Extracted');
    91 end loop;
    92 close Cert_ext;
    93 END MEXICO_NAFTA_CERTIFICATE_EXT;
    94 /
    Procedure created.
    SQL> declare
    2 begin
    3 MEXICO_NAFTA_CERTIFICATE_EXT('0048', '00254101', '11', '03');
    4 end;
    5 /
    Data Extracted
    declare
    ERROR at line 1:
    ORA-29282: invalid file ID
    ORA-06512: at "SYS.UTL_FILE", line 774
    ORA-06512: at "FTA_SOURCE.MEXICO_NAFTA_CERTIFICATE_EXT", line 72
    ORA-06512: at line 3

    what is the datatype of your column org_id for the table fta.SAP_CERTIFICATES_EXTRACT_VIEW? also try to put this exceptions to see what might be the exact cause of the error.
      EXCEPTION
        WHEN utl_file.invalid_mode THEN
          RAISE_APPLICATION_ERROR (-20051, 'Invalid Mode Parameter');
        WHEN utl_file.invalid_path THEN
          RAISE_APPLICATION_ERROR (-20052, 'Invalid File Location');
        WHEN utl_file.invalid_filehandle THEN
          RAISE_APPLICATION_ERROR (-20053, 'Invalid Filehandle');
        WHEN utl_file.invalid_operation THEN
          RAISE_APPLICATION_ERROR (-20054, 'Invalid Operation');
        WHEN utl_file.read_error THEN
          RAISE_APPLICATION_ERROR (-20055, 'Read Error');
        WHEN utl_file.internal_error THEN
          RAISE_APPLICATION_ERROR (-20057, 'Internal Error');
        WHEN utl_file.charsetmismatch THEN
          RAISE_APPLICATION_ERROR (-20058, 'Opened With FOPEN_NCHAR But Later I/O Inconsistent');
        WHEN utl_file.file_open THEN
          RAISE_APPLICATION_ERROR (-20059, 'File Already Opened');
        WHEN utl_file.invalid_maxlinesize THEN
          RAISE_APPLICATION_ERROR(-20060,'Line Size Exceeds 32K');
        WHEN utl_file.invalid_filename THEN
          RAISE_APPLICATION_ERROR (-20061, 'Invalid File Name');
        WHEN utl_file.access_denied THEN
          RAISE_APPLICATION_ERROR (-20062, 'File Access Denied By');
        WHEN utl_file.invalid_offset THEN
          RAISE_APPLICATION_ERROR (-20063,'FSEEK Param Less Than 0');
        WHEN others THEN
          RAISE_APPLICATION_ERROR (-20099, 'Unknown UTL_FILE Error');

  • Getting INVALID_OPERATION  while using UTL file

    Hi,
    I have a procedure which makes different UTL files i.e data file, error file and log file for a Purchase order. These 3 sets of files are made for every purchase order.
    So suppose in a cursor i find that there are 10 Purchase orders to process, then it should create 30 UTL files 10 sets of 3 files.
    But when i run this procedure, after processing 3 PO's i.e after creating 9 files i get INVALID_OPERATION error.
    So lets say i have 10 PO's 1 to 10 , i run for first time PO 1,2 and 3 utl files are created and then i get error. Then when i run it again processes PO number 4 to 6 and then again error...
    So i want to know is there any restriction on number of UTL files you can create in a single procedure. i want urgent help, appreciate ur quick replies on this matter.
    thanks,
    Dipin

    Hi,
    There could be several reasons for this...
    1. In inti ora file, what utl file directory was specified? is it 'C:\PLXML\DBDOM'? if not check.
    2. Do u have C:\PLXML\DBDOM\Testfile.txt in your directory?
    3. If you have above file in that directory and you have opened that file for writing purpose, close that.
    Ur program looks ok. Also, dbms_output.put_line will display 255 charcters only(at least in 7.3).
    Koti.
    null

  • Error loading xml file with sqlldr

    Hi there,
    I am having trouble loading an xml file via sqlldr into oracle.
    The version i am running is Oracle Database 10g Release 10.2.0.1.0 - 64bit Production and the file size is 464 MB.
    It ran for about 10 hours trying to load the file and then threw up the error:
    ORA-22813: operand value exceeds system limits.
    I have loaded a file of 170MB using the same process succesfully.
    Any Ideas?
    Cheers,
    Dan.

    Looked a bit into the issue (ORA-22813) and although it can be caused by a lot of issues varrying database versions, you could have a go at sizing up your PGA database parameter. See Oracle support Doc ID 837220.1 for more info.
    The following might help
    CREATE OR REPLACE PROCEDURE show_pga_memory (context_in IN VARCHAR2 DEFAULT NULL)
    SELECT privileges required on:
      SYS.v_$session
      SYS.v_$sesstat
      SYS.v_$statname
    Here are the statements you should run:
    GRANT SELECT ON SYS.v_$session  TO <schema>;
    GRANT SELECT ON SYS.v_$sesstat  TO <schema>;
    GRANT SELECT ON SYS.v_$statname TO <schema>;
    IS
      l_memory NUMBER;
    BEGIN
      SELECT st.VALUE
        INTO l_memory
        FROM SYS.v_$session se, SYS.v_$sesstat st, SYS.v_$statname nm
      WHERE se.audsid = USERENV ('SESSIONID')
        AND st.statistic# = nm.statistic#
        AND se.SID = st.SID
        AND nm.NAME = 'session pga memory';
      DBMS_OUTPUT.put_line (CASE WHEN context_in IS NULL
                              THEN NULL
                              ELSE context_in || ' - '
                            END
                            || 'PGA memory used in session = ' || TO_CHAR (l_memory));
    END show_pga_memory;
    /

  • Problem with UTL FILE COPY

    Hi,
    I am facing one small problem in UTL FILE COPY package. We have an automated scheduled batch process. As a daily batch process it moves the files from one folder to other. During movement, it first copies the file from source folder to destination folder using FILE COPY package and then removes the file using FILE REMOVE package from the source folder.
    Few cases are found that the file when files are copied they are copied as 0 bytes in destination folder but the source file had 1 MB file size. The interesting part is I am unable to replicate the issue. Means when i try to run once again the package its working properly and files are copied with correct size. This kind is issue is occuring very rarely though as once in month but the question is why FILE_COPY package is not working properly sometimes.. I am unable to understand.
    Thanks a lot for going through this. Any suggestions.
    Regards,
    Ashish

    Anyhow make sure that the copy will start after the full generation of files.
    You can think like a spool file generation with huge data. In that case initially spool file available with 0 byte only. After finish of query only it shows its actual size.

  • Loading a table from multiple input files using sqlldr

    Hi,
    For my project i need to load into a table by joining two input files using sqlldr. For example,
    I have a file1, which has values
    name,salary,ssn
    and file2 which has values for
    ssn,location,country
    now i need to load these values into a table say employee_information by joining both input files. both input files can be joined using ssn as common field.
    Any idea how to do this??
    Thanks in advance
    Satya.

    Hi,
    What is the size of the files. If possible mail me the sample files, And the structure of table. Is the <ssn> from first file and second will have seperate columns in the table or we have to merge it.
    SKM

  • Problem with utl file

    Hi to all,
    I have tried the UTL file concept as per the oracle documentation
    I have created a directory name read_flat_file and granted read, write permission to the whm user. I am trying to executing the below code as in Oracle Documentation, but I am getting this below error.
    DECLARE
    V1 VARCHAR2(32767);
    F1 UTL_FILE.FILE_TYPE;
    BEGIN
    F1 := UTL_FILE.FOPEN('READ_FLAT_FILE','HMI PO','R',256);
    UTL_FILE.GET_LINE(F1,V1,32767);
    UTL_FILE.FCLOSE(F1);
    END;
    Error I am getting is
    F1 UTL_FILE.FILE_TYPE;
    ERROR at line 3:
    ORA-06550: line 3, column 4:
    PLS-00201: identifier 'UTL_FILE' must be declared
    ORA-06550: line 3, column 4:
    PL/SQL: Item ignored
    ORA-06550: line 5, column 1:
    PLS-00320: the declaration of the type of this expression is incomplete or
    malformed
    ORA-06550: line 5, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 6, column 19:
    PLS-00320: the declaration of the type of this expression is incomplete or
    malformed
    ORA-06550: line 6, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 7, column 17:
    PLS-00320: the declaration of the type of this expression is incomplete or
    malformed
    ORA-06550: line 7, column 1:
    PL/SQL: Statement ignored
    I tried this code from system user but I got the same error.
    When I am trying the same code with the SYS User I got this error.
    declare
    ERROR at line 1:
    ORA-29283: invalid file operation
    ORA-06512: at "SYS.UTL_FILE", line 475
    ORA-29283: invalid file operation
    ORA-06512: at line 5
    I dont understand the UTL_FILE package is granted to PUBLIC role by default.
    In sys user the handler is throwing the error perfectly that invalid file operation. then why this is not occuring with other users.
    Please let me know why this is happening
    Thanks and Regards,
    Vijay

    Hi Vijay,
    There are two problems here...
    The first is that your user doesn't appear to have execute privs on the procedure. As you say, it is usually granted to public, but it doesn't look like it is for you. Check the privileges with:
    select *
    from dba_tab_privs
    where table_name like 'UTL_FILE'
    This will list who has permissions on the package. If you get nothing, grant execute to either public or to your user:
    grant execute on sys.utl_file to <user/public>;
    The second problem is a syntax error on line 5 of your procedure. Remove the ',256' bit - it shouldn't be there.
    F1 := UTL_FILE.FOPEN('READ_FLAT_FILE','HMI PO','R');
    Cheers,
    Andy Barry
    http://www.shutdownabort.com

  • Issue with utl file

    Hi,
    I am using UTL file to export records from table with fixed delimiter to a text file.
    It works fine except that I see an additional character @ at the end of the file in the last line.
    Can anyone let me know why are we getting this and how can we delete it..
    Thaks in advance..

    I assume, as you are saying you can see the file ok in notepad/wordpad that you are creating a text file.
    So a) what are you using to view the file in unix and b) how did you transfer the file to unix?
    When you transfer files from Windows/DOS based operating systems to unix based operating systems you have to be aware that Windows uses a CR/LF pair of characters to terminate a line (a 'newline') and unix just uses a single LF character (character 10 in the ascii table) to terminate a line.  So when you transfer the files you need to convert the CR/LF pairs into just LF characters.
    Typically this is done if you transfer the files using FTP and specify the 'mode' to be ASCII rather than BINARY.
    c:\>ftp testserver
    Connected to testserver.mycompany.com.
    220 sunny2 FTP server ready.
    User (testserver.mycompany.com:(none)): myuser
    331 Password required for myuser.
    Password:
    230 User myuser logged in.
    ftp> ascii
    200 Type set to A.
    ftp>
    This tells the FTP software that you are transferring text files and that it needs to convert newline characters, if necessary, when transferring between Windows and Unix operating systems.
    And for reference, if it's not a text file, then you must transfer in BINARY mode to ensure the files remain byte for byte the same...
    ftp> bin
    200 Type set to I.
    ftp>
    If you don't transfer text files, between different operating systems, in ASCII mode, then those files will either be missing characters or have additional characters that aren't wanted.

  • 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.

  • Syntax to find "utl file"

    Hi all,
    I request u to pls give me the syntax to find
    "utl file" from the v$parameter in oracle database.
    thanks and regards
    somasi

    My version is 11.5.10.2I don't think it is. Unless you've travelled into the future.
    The UTL_FILE_DIR parameter, as already mentioned, was deprecated a while back as it leaves your database open to security holes, meaning that unscrupulous people could access files on your o/s and cause disruption and/or loss of data.
    The correct method now is to use directory objects e.g.
    CREATE OR REPLACE DIRECTORY mydir AS '/user/fred/myfiles';
    Then grant read and/or write permissions on that directory object to the required database users.
    Then use that directory object in your UTL_FILE functions e.g.
    f := UTL_FILE.FOPEN('MYDIR', 'file.txt', 'w');
    Note: In the functions the directory object should be specified as a string in UPPERcase as that is how the object is referred to in the data dictionary.
    ;)

  • How to load data from UTL file to database

    Hi All,
    I am new in this technologies.
    I am facing below problem to load data from utl file to database .
    below is the script written by me :
    CREATE OR REPLACE PROCEDURE load_data AS
    v_line VARCHAR2(2000);
    v_file UTL_FILE.FILE_TYPE;
    v_dir VARCHAR2(250);
    v_filename VARCHAR2(50);
    v_1st_Comma NUMBER;
    v_2nd_Comma NUMBER;
    v_deptno NUMBER;
    v_dname VARCHAR2(14);
    v_loc VARCHAR2(13);
    BEGIN
    v_dir := ':f/rashi/dataload';
    v_filename := 'fake.txt';
    v_file := UTL_FILE.FOPEN(v_dir, v_filename, 'r');
    LOOP
    BEGIN
    UTL_FILE.GET_LINE(v_file, v_line);
    EXCEPTION
    WHEN no_data_found THEN
    exit;
    END;
    v_1st_Comma := INSTR(v_line, ',' ,1 , 1);
    v_2nd_Comma := INSTR(v_line, ',' ,1 , 2);
    v_deptno := SUBSTR(v_line, 1, v_1st_Comma-1);
    v_dname := SUBSTR(v_line, v_1st_Comma+1, v_2nd_Comma-v_1st_Comma-1);
    v_loc := SUBSTR(v_line, v_2nd_Comma+1);
    DBMS_OUTPUT.PUT_LINE(v_deptno || ' - ' || v_dname || ' - ' || v_loc);
    INSERT INTO don
    VALUES (v_deptno, UPPER(v_dname), UPPER(v_loc));
    END LOOP;
    UTL_FILE.FCLOSE(v_file);
    COMMIT;
    END;
    show error
    I am getting the below errors:
    LINE/COL ERROR
    3/8 PL/SQL: Item ignored
    3/8 PLS-00201: identifier 'UTL_FILE' must be declared
    15/1 PL/SQL: Statement ignored
    15/1 PLS-00320: the declaration of the type of this expression is
    incomplete or malformed
    20/1 PL/SQL: Statement ignored
    20/19 PLS-00320: the declaration of the type of this expression is
    incomplete or malformed
    36/1 PL/SQL: Statement ignored
    LINE/COL ERROR
    36/17 PLS-00320: the declaration of the type of this expression is
    incomplete or malformed
    could anyone please advice me on above error.
    thanx.

    First of all, is file located on (or is accessible from) database server? If not - you can't load it neither with UTL_FILE nor with external table. You need to use client side tool like SQL*Loader or write your own client side load. If file is accessible from database server, then, as sb92075 noted, external table (assuming you are not on some ancient Oracle version) is the way to go.
    SY.

Maybe you are looking for

  • Horizontal Slider with dates

    Hi All,      I wanted a horizontal slider with dates . Can anybody help please. Thanks

  • Double Click Event In ALV Tree

    Hello guys, There is a requirement that when I double click on an item in ALV tree it takes me to a standard transaction code. Can anyone suggest me how to proceed on this. Thanks in Advance. Regards, Abhinav

  • Mac mail sometimes does not load gmail messages

    Several times a week my mail will not load some messages. Most times it works fine. My iphone always gets the mail. What's up with that?

  • Changing Eye Color

    I'm guessing that one changes color in Color of course but in this case I have an actress who has "blue" eyes and for at least one scene we need those eyes to be real looking brown ones. Anyone ever done this?  If so, how do you go about doing it?  S

  • How to configure, ISQL*PLUS?

    Hi, Can you please let me know how I can work with ISQL*PLUS??? Thanks in advance,,,