Unable to read the file using UTL_FILE Dir

I need to read/write a file from/to the operating system through PLSQL Package. I used UTL_FILE package to do the same. In the application server the utl_file_dir(/usr/tmp in my system) is created as a softlink to database server.
oI want to run this package through the application server. However I am unable to read and write the file to the operating system.
I just wondering it is not reading/opening the file from the server. Please suggest me how to modify my code.

Hi,
How to check if it is end of file or not? I have the following function which is working fine in my win2003 server std 32bit and Oracle10g Database R2 Standard Edition one 32bit. HOwever, when I deploy to production server which is 64bit OS and database, it gives error at UTL_FILE.GET_LINE(fptr, tmp);
Any idea why it behaves like that?
     FUNCTION readFile (
          inHTML OUT CLOB,
          path IN VARCHAR2,
          htmlFile IN VARCHAR2
     ) RETURN BOOLEAN IS
     fptr utl_file.file_type;
     tmp VARCHAR2(5023);
     bufferlen BINARY_INTEGER;
     BEGIN
          fptr := UTL_FILE.FOPEN(path, htmlFile, 'r');
          DBMS_LOB.CREATETEMPORARY(inHTML, TRUE);
          DBMS_LOB.OPEN(inHTML, DBMS_LOB.LOB_READWRITE);
          LOOP
               UTL_FILE.GET_LINE(fptr, tmp);
               if tmp is not null then
                    tmp := tmp || CHR(10);
                    bufferlen := LENGTH(tmp);
                    DBMS_LOB.WRITEAPPEND(inHTML, bufferlen, tmp);
               end if;
          END LOOP;
          WHEN NO_DATA_FOUND THEN
          DBMS_LOB.CLOSE(inHTML);
               UTL_FILE.FCLOSE(fptr);
               RETURN TRUE;
          WHEN OTHERS THEN
               DBMS_LOB.CLOSE(inHTML);
               DBMS_LOB.FREETEMPORARY(inHTML);
               RETURN FALSE;
     END readFile;

