Re: file random write access from within a database
From: Remigiusz Sokolowski <remigiusz.sokolowski_at_nordea.com>
Date: Mon, 14 Mar 2011 07:56:05 +0100
Message-ID: <4D7DBC05.70603_at_nordea.com>
Sebastian Kolski pisze:
>> hi,
>>
>> I wonder if it is possible to write to a file from within a database at
>> the chosen position.
>>
>> What I want to achieve is to modify a kind of header of simple text file
>> (few tens of MB in size).
>> I could read it to a LOB/table/buffer/whatever, modify few bytes and
>> write it back to the file in its entirety.
>> But this is rather unacceptable solution - I would rather imagine I open
>> a file, set a position, write few bytes at this position (adding or
>> eventually replacing some bytes on specified length), close a file.
>>
>> I tried fseek, but it works in the Read-like mode only, as I get
>> ERROR at line 1:
>> ORA-29283: invalid file operation
>> ORA-06512: at "SYS.UTL_FILE", line 1219
>> ORA-06512: at "REMS.WRITE_AT", line 16
>> ORA-06512: at line 1
>>
>>
>> Regards
>> Remigiusz
>>
Date: Mon, 14 Mar 2011 07:56:05 +0100
Message-ID: <4D7DBC05.70603_at_nordea.com>
Sebastian Kolski pisze:
> On 11/03/2011 14:14, Remigiusz Sokolowski wrote:
>> hi,
>>
>> I wonder if it is possible to write to a file from within a database at
>> the chosen position.
>>
>> What I want to achieve is to modify a kind of header of simple text file
>> (few tens of MB in size).
>> I could read it to a LOB/table/buffer/whatever, modify few bytes and
>> write it back to the file in its entirety.
>> But this is rather unacceptable solution - I would rather imagine I open
>> a file, set a position, write few bytes at this position (adding or
>> eventually replacing some bytes on specified length), close a file.
>>
>> I tried fseek, but it works in the Read-like mode only, as I get
>> ERROR at line 1:
>> ORA-29283: invalid file operation
>> ORA-06512: at "SYS.UTL_FILE", line 1219
>> ORA-06512: at "REMS.WRITE_AT", line 16
>> ORA-06512: at line 1
>>
>>
>> Regards
>> Remigiusz
>>
> > If you only want to change few bytes then i think it is possible with > java stored procedure and java.io.RandomAccessFile > (http://download.oracle.com/javase/tutorial/essential/io/rafs.html). > If you want to change length of the file, for example insert some text, > then it is not possible without moving some data (consider how > physically data is stored on hd). > > Sebastian >
Thanks for all the answers - I am sure I can do it with C or Java. I just search for something really simple (I mean UTL_FILE here). And what You told me is a signal I must do it little more complicated
Thank You very much
Regards
Remigiusz
-- Pole nakazi ---------------------------------------------------------------------- Remigiusz Sokolowski <remigiusz.sokolowski_at_nordea.com> pos : DBA at DIiUSI addr : Nordea Bank Polska SA, Luzycka 6A Street, 81-537 Gdynia, Poland phone : +48 58 667 17 43 mobile: +48 602 42 42 77 Nordea Bank Polska S.A. z siedzibą w Gdyni, ul. Kielecka 2, 81-303 Gdynia, wpisaną do Rejestru Przedsiębiorców Krajowego Rejestru Sądowego pod numerem: 0000021828, dla której dokumentację przechowuje Sąd Rejonowy Gdańsk - Północ w Gdańsku, VIII Wydział Gospodarczy Krajowego Rejestru Sądowego, o kapitale zakładowym i wpłaconym w wysokości: 227.593.500,00 złotych, NIP: 586-000-78-20, REGON: 190024711-- http://www.freelists.org/webpage/oracle-lReceived on Mon Mar 14 2011 - 01:56:05 CDT