How to read file to blob variable

I Write so:
fil BFILE;
lobd BLOB;
filename VARCHAR2(255);
filename:='1.doc';
fil:=BFILENAME('DOCS_IN',filename);
dbms_lob.CREATETEMPORARY(lobd,true);
dbms_lob.fileopen(fil, dbms_lob.lob_readonly);
dbms_lob.LOADFROMFILE( lobd,fil,dbms_lob.getlength(fil), 1, 1);
Ошибка:
ORA-22285: non-existent directory or file for GETLENGTH operation
But file was successfully open by dbms_lob.fileopen.

create table temp
key INTEGER,
trash BLOB
create directory hdoc as '/tmp';
--For this example, /tmp is the directory and test.bin is the filename.
--You must ensure that a file exist at that location (/tmp/test.bin) for
--this sample to work. The file and location referenced should be that which
--is on the server.
DECLARE
lobd BLOB;
fils BFILE := BFILENAME('HDOC', 'test.bin');
amt INTEGER;
BEGIN
DBMS_LOB.FILEOPEN(fils, dbms_lob.file_readonly);
amt:=DBMS_LOB.getlength(fils);
insert into temp values (1, empty_blob()) returning trash into lobd;
DBMS_LOB.LOADFROMFILE(lobd, fils, amt);
COMMIT;
DBMS_LOB.FILECLOSE(fils);
END;