Similar Messages

  • How to read HTML files using UTL_FILE

    Hello Friends,
    How to read HTML files using UTL_FILE package ? According
    to Oracle documentation UTL_FILE can read or write OS Text Files.
    Thanx in advance..
    Adi

    HI Hareesh,
    i have gone through that blog.
    i tried it...but i am getting mapping error  no receiver determination fond because there are so  many excel files.
    my data is available on sharedString.xml but also it is in not same order.
    i have no clue how to handle this part form the blog.
    "This way our mapping will receive all data from the sheet in an XML format. The only thing that's left is to create an XSD file from the XML file we received in order to be able to use it in the mapping and as our Service Interface and we can proceed with mapping. As you can see from the sheet.xml files all the data is placed with column name and row number so it's not that difficult to map it to an table type format using the Message Mapping only (no java, abap mapping required)."

  • To read text file using utl_file

    I would like to read test_file_out.txt which is in c:\temp folder.
    create or replace create or replace directory dir_temp as 'c:\temp';
    grant read, write on directory dir_temp to system;
    then when i execute the below code i get the error .
    // to read text file using utl_file
    DECLARE
    FileIn UTL_FILE.FILE_TYPE;
    v_sql VARCHAR2 (1000);
    BEGIN
    FileIn := UTL_FILE.FOPEN ('DIR_TEMP', 'test_file_out.txt', 'R');
    UTL_FILE.PUT_LINE (FileIn, v_sql);
    dbms_output.put_line(v_sql);
    UTL_FILE.FCLOSE (FileIn);
    END;
    ERROR:
    invalid file operation
    i would like to use ult_file only and also can you let me know to read the text file and place its contents in tmp_emp table?

    Are you trying to read the contents of the file into the local variable? Or write the contents of the local variable to the file?
    Your text talks about reading the file. And you open the file in read mode. But then you call the UTL_FILE.PUT_LINE method which, as SomeoneElse points out, attempts to write data to the file. Since the file is open in read-only mode, you cannot write to the file.
    If the goal is really to read from the file, replace the UTL_FILE.PUT_LINE calls with UTL_FILE.GET_LINE. If the goal is really to write to the file, you'll need to open the file in write mode ('W' rather than 'R' in the FOPEN call).
    Justin

  • Can't read text file using UTL_FILE

    Hi All,
    how can I read notepad file using UTL_FILE package.I have specified the UTL_FILE_DIR in the init.ora file.My objective is to when a button is clicked, the contents of the file will display in a text item.Here is my code written in WHEN_BUTTON_PRESSED trigger.
    DECLARE
         file_handle UTL_FILE.FILE_TYPE;
    data_line Varchar2(100);
    BEGIN
         file_handle := UTL_FILE.FOPEN('E:\vimal','abc.txt','R');
              message('directory created');
         UTL_FILE.GET_LINE(file_handle, data_line);
         :block2.t1 := data_line;
         UTL_FILE.FCLOSE(file_handle);
    END;

    Why don't you use text_io? Don't forget that UTL_FILE is reading directories from the database point of view. The E drive for the database is a different E then on your client pc. I presume your database is on a different computer. Are you getting any errors?

  • Is it possible to read the file using File Adapter which is in client machi

    Is it possible to read the file using file Adapter which is in client machine(on the same network).Then what is thee need of FTP Adapter?

    You can achieve that by exposing your client machine as a drive, then you can go using file adapter.
    FTP adapter will help you to communicate with different machine which is in different network.
    It is considered good etiquette to reward answerers with points (as "helpful" - 5 pts - or "correct" - 10pts).
    Thanks,
    Vijay

  • How to skip the header rows of the file using UTL_FILE?

    Hi,
    I created a procedure to read the file from shared location using UTl_FILE package. But, I stucked why because I don't know how to skip the header rows as those rows are headings for one of the report.Since, please help me.
    Regards,
    Vissu.....

    vissu wrote:
    Hi,
    I created a procedure to read the file from shared location using UTl_FILE package. But, I stucked why because I don't know how to skip the header rows as those rows are headings for one of the report.Since, please help me.
    Regards,
    Vissu.....UTL_FILE just reads data from the file. It has no concept of what could be a "header" or "body" or "records" or "footer" or any other data based concept. If you want to skip lines of a file, you will just need to read them using UTL_FILE and ignore them.

  • I am unable to read pdf files using Acrobat Reader on my MAC OS X. Any suggestions?

    How do I read pdf files using my MAC OS X?

    You can read pdf files with preview. Select a pdf document, right click on it, and choose Preview. You can also get info and select to choose Preview for all.
    You can also install Adobe Reader 10.1.3 for Lion. It will also install a plug-in to read pdf docs in the browser.
    http://www.adobe.com/support/downloads/detail.jsp?ftpID=5360

  • Unable to remove *.log files using utl_file.fremove

    Hi,
    I want to remove .log files using the below command
    I want to remvoe all the *.log files but its remvoing only one .log file
    utl_file.fremove(location => dir_name, filename => log_file_name);
    Any help will be needful for me

    In the documentation for your unknown version of oracle you can view the definition of utl_file.fremove.
    Everywhere it states utl_file.fremove removes a file, not 1 or more, and the documentation doesn't discuss the use of wildcards.
    It seems like the question could have been prevented by reading docs (which almost no one here does), and you need to use Java to address your requirement.
    Personally I wouldn't misuse Oracle to perform O/S tasks.
    Sybrand Bakker
    Senior Oracle DBA

  • Unable to read the file in excel..

    Hi all,
    I created a report.for this report It was an excel template. when I click on view button I am getting an error Unable to read file.
    I checked my query in database it retrieving 43000 records.
    When I am going for rownum<1000 my report is giving successful results.But when I am removing that condition in where clause I am getting error Unable to read file.
    Can any one pls help in this.....
    Thanks,
    KSS.

    Not that this really answers your question but... 45K records seems like a lot of data. Perhaps you need to add some conditions to your SQL to limit the records to a more manageable size and make the results more relevant to the task. Just an opinion.
    ds

  • LSMW unable to read the file .its givining Dump

    Hi,
    I am facing problem ,while reading the Data. Below is the Dump.how can i slove this problem
    The current program, "/1CADMC/SAP_LSMW_READ_00000002", had to be terminated because a capacity limit has been reached.
    Error analysis
        An exception occurred. This exception will be dealt with in more detail
        below. The exception, assigned to the class 'CX_SY_FILE_IO', was not caught,
         which
         led to a runtime error. The reason for this exception is:
        An error occurred when writing to the file
         "ZCO_ZCO_UPLOAD_PROFIT_CNTER_UP.lsmw.read".
        Error text: "No space left on device"
        Error code: 28

    It is in my business card.
    https://www.sdn.sap.com:443/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=3s67bbqock8=
    Regds
    Manohar

  • After having downloaded I have been unable to open the files using right click or double clicking in the download windo

    I am using Windows 7 along with Office 10. I have downloaded a number of zip files into Download location. Although the files are shown in the firefox download window they are not on my computer hard disk. Although I can access the Firefox download window and get the menu when I right click on a file and click on open nothing happens. The same outcome when I double click on the file in the window. I need to understand where the download files are and how to open them before I go crazy.

    Reload web page(s) and bypass the cache to refresh possibly outdated or corrupted files.
    *Hold down the Shift key and left-click the Reload button
    *Press "Ctrl + F5" or press "Ctrl + Shift + R" (Windows,Linux)
    *Press "Command + Shift + R" (Mac)
    Clear the cache and the cookies from websites that cause problems.
    "Clear the Cache":
    *Firefox/Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Firefox/Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Firefox uses the about: protocol to access built-in about: pages that you can open via the location bar just like you open web pages.
    *http://kb.mozillazine.org/About_protocol_links).
    *Do NOT click the Reset button on the Safe Mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • I purchased a very expensive package, to convert files to PDF form. when it converted some of the text needs to be adjusted how do i fix this? When i e-mailed the file to myself i was unable to read the file??????

    Question?? my name is Cecelia. I purchased your product and so far I am very unsatisfied with it. I need to fix or add to a converted PDF and I am unable to do so. I e-mailed this form to my self and it states no file avail.. is this what other will see too??????

    First, when you e-mail a PDF you have to be sure the e-mail package you use encodes the PDF as binary file, not all do automatically. If the PDF is sent as an ASCII (text) file, then it will be corrupted. That is likely what happened. The alternative is to zip the PDF and send the zip file.
    Fix ups are generally done in the application you used. The PDF should be a duplicate of what you see in your APP. If you are using WORD, be sure the selected printer in WORD is the Adobe PDF printer during your editing. WORD and many other word processors reflow documents based on the attached printer. It is not clear what your problem is, but that might be the issue.
    As for forms, are you actually creating an electronic form or is this something that looks form for someone to print and fill in. If you want an electronic form, then you need to use the Form Tools in the tools menu. You can let Acrobat try to guess the form fields that are needed, then go back and edit the form fields. Of course, you may not have actually meant a form as such, but the layout of your document that is messed up. If it is the layout, then attaching the Adobe PDF printer during the editing of your document should solve that issue. You should also consider using the Press or Print job settings to embed all fonts.

  • ODI and Essbase in different server to read the file error

    Hi,
    I have ODI and Essbase installed in different server.
    I have created an interface to execute a calc script on top of an essbase cube. I kept the Caclscript.csc file in one folder in ODI server and provide the path
    EXTRACTION_QUERY_FILE parameter is the path of the .csc file i placed in ODI server. it executed successfully to generate the extract file using the calc script in the specified path on Essbase server.
    Now i want to read that file and load it to a relational table so map the network drive from ODI server to Essbase server where the file has been generated and provided the EXTRACT_DATA_FILE_IN_CALC_SCRIPT parameter as the Network drive path but ODI is unable to read the file.
    any other option to read the file reside in essbase server and load it to relational table.
    com.hyperion.odi.essbase.ODIEssbaseException: com.hyperion.odi.essbase.ODIEssbaseException: Error occured while reading the data file produced by calculation script.
    -KP

    I would install an ODIAgent on the Essabse server and use this agent when running this particular operation

  • Problem while reading the file from FTP server

    Hi Friends,
    I have a problem while fetching files from FTP server.
    I used FTP_Connect, FTP_COMMAND function modules. I can able to put the files into FTP server.
    but I cant able to pick the files from FTP server.
    anyone have faced similar issues kindly let me know.
    Thanks
    Gowrishankar

    Hi,
    try this way..
    for reading the file using FTP you need to use different unix command ..
    Prabhuda

  • How to read a file using servlet

    hi ,
    i've to read a file using servlet ,
    should read the file using servlet and display it in JSP,Could anybody get me how can i do it .
    Shiva

    To do that you need to get the response output stream and write yur file contents to that.
    response.setContentType(mimeType); //Set the mime type for the response
    ServletOutputStream sos = resp.getOutputStream();
    sos.write(bytes from your file input stream);
    sos.close();

Maybe you are looking for