Archiving files generated by PL/SQL program using UTL_FILE package

Dear All,
We have on PL/SQL package that is generating some data files using UTL_FILE package in one specific directory.
I am working on concurrent program of type host(unix script) to move generated file to some archive folder.
Now the problem is owner of the files generated by PL/SQL is oracle and file permissions of the generated files are 644(Only read permission for group and others).
Concurrent program is using an another os user applmgr to execute the script attached with concurrent program.
Because applmgr is not having write permission on the files, hence mv command is failing.
Please suggest me how to resolve this issue.
Regards
Devender Yadav

Hi;
I just think that, you can create one sh which is chancing permission of related path owner for applmgr user and put it on crontab and it can run every 1 min.
Regard
Helios

Similar Messages

  • Need to generate the excel file with diffrent sheets using utl_file package

    Hi,
    Sorry for previous message in which I had missed the usage of " UTL_FILE " package
    I need to generate the excel file with diffrent sheets . Currently I am generating the data in three diffrent excel files using
    " UTL_File " package and my requirement is to generate this in a single excel file with diffrent sheets.
    Please help on this
    Thanks & Regards,
    Krishna Vyavahare

    Hello 10866107,
    at Re: How to save a query result and export it to, say excell? you can find links to different solutions. At least the packages behind second and fourth link support more than one worksheet.
    Regards
    Marcus

  • Permissions on files created using UTL_FILE package

    The files created on unix using UTL_FILE package have permisisons rw- - - - - - -.(600). I want them to be created with permissions 640.(rw-r - - - - - ).i.e read access to the group also. The umask setting of the unix account of the oracle instance are 137. Is there any way to create the files with the required permissions.

    So SQL*Plus is on your PC? I'm assuming you mean 'call' as in the windows cmd.exe command?
    Sheesh this is like getting blood from a stone.
    In that case you must be connecting via the listener and not internally.
    In which case the umask comes from the umask that was set in the environment of the OS user who started the listener process.
    Thats not necessarily the same as the owner of the oracle software (normally 'oracle').
    If sysdamin joebloggs logs in and starts the listener manually in a shell, then the umask applied to all shadow processes started by the listener is whatever jobloggs umask was when he typed the command 'lsnrctl start'. The umask of the owner of the oracle software, or your umask, is utterly irrelevent.
    So if you don't like the umask for files created by processes spawned by the listener, stop and restart the listener in a shell where you have explicitly set the umask to what you want it to be.
    Really starting the listener should be scripted and the correct umask is put in the script just before the call to 'lsnrctl start'.

  • Creating Error log files using UTL_FILE package on a remote machine

    Database Version: 10g Release2
    OS Platform: Sun Solaris
    I have been asked to log errors to OS files rather than tables. So, i wanted to use UTL_FILE package. But the client doesn't want to store these files on the same server where the database is running(as specified in UTL_FILE_DIR). Is there a way i could get these files created on a remote machine(client).

    I believe what others are suggesting is that your stored procedure continues to log to a table and a separate process be created that runs on the machine you want the file to be created on which reads the log table and writes to a log file.
    If that is not an option, can you expose the directory on the remote machine you want to write the file to as a file share that can be mounted by the database server? If you can, you could write errors there using UTL_FILE. However, it would probably be a bad idea. If you're logging an error already, that implies that something has gone wrong. Making an error logging process dependent on a remote server being available and properly mounted with appropriate privileges at the instant the error occurs just creates more sources of failure that would prevent you from logging an error, which would prevent you from being able to debug the problem or even know it existed without a report from a user.
    Justin

  • Create a file and store it in the database using UTL_FILE package

    Hello.
    I'm using UTL_FILE package to store data from a table into an excel file but I don't know how to store this file in a table with a BLOB field the database at the same time. I want do do this because I will use it in a Oracle Portal.
    Anybody has any idea how to do this?
    Thanks & Regards,
    Alexandra

    From Asktom
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:232814159006

  • Error while using UTL_FILE package

    I am getting error while using UTL_FILE package in apex 3.0 version
    Pls help me out.

    ok, how are you using UTL_FILE and what is the error?

  • Downloading unix archive file (.Z extension) from java program

    Hi,
    I am trying to download unix archive files with .Z extension from java program. When I use
    BufferedReader zReader = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
    and then read line by line and write it to file, downloaded file can't be decompressed. I tried to open it with winZip which supports .Z files but I get the message : Cannot open file, it does not appear to be a valid archive.
    How can I download file correctly?
    Any help would be appreciated.

    Hi,
    I am trying to download unix archive files with .Z
    extension from java program. When I use
    BufferedReader zReader = new BufferedReader(new
    InputStreamReader(urlConn.getInputStream()));
    and then read line by line and write it to file,How are you writing the file? Since it is binary data you need to be careful about using Reader/Writers, which are meant for character data. Look at using classes from the InputStream/OutputStream hierarchy.
    - N

  • Example of PL/SQL PROGRAM USING  BLOB datatype

    give me one example of PL/SQL PROGRAM BY USING BLOB DATATYPE

    Try this link
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96591/toc.htm
    Best Regards
    Krystian Zieja / mob

  • Reading all files on directory using "utl_file" package...

    I need to read all files in directory via PL/SQL. I don't know
    name files (are data dynamics create for automation system),
    only I know your extensions.
    Can I do this using the package "utl_file" or I need to create
    program in another language (C, C++, for example)?
    Any ideas...
    Thanks.

    Hi,
    you can't do that with the UTL_FILE package (it can't retrieve
    file names).
    A very simple solution would be, if you created on OS-level a
    file which contains the filenames of directory and then read this
    file using UTL_FILE. With the information on all file names you
    can enter a loop which opens and reads all files again using
    UTL_FILE.
    A more mundane solution could be to use the features on the iFS.
    Cheers
    Gerald

  • Having problem in recognising file using utl_file package..

    Hi,
    I am using utl_file utility to read the CSV file, utl_file.fopen function is useed to open file. This fopen function has three input parameters, second parameter is file name. My problem is that, i have to read file on daily basis. File name will be like:- DDMMYYYYHHMISS. Last six characters are for hour minute second of the file generation time. If the name has only DDMMYYYY then I can give the file name like TO_CHAR(SYADATE,'DDMMYYYY'), because on a particular date its same for the whole day. But hours, minutes and seconds will be of the time when the file is generated, it may be different for different days. In this condition how can I standardize the value for file name parameter in fopen function.
    Thanks in advance.

    Bharat Kaushik wrote:
    Actually.....
    I am gettting file from some other place..... And those people are not agreed to send file without exact time.JAVA solution is here
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:7506780031005
    Or if you want PL/SQL .. (May Be kiddy)
    --Please Note: SYSDATE is 26th in our DB.
    SQL> declare
      2   fp utl_file.file_type;
      3   dt date := trunc(sysdate);
      4  begin
      5   while (dt <= sysdate) loop
      6    begin
      7      fp := utl_file.fopen('OGL_REPORT_ACCESS','TEST'||to_char(dt,'ddmmyyyyhh24miss')||'.csv','r');
      8      dbms_output.put_line('TEST'||to_char(dt,'ddmmyyyyhh24miss'));
      9      utl_file.fclose(fp);
    10      exit;
    11    exception
    12     when utl_file.INVALID_OPERATION then
    13      null;
    14    end;
    15    dt := dt + 1/24/60/60;
    16   end loop;
    17  end;
    18  /
    TEST26042009010102
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:03.45
    SQL> select sysdate from dual;
    SYSDATE
    26-APR-09

  • Unable to write files in different m/c in LAN using utl_file package

    I need to dump some files generated by utl_file package in a separate m/c not in the db server.For that I tried using utl_file_dir='*' and mapped the specified directory in the db server. but its failing as show below..
    ORA-29283: invalid file operation
    ORA-06512: at "SYS.UTL_FILE", line 449
    ORA-29283: invalid file operation
    ORA-06512: at "ANIRBAN.WRITE_IN_FILE", line 9
    ORA-06512: at line 1
    The prototype sp is given below..
    CREATE OR REPLACE PROCEDURE write_in_file(pInDir IN VARCHAR2,
    pInFileName IN VARCHAR2,
    pInFileContent IN VARCHAR2) IS
    vFile UTL_FILE.FILE_TYPE;
    vFileName VARCHAR2(20) := pInFileName;
    BEGIN
    dbms_output.enable(1000000);
    vFile := UTL_FILE.FOPEN(pInDir, vFileName, 'w', 32000);
    UTL_FILE.PUT_LINE(vFile, pInFileContent);
    UTL_FILE.FCLOSE(vFile);
    END write_in_file;
    With this sp i'm able to write in genuine drives but not in mapped one.What shall be done to be able to write in a separate m/c freely.Plz guide me

    And make sure you specify the full path name of the server/directory path rather than using substituted drive names as is can sometimes be funny about that sort of thing.

  • HOW TO READ DATA FROM A FILE AND INSERT INTO A TABLE USING UTL_FILE

    Hi..
    I have a file.I want to read the data from file and load it into a table using utl_file.
    how can I do it?
    Any reply apreciated...

    Hi,
    This is not your requirment but u can try this :
    CREATE OR REPLACE DIRECTORY text_file AS 'D:\TEXT_FILE\';
    GRANT READ ON DIRECTORY text_file TO fah;
    GRANT WRITE ON DIRECTORY text_file TO fah;
    DROP TABLE load_a;
    CREATE TABLE load_a
    (a1 varchar2(20),
    a2 varchar2(200))
    ORGANIZATION EXTERNAL
    (TYPE ORACLE_LOADER
    DEFAULT DIRECTORY text_file
    ACCESS PARAMETERS
    (FIELDS TERMINATED BY ','
    LOCATION ('data.txt')
    select * from load_a;
    CREATE TABLE A AS select * from load_a;
    SELECT * FROM A
    Regards
    Faheem Latif

  • Writing files using UTL_FILE package

    Greetings:
    I'm attempting to write simple text files on the server side using the UTL_FILE package.I can get it to write the file to a local drive on the Oracle server with no problems, but not a network drive. When trying to write to a network drive, the FOPEN function raises the UTL_FILE.INVALID_OPERATION exception. This is even with my UTL_FILE_DIR parameter set the * for all directories and I have "Full Control" permission on the directory. I am running in a NT Server/Wkstn environment. Anyone have any ideas why I can't write a file to a network drive?
    Thanks a lot,
    Chris Scopp

    Thanks for your response...
    I have set the UTL_FILE_DIR parameter... I've tried setting it to the * for all directories and also mapping a drive letter from the server to where I want to write the file and then explicitly naming this path in the UTL_FILE_DIR parameter. Neither works, I still get the INVALID_OPERATION exception raised on the FOPEN function. I'm convinced now that it does have something to do with NT because I have been able to do the same operation writing to a Win95/98 box and it works fine. I have "Full Control" to all places I'm trying to write to, any other ideas?
    Thanks a lot,
    Chris Scopp

  • Download files from Shared Point document library using SSIS packages

    Dear All,
            Can you please help me on how can I download excel/CSV files from share point document library to local machine using SSIS packages.
    Regads,
    Praveen C
    Regards, Praveen

    Hi Praveen,
    You can also implement
    custom component or try third party custom component such as SharePoint List Adapters:
    https://sqlsrvintegrationsrv.codeplex.com/releases/view/17652
    Regards,
    Mike Yin
    TechNet Community Support

  • Using UTL_FILE package

    Dear Oracle community,
    Oracle has a great feature for letting your PL/SQL programs read and write operating system (OS) text files. However, there are no samples available.
    Does anyone already explored this feature and are willing to share some examples?
    Your help would be great. Thanks.
    Faron Sibbald

    Hi here is sample code I wrote to split up a 2 giga byte file so that it can be easily loaded using in wordpad/notepad or excell. Note you can also do lot of error traping. Its documented in oracle PL/SQL.
    CREATE OR REPLACE PROCEDURE mytest7 IS
    infile UTL_FILE.file_type;
    outfile UTL_FILE.file_type;
    filein varchar2(25);
    fileout varchar2(25);
    cur_dir varchar2(25);
    in_linebuf varchar2(301);
    out_linebuf varchar2(301);
    rec_count Number;
    cuml_rec_count Number;
    file_num Number;
    BEGIN
    rec_count := 0;
    cuml_rec_count := 0;
    file_num := 1;
    cur_dir := 'c:\junk\';
    filein := 'c:\junk\mluinput.txt';
    fileout := 'c:\junk\output'&#0124; &#0124; file_num &#0124; &#0124;'.txt';
    infile := UTL_FILE.fopen(cur_dir,filein,'R');
    outfile := UTL_FILE.fopen(cur_dir,fileout,'W');
    LOOP
    IF cuml_rec_count > 63670
    THEN
    rec_count := cuml_rec_count;
    out_linebuf := 'Total Records in this file = ' &#0124; &#0124; TO_CHAR(rec_count);
    UTL_FILE.put_line(outfile,out_linebuf);
    UTL_FILE.fclose(outfile);
    Exit;
    ELSE
    UTL_FILE.get_line(infile,in_linebuf);
    cuml_rec_count := cuml_rec_count + 1;
    out_linebuf := in_linebuf;
    UTL_FILE.put_line(outfile,out_linebuf);
    END IF;
    END LOOP;
    rec_count := 0;
    file_num := file_num + 1;
    fileout := 'output'&#0124; &#0124; file_num &#0124; &#0124; '.txt';
    outfile := UTL_FILE.fopen(cur_dir,fileout,'W');
    LOOP
    IF cuml_rec_count > 127340
    THEN
    out_linebuf := 'Total Records in this file = ' &#0124; &#0124; TO_CHAR(rec_count);
    UTL_FILE.put_line(outfile,out_linebuf);
    UTL_FILE.fclose(outfile);
    EXIT;
    ELSE
    UTL_FILE.get_line(infile,in_linebuf);
    cuml_rec_count := cuml_rec_count + 1;
    rec_count := rec_count + 1;
    out_linebuf := in_linebuf;
    UTL_FILE.put_line(outfile,out_linebuf);
    END IF;
    END LOOP;
    rec_count := 0;
    file_num := file_num + 1;
    fileout := 'output'&#0124; &#0124; file_num &#0124; &#0124; '.txt';
    outfile := UTL_FILE.fopen(cur_dir,fileout,'W');
    LOOP
    IF cuml_rec_count > 191010
    THEN
    out_linebuf := 'Total Records in this file = ' &#0124; &#0124; TO_CHAR(rec_count);
    UTL_FILE.put_line(outfile,out_linebuf);
    UTL_FILE.fclose(outfile);
    EXIT;
    ELSE
    UTL_FILE.get_line(infile,in_linebuf);
    cuml_rec_count := cuml_rec_count + 1;
    rec_count := rec_count + 1;
    out_linebuf := in_linebuf;
    UTL_FILE.put_line(outfile,out_linebuf);
    END IF;
    END LOOP;
    rec_count := 0;
    file_num := file_num + 1;
    fileout := 'output'&#0124; &#0124; file_num &#0124; &#0124; '.txt';
    outfile := UTL_FILE.fopen(cur_dir,fileout,'W');
    LOOP
    IF cuml_rec_count > 254680
    THEN
    out_linebuf := 'Total Records in this file = ' &#0124; &#0124; TO_CHAR(rec_count);
    UTL_FILE.put_line(outfile,out_linebuf);
    UTL_FILE.fclose(outfile);
    EXIT;
    ELSE
    UTL_FILE.get_line(infile,in_linebuf);
    cuml_rec_count := cuml_rec_count + 1;
    rec_count := rec_count + 1;
    out_linebuf := in_linebuf;
    UTL_FILE.put_line(outfile,out_linebuf);
    END IF;
    END LOOP;
    rec_count := 0;
    file_num := file_num + 1;
    fileout := 'output'&#0124; &#0124; file_num &#0124; &#0124; '.txt';
    outfile := UTL_FILE.fopen(cur_dir,fileout,'W');
    LOOP
    IF cuml_rec_count > 318350
    THEN
    out_linebuf := 'Total Records in this file = ' &#0124; &#0124; TO_CHAR(rec_count);
    UTL_FILE.put_line(outfile,out_linebuf);
    UTL_FILE.fclose(outfile);
    EXIT;
    ELSE
    UTL_FILE.get_line(infile,in_linebuf);
    cuml_rec_count := cuml_rec_count + 1;
    rec_count := rec_count + 1;
    out_linebuf := in_linebuf;
    UTL_FILE.put_line(outfile,out_linebuf);
    END IF;
    END LOOP;
    rec_count := 0;
    file_num := file_num + 1;
    fileout := 'output'&#0124; &#0124; file_num &#0124; &#0124; '.txt';
    outfile := UTL_FILE.fopen(cur_dir,fileout,'W');
    LOOP
    IF cuml_rec_count > 382020
    THEN
    out_linebuf := 'Total Records in this file = ' &#0124; &#0124; TO_CHAR(rec_count);
    UTL_FILE.put_line(outfile,out_linebuf);
    UTL_FILE.fclose(outfile);
    EXIT;
    ELSE
    UTL_FILE.get_line(infile,in_linebuf);
    cuml_rec_count := cuml_rec_count + 1;
    rec_count := rec_count + 1;
    out_linebuf := in_linebuf ;
    UTL_FILE.put_line(outfile,out_linebuf);
    END IF;
    END LOOP;
    rec_count := 0;
    file_num := file_num + 1;
    fileout := 'output'&#0124; &#0124; file_num &#0124; &#0124; '.txt';
    outfile := UTL_FILE.fopen(cur_dir,fileout,'W');
    LOOP
    IF cuml_rec_count > 445690
    THEN
    out_linebuf := 'Total Records in this file = ' &#0124; &#0124; TO_CHAR(rec_count);
    UTL_FILE.put_line(outfile,out_linebuf);
    UTL_FILE.fclose(outfile);
    EXIT;
    ELSE
    UTL_FILE.get_line(infile,in_linebuf);
    cuml_rec_count := cuml_rec_count + 1;
    rec_count := rec_count + 1;
    out_linebuf := in_linebuf;
    UTL_FILE.put_line(outfile,out_linebuf);
    END IF;
    END LOOP;
    rec_count := 0;
    file_num := file_num + 1;
    fileout := 'output'&#0124; &#0124; file_num &#0124; &#0124; '.txt';
    outfile := UTL_FILE.fopen(cur_dir,fileout,'W');
    LOOP
    IF cuml_rec_count > 509360
    THEN
    out_linebuf := 'Total Records in this file = ' &#0124; &#0124; TO_CHAR(rec_count);
    UTL_FILE.put_line(outfile,out_linebuf);
    UTL_FILE.fclose(outfile);
    EXIT;
    ELSE
    UTL_FILE.get_line(infile,in_linebuf);
    cuml_rec_count := cuml_rec_count + 1;
    rec_count := rec_count + 1;
    out_linebuf := in_linebuf;
    UTL_FILE.put_line(outfile,out_linebuf);
    END IF;
    END LOOP;
    rec_count := 0;
    file_num := file_num + 1;
    fileout := 'output'&#0124; &#0124; file_num &#0124; &#0124; '.txt';
    outfile := UTL_FILE.fopen(cur_dir,fileout,'W');
    LOOP
    IF cuml_rec_count > 573030
    THEN
    out_linebuf := 'Total Records in this file = ' &#0124; &#0124; TO_CHAR(rec_count);
    UTL_FILE.put_line(outfile,out_linebuf);
    UTL_FILE.fclose(outfile);
    EXIT;
    ELSE
    UTL_FILE.get_line(infile,in_linebuf);
    cuml_rec_count := cuml_rec_count + 1;
    rec_count := rec_count + 1;
    out_linebuf := in_linebuf;
    UTL_FILE.put_line(outfile,out_linebuf);
    END IF;
    END LOOP;
    rec_count := 0;
    file_num := file_num + 1;
    fileout := 'output'&#0124; &#0124; file_num &#0124; &#0124; '.txt';
    outfile := UTL_FILE.fopen(cur_dir,fileout,'W');
    LOOP
    IF cuml_rec_count = 636698
    THEN
    out_linebuf := 'Total Records in this file = ' &#0124; &#0124; TO_CHAR(rec_count);
    UTL_FILE.put_line(outfile,out_linebuf);
    out_linebuf := 'Total Cumulative Records = ' &#0124; &#0124; TO_CHAR(cuml_rec_count);
    UTL_FILE.put_line(outfile,out_linebuf);
    UTL_FILE.fclose(outfile);
    EXIT;
    ELSE
    UTL_FILE.get_line(infile,in_linebuf);
    cuml_rec_count := cuml_rec_count + 1;
    rec_count := rec_count + 1;
    out_linebuf := in_linebuf;
    UTL_FILE.put_line(outfile,out_linebuf);
    END IF;
    END LOOP;
    UTL_FILE.fclose_all;
    END mytest7;
    show errors

Maybe you are looking for

  • Backup (clone) disk - cannot open apps

    I am very careful with backups, using a combination of Time Machine (for incremental time-stamped backups) and I also do a complete clone, on a weekly basis, of my entire HD on to a FireWire backup. To be sure that the backup has worked, I always res

  • How to change the JCA JNDI dynamically using FTP Adapter

    We have 5 FTP Servers, each having a directory to poll. We have created 5 CCI instances for these FTP Adapters in the FTPAdapter deployment. We created a BPEL process and using FTP Adapter to connect to above mentioned servers. Question: Customer's r

  • JCheckbox and DPI

    Java version 1.5.0_06 I have a column in a table that contains check boxes. Using the Windows look and feel the spacing (insets) around the check box in each cell is not proportionally the same for 96 DPI as it is for 120 DPI. Using the default look

  • Windows 7 preinstalled marked as not genuine

    I had some problems with my laptop so decided to format the harddrive and start again. During this process my laptop crashed and got stuck. I had to use a windows recovery disk to get it back up again. For some reason it said that the product kep, on

  • Opening Saved PDFs

    When I save a PDF, say from a website or from an online class, I receive an error message when I go back later to open it.  The error is: "Adobe Reader could not open 'IECA_STI-Brochure-2014.pdf' because it is either not a supported file type or beca