Similar Messages

  • Getting a PDF file in BLOB variable

    Hi Forum,
    I want to get a PDF file in BLOB variable from DB server.
    Further I will pass that variable to a procedure; in that procedure that variable will be inserted into a table.
    I have called procedure (inserting BLOB into a table) is ready.
    Can someone advice?
    thanks,
    regards.

    user573927 wrote:
    Hi Forum,
    I want to get a PDF file in BLOB variable from DB server.
    Further I will pass that variable to a procedure; in that procedure that variable will be inserted into a table.
    I have called procedure (inserting BLOB into a table) is ready.
    Can someone advice?It's all fine you saying what you want, but how about telling us what you've already done and where it's going wrong

  • [Urgent] How to read files from different directories?

    I am new to Java Programming, I would like to know how to read files from directories other than the current one? (example as follows)
    ProjectDirectory
    |--MainDirectory
    |--MainProgram.java
    |--SupplementDirectory
    |--SupplementProgram.java
    |--Pictures
    |--Image.gif
    What should I write in the MainProgram.java so that I can use the supplementProgram.java from MainProgram and read the Image.gif file from the MainProgram.java?
    Thanks

    Run through the I/O tutorial here. It should get you up to speed on this sort of thing...

  • How to get file count in variable?

    dear all,
    how to get file count in variable?
    regards
    Naseer

    Hi Nazeer ,
    It wont take much time .. so simple :- )
    Create one os comand step
    ( for unix) Use
    wc -l filename.txt > someoutputfile.txt
    Now the number of lines in your file will be there in the output file ( someoutputfile.txt )
    Step2 :-
    Now use Cezar's logic to fetch the variable value ( file count ) from the output file .. ( select value for a variable from a file )
    This will not take eeven a second to finish the job.
    Regards,
    Rathish A M

  • Assigning server file to Blob variable in pl/sql procedure

    I have a file on the Unix box say 'test.txt' at '/temp/..'(path) which might be of a any size(which is not known), Now I wanted to read & open that file into a Blob variable in my pl/sql procedure. How can I do that ?
    Can any one please help me....
    Thanks
    Ravi

    This is not an appropriete forum to ask this pl/sql question.
    Check "DBMS_LOB Demos / Blob Load Demo" part of the below reference for an example -
    http://psoug.org/reference/dbms_lob.html

  • How to read file from remote machine

    Hello,
    Hi, i would like to know how to read text file from remote machine using java source code, any code ?
    Thanks very much;
    Best regards
    Kim

    On the server, perform the following steps:
    Parse the request and determine the file to serve
    Open a FileInputStream to the appropriate file
    Obtain a reference to the Servlet OutputStream
    Pipe the bytes from the file to the output stream
    Flush and close the streamYou might want to call HttpServletResponse.setContentType("application/octet") to indicate to the browser that a file download will be occurring. Do so before getting the reference to the Servlet's OutputStream.
    - Saish

  • How to read file from server if I have a logical file path?

    Hi guys,
    I'm having a pretty "on the run" question,
    My program is currently reading a file from server using "open dataset" with file path like this (just example)
    /usr/interface/abc/bcd/testfile.dat
    Now I got a requirement to make it more consistent to read files, instead of reading that physical file name, I should read the files from a specific folder using logical path.
    So I go to T code "FILE" and created a logical path called ZABC_FILE_PATH, unix compatible, with physical path is (for example),
    /usr/interface/<sysid>/<client>/<filename>
    My question is, can I still use open dataset statement to read this? if yes, how do I do that? If no, there should be alternative way, please let me know what you think. Thanks,

    Thanks all, I figured it out.
    ONe thing is that typo double quote
    The other thing is the importing part, I need the full file path.
    CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
      EXPORTING
        CLIENT                           = SY-MANDT
        logical_path                     = 'ZABC_MY_LOGICAL_FILE_PATH'
    *   OPERATING_SYSTEM                 = SY-OPSYS
    *   PARAMETER_1                      = ' '
    *   PARAMETER_2                      = ' '
    *   PARAMETER_3                      = ' '
    *   USE_BUFFER                       = ' '
        file_name                        =  v_1
    *   USE_PRESENTATION_SERVER          = ' '
    *   ELEMINATE_BLANKS                 = 'X'
      IMPORTING
        FILE_NAME_WITH_PATH              = v_what_I_need
    * EXCEPTIONS
    *   PATH_NOT_FOUND                   = 1
    *   MISSING_PARAMETER                = 2
    *   OPERATING_SYSTEM_NOT_FOUND       = 3
    *   FILE_SYSTEM_NOT_FOUND            = 4
    *   OTHERS                           = 5
    I really appreciate your contributions, thanks again!

  • How to read file header/open filein binary mode

    i am using FileConnenction API to read from a file. how can i open a file in binary mode so that i can read file header. In other words i want to open a file in binary mode.

    You can always try looking at the [Header Signatures|http://www.techpathways.com/uploads/headersig.txt]. But it would probably be easier to adjust your application so it doesn't have to guess.
    ~

  • How to read files in whole directory

    hi everybosy i have got a directory called grepdatabase in the following path
    /users/zer/gd.
    it has 3000 files in it.i have to read each file and do soem process and write it into another file.
    but with the following code it says, directorydoesnot exists.but i have the directory,with all the files in it.
    File database = new File("c:/Domain/nbi.bbsrc.ac.uk/Users/zer/gd");
            if (database.exists() && database.isDirectory()) {
                String datafiles[] = database.list();
                for (int i = 0; i < datafiles.length; i++) {
                    System.out.println("processing file: " + database.getAbsolutePath() +
                            "/" + datafiles[0]);
            } else {
                System.out.println("Database exists: "+database.exists()+"\nDatabase is Directory: "+database.isDirectory());
            }can anyone help me how to read multiple files...

    ur code can be little modified as follows to make it work flawlessly
           File database = new File("c:/Domain/nbi.bbsrc.ac.uk/Users/zer/gd");
                  if (database.exists() && database.isDirectory()) {
                      //String datafiles[] = database.list();
                      //Instead use file list here
                      File[] datafiles = database.listFiles();
                      for (int i = 0; i < datafiles.length; i++) {
                      //    System.out.println("processing file: " + database.getAbsolutePath() +
                      //            "/" + datafiles[0]);
                       System.out.println("processing file: " + datafiles.getName());
    } else {
    System.out.println("Database exists: "+database.exists()+"\nDatabase is Directory: "+database.isDirectory());
    BR

  • How to read files....plzzz

    Hi! All,
    I have a problem in reading files using jfilechooser class.
    when i select open menuitem from the file menu and reading it through
    the file reader class it is giving nullpointer exception.
    Also i tried by hardcoding filename in filereader class instead of using getSelectedfile().This time it is not giving null pointer exception but it is showing any stuff.
    Here's the code i am using...
    int returnVal = fc.showOpenDialog(openpanel);
    if(returnVal == JFileChooser.APPROVE_OPTION){
    file = fc.getSelectedFile();
                   //This is where a real application would open the file.
    if(fc == null)
         file = new File("D:\\karthik\\java\\");
         file = new File("D:\\karthik\\java\\kar.txt");
         fc.setCurrentDirectory(file);
    BufferedReader infile = new BufferedReader(new FileReader(file));
         files.append(infile.readline()); //files is the textarea..

    how come you do a fc.setCurrentDirectory(file);?
    where exactly do you get the NullPointerException? what does your stacktrace say?
    thomas

  • How to read files on server from a java program?

    Hello,
    I am fairly new to JSP programming. I have an issue with reading files. I am trying to call method of a normal java file from a jsp program. The method I am trying to call does some IO operation on Files. I have the files in the same directory as my class files on server that is in WEB-INF/classes folder. In my java program, I am giving just the file name to open because the files and the classes are in the same directory. But this is not working.
    What exactly should I do to read a file from a java program, that is running on the server?
    Any help is appreciated.
    Thanks,
    Krishna

    String realFilePath = application.getRealPath("/WEB-INF/myFile.txt");
    File fileToOpen = new File(realFilePath);
    out.println(fileToOpen.getAbsolutePath() + ": exists? " + fileToOpen.exists());in this case "application" is a reference to the ServletContext.
    It is an implicit variable in a JSP. In a servlet:
    ServletContext application = getServletConfig().getServletContext();

  • HOW to read file using ftp???

    Hi to all,
    I have problem with reading file using ftp connection, i want to read only 1024 bytes for one time, and i have
    next code wich read this:
    byte buffer[] = new byte[1024];
    while( (readCount = input.read(buffer)) > 0) {
    bos.write(buffer, 0, readCount);
    but I dont know how to put all read data in one byte[] if i dont know length of file.
    I can't do some like: byte file[] = new file[1000000];
    Thanks for all sugestions!

          * Download a file from a FTP server. A FTP URL is generated with the following syntax:
         * <code>ftp://user:password@host:port/filePath;type=i</code>.
          * @param ftpServer FTP server address (incl. optional port ':portNumber').
          * @param user Optional user name to login.
          * @param pwd Optional password for <i>user</i>.
          * @param fileName Name of file to download (with optional preceeding relative path, e.g. one/two/three.txt).
          * @param destination Destination file to save.
         * @throws MalformedURLException, IOException on error.
         public void download(String ftpServer, String user, String pwd, String fileName, File destination) throws MalformedURLException, IOException {
            if (ftpServer != null && fileName != null && destination != null) {
                StringBuffer sb = new StringBuffer("ftp://");
                if (user != null && pwd != null) { //need authentication?
                    sb.append(user);
                    sb.append(':');
                    sb.append(pwd);
                    sb.append('@');
                }//else: anonymous access
                sb.append(ftpServer);
                sb.append('/');
                sb.append(fileName);
                sb.append(";type=i"); //a=ASCII mode, i=image (binary) mode, d= file directory listing
                BufferedInputStream bis = null;
                BufferedOutputStream bos = null;
                try {
                    URL url = new URL(sb.toString());
                    URLConnection urlc = url.openConnection();
                    bis = new BufferedInputStream(urlc.getInputStream());
                    bos = new BufferedOutputStream(new FileOutputStream(destination.getName()));
                    int i;
                    while ((i = bis.read()) != -1) { //read next byte until end of stream
                        bos.write(i);
                    }//next byte
                } finally {
                    if (bis != null) try { bis.close(); } catch (IOException ioe) { /* ignore*/ }
                    if (bos != null) try { bos.close(); } catch (IOException ioe) { /* ignore*/ }
            }//else: input unavailable
        }//download()If you don't want to strore the data into a file, use ByteArrayOutputStream instead of a FileOutputStream.

  • How to Read file name which we are dealing with ODI File tool

    Hi,
    We are using ODi10g version and we have requirement to move file from one place to another place. We are using ODIFileMove utility but we also want to read file name.
    Any help.
    Thanks in Advance.

    You can accomplish this with a fairly simple Jython script.  Use the os.listdir(<directory>) command to get the name of files in a given directory. 
    You can then (still in the Jython script) loop through the files and move them to a desired location (bypassing the OdiFileMove tool) OR use the Jython script to write the file names to a SQL table.  Then, use an ODI procedure to loop through the newly inserted records and store the file name in an ODI variable that you can then use in your OdiFileMove tool etc.
    I often refer to this blog entry from Gurcan Orhan as a starting point for this kind of task: Loading multiple files with ODI | Gurcan Orhan&amp;#039;s Oracle Data Integrator Blog

  • How to read File Header in JAVA

    I wanna upload a(doc/pdf) file from client site, where I hv to check whether the the file is originally a doc/pdf file or not, I mean not just the extension, but the actual header information of the file. Please some body help me to do this, I dont know how to read the file header. Thnx in advnc.

    You can always try looking at the [Header Signatures|http://www.techpathways.com/uploads/headersig.txt]. But it would probably be easier to adjust your application so it doesn't have to guess.
    ~

  • How to read file in sync.?

    Hi all,
    I am using URLLoader to read file, but it has trouble/problem
    that is need to wait the load complete event to finish read file
    action. So i cannot use it to load file to read some configuration
    file to assign to the class variables.
    I want to use as follow:
    var config:ConfigFile = new ConfigFile();
    var file:String = "data.ini";
    config.Load(file);
    var x:int = config.X;
    var y:Strin = config.Y;
    If I use URLLoad that cannot implement to get properties
    directly, I need to wait complete event then I need to dispatch my
    own event again to tell the caller is allow to get properties.
    Anyone has other method to help me to implement these usage
    way?
    Thanks.

    Hi,
    Sync Read is an outbound operation, you can not use inbound configuration parameters for it.
    http://docs.oracle.com/cd/E17904_01/integration.1111/e10231/adptr_file.htm#CACHDJFF
    If you have a large file you may use ChunkedRead
    http://docs.oracle.com/cd/E17904_01/integration.1111/e10231/adptr_file.htm#BABJFCBH
    Cheers,
    Vlad
    Give points - it is good etiquette to reward an answerer points (5 - helpful; 10 - correct) for their post if they answer your question. If you think this is helpful, please consider giving points

Maybe you are looking for

  • How to change font size in jquery fancybox

    I'm using the fancybox to get pop ups when I want to give more information about a subject. It works great, but in my opinion the font size is not big enough. I tried to ad: #fancybox-content {           font-family:Gotham, "Helvetica Neue", Helvetic

  • XSL, XML, and Metadata Names in Web Gallery Templates

    I don't know exactly how to ask the question, but what I want to do is customize the information that appears below a full-size image in an HTML web gallery. For the existing HTML gallery templates, this is the area where "caption" data is placed. Yo

  • How to get he names of all the local drives that are present in hdd

    Hi ABAP Experts, I want to get the names of all the local drives that are present in hdd on local system using ABAP. Is this technically possible. If so how. Thanks & Regards, Aexandr Ciunchik

  • Avoid Highways in Maps

    Why is there no way to avoid highways when getting directions in Maps? Sometimes I'm not always looking for the quickest way there, but instead the safest. Example: A month ago I was in a town (on business) I was not familiar with and the weather tur

  • Shameful support

    Been a customer for over 10 years. Been running a web hosting company also for over ten years. Verizon has blacklisted my company's mail server IP address. So, it says to visit this page to request delisting. http://my.verizon.com/micro/whitelist/ I