Inserting files into lob columns stored procedure

i have created a stored procedure that inserts file into the database as a lob object. the source code converts the file into a byte [] stream (c#) and assigns to the parameter . please check the pl/sql stored procdure. is there a way to debug pl/sql code in vs 2005.
PROCEDURE "STARDOC"."INSERTFILE" (
"TITLE" IN VARCHAR2,
"AUTHOR" IN VARCHAR2,
"DESCRIPTION" IN VARCHAR2,
"PUBLISHER" IN VARCHAR2,
"LANGUAGE_ID" IN NUMBER,
"CONTENT" IN BLOB DEFAULT empty_blob(),
"FILENAME" IN VARCHAR2,
"EXTENSION" IN VARCHAR2,
"APPID" IN NUMBER,
"DOC_SIZE" IN NUMBER,
"CONTENT_TYPE_ID" IN NUMBER,
"IDENTIFIER" IN VARCHAR2,
"DOC_ID" OUT NUMBER) IS
docid number;
BEGIN -- executable part starts here
     SELECT seq_document_id.NEXTVAL INTO docid FROM dual;
     --Documents table     
     INSERT INTO DOCUMENTS(document_id, content, filename,
                              extension, retrieval_metadata_id,
                                   content_metadata_id,description)
          VALUES (docid,content,filename,extension,docid,docid,description);
     --Content Metadata table     
     INSERT INTO CONTENT_METADATA(content_metadata_id, document_id,
                                        author, title, description,
                                        publisher, language_id, content_type_id)
          VALUES (docid, docid, author,
                    title, description, publisher,     
                    language_id, content_type_id);
     --retrieval metadata table
     INSERT INTO RETRIEVAL_METADATA(retrieval_metadata_id, identifier)
          VALUES (docid,identifier);
     --Storage metadata table
     INSERT INTO STORAGE_METADATA(storage_metadata_id, application_id,doc_size)
          VALUES (docid,appid, doc_size);
EXCEPTION
--rollback when an expetion occurs
WHEN OTHERS THEN
          ROLLBACK;
END "INSERTFILE";

Yes.
Are you experiencing any issues? From your posts above there is no mention of any issues you are facing that could ba attributed to the LOB size.
Has the procedure been run at least once?

Similar Messages

  • Read XML file into databased using stored procedure

    I need to read an xml file into my database using a stored procedure. I looked at a couple of tutorials, but I am kind of lost and am looking for some guidance. I will eventually need to only pull a handfull of the data in based on the USER ID. Any help will be greatly appreciated. I have been given a schema file and an example file of how the data will me sent to me. The schema file is below:
    <h1>Schema File</h1>
    <?xml version="1.0" encoding="utf-8"?>
    <!--Generated by Turbo XML 2.4.1.100. Conforms to w3c http://www.w3.org/2001/XMLSchema-->
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xsd:element name="root">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="Report">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element ref="Biller" />
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="Biller">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element ref="BillerName" />
    <xsd:element ref="BillerIdNumber" />
    <xsd:element ref="PartnerInfo" />
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="BillerName">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="BillerIdNumber">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="PartnerInfo">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element ref="PartnerName" />
    <xsd:element ref="PartnerVenderNumber" />
    <xsd:element ref="PartnerStreet01" />
    <xsd:element ref="PartnerStreet02" />
    <xsd:element ref="PartnerCity" />
    <xsd:element ref="PartnerState" />
    <xsd:element ref="PartnerZip" />
    <xsd:element ref="PartnerCountry" />
    <xsd:element ref="PartnerActive" />
    <xsd:element ref="PartnerContactName" />
    <xsd:element ref="PartnerEmailAddress" />
    <xsd:element ref="PartnerContactPhone" />
    <xsd:element ref="PartnerFaxNumber" />
    <xsd:element ref="PartnerUpdateUser" />
    <xsd:element ref="PartnerUpdateDate" />
    <xsd:element ref="PartnerDocColor" />
    <xsd:element ref="PartnerDocDistribution" />
    <xsd:element ref="PartnerDocPrinting" />
    <xsd:element ref="PartnerDocTiming" />
    <xsd:element ref="Delivery" maxOccurs="unbounded" />
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="PartnerName">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="PartnerVenderNumber">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="PartnerStreet01">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerStreet02">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerCity">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerState">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerZip">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerCountry">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerActive">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerContactName">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerEmailAddress">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerContactPhone">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerFaxNumber">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerUpdateUser">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerUpdateDate">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerDocColor">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerDocDistribution">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerDocPrinting">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="PartnerDocTiming">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="Delivery">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element ref="DeliveryType" />
    <xsd:element ref="DeliveryContactName" />
    <xsd:choice>
    <xsd:element ref="ReceivingStreet01" />
    <xsd:element ref="ReceivingStreet02" />
    <xsd:element ref="ReceivingCity" />
    <xsd:element ref="ReceivingState" />
    <xsd:element ref="ReceivingZip" />
    <xsd:element ref="ReceivingCountry" />
    <xsd:element ref="DeliveryEmailAddress" />
    <xsd:element ref="DeliveryCompanyId" />
    <xsd:element ref="DeliveryUserId" />
    <xsd:element ref="DeliveryFormatType" />
    <xsd:element ref="SecureType" />
    <xsd:element ref="SecureQuestion" />
    <xsd:element ref="SecureAnswer" />
    <xsd:element ref="DeliveryFaxNumber" />
    </xsd:choice>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="DeliveryType">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="DeliveryContactName">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="DeliveryEmailAddress">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="SecureType">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="SecureQuestion">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="SecureAnswer">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="DeliveryFormatType">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="DeliveryCompanyId">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="DeliveryUserId">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="DeliveryFaxNumber">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="ReceivingStreet01">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="ReceivingStreet02">
    <xsd:complexType />
    </xsd:element>
    <xsd:element name="ReceivingCity">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="ReceivingState">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="ReceivingZip">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="ReceivingCountry">
    <xsd:complexType mixed="true">
    <xsd:choice />
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    <h1>Example File</h1>
    <?xml version="1.0" encoding="utf-8"?>
    <Report>
    <Biller>
    <BillerName>DONATO TEST BILLER</BillerName>
    <BillerIdNumber>999999999</BillerIdNumber>
    <PartnerInfo>
    <PartnerName>TEST TRADING PARTNER</PartnerName>
    <PartnerVenderNumber>999999999</PartnerVenderNumber>
    <PartnerStreet01 />
    <PartnerStreet02 />
    <PartnerCity />
    <PartnerState />
    <PartnerZip />
    <PartnerCountry />
    <PartnerActive />
    <PartnerContactName />
    <PartnerEmailAddress />
    <PartnerContactPhone />
    <PartnerFaxNumber />
    <PartnerUpdateUser />
    <PartnerUpdateDate />
    <PartnerDocColor />
    <PartnerDocDistribution />
    <PartnerDocPrinting />
    <PartnerDocTiming />
    <Delivery>
    <DeliveryType>EMAIL</DeliveryType>
    <DeliveryContactName>Kiran</DeliveryContactName>
    <DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
    </Delivery>
    <Delivery>
    <DeliveryType>SECURE</DeliveryType>
    <DeliveryContactName />
    <DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
    <SecureType />
    <SecureQuestion>Pet Name</SecureQuestion>
    <SecureAnswer>040698de9bf14ef87d8cbaf46b8ecddc</SecureAnswer>
    <DeliveryFormatType />
    </Delivery>
    <Delivery>
    <DeliveryType>CEO</DeliveryType>
    <DeliveryContactName />
    <DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
    <DeliveryCompanyId>WFADM618</DeliveryCompanyId>
    <DeliveryUserId>PAULSEN</DeliveryUserId>
    <DeliveryFormatType />
    </Delivery>
    <Delivery>
    <DeliveryType>FAX</DeliveryType>
    <DeliveryContactName>Kiran</DeliveryContactName>
    <DeliveryFaxNumber>4807244340</DeliveryFaxNumber>
    <DeliveryFormatType>PDF</DeliveryFormatType>
    </Delivery>
    <Delivery>
    <DeliveryType>DOC</DeliveryType>
    <DeliveryContactName />
    <ReceivingStreet01>2600 South Price Road</ReceivingStreet01>
    <ReceivingStreet02 />
    <ReceivingCity>Chandler</ReceivingCity>
    <ReceivingState>AZ</ReceivingState>
    <ReceivingZip>85248</ReceivingZip>
    <ReceivingCountry>United States</ReceivingCountry>
    </Delivery>
    <Delivery>
    <DeliveryType>DR</DeliveryType>
    <DeliveryContactName />
    <DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
    <DeliveryCompanyId>WFADM618</DeliveryCompanyId>
    <DeliveryUserId>PAULSEN</DeliveryUserId>
    <DeliveryFormatType />
    </Delivery>
    </PartnerInfo>
    </Biller>
    </Report>

    Try with a XMLTABLE function
    For example to Extract BillerName and BillerID
    with t as(select xmltype( '<?xml version="1.0" encoding="utf-8"?>
    <Report>
    <Biller>
    <BillerName>DONATO TEST BILLER</BillerName>
    <BillerIdNumber>999999999</BillerIdNumber>
    <PartnerInfo>
    <PartnerName>TEST TRADING PARTNER</PartnerName>
    <PartnerVenderNumber>999999999</PartnerVenderNumber>
    <PartnerStreet01 />
    <PartnerStreet02 />
    <PartnerCity />
    <PartnerState />
    <PartnerZip />
    <PartnerCountry />
    <PartnerActive />
    <PartnerContactName />
    <PartnerEmailAddress />
    <PartnerContactPhone />
    <PartnerFaxNumber />
    <PartnerUpdateUser />
    <PartnerUpdateDate />
    <PartnerDocColor />
    <PartnerDocDistribution />
    <PartnerDocPrinting />
    <PartnerDocTiming />
    <Delivery>
    <DeliveryType>EMAIL</DeliveryType>
    <DeliveryContactName>Kiran</DeliveryContactName>
    <DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
    </Delivery>
    <Delivery>
    <DeliveryType>SECURE</DeliveryType>
    <DeliveryContactName />
    <DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
    <SecureType />
    <SecureQuestion>Pet Name</SecureQuestion>
    <SecureAnswer>040698de9bf14ef87d8cbaf46b8ecddc</SecureAnswer>
    <DeliveryFormatType />
    </Delivery>
    <Delivery>
    <DeliveryType>CEO</DeliveryType>
    <DeliveryContactName />
    <DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
    <DeliveryCompanyId>WFADM618</DeliveryCompanyId>
    <DeliveryUserId>PAULSEN</DeliveryUserId>
    <DeliveryFormatType />
    </Delivery>
    <Delivery>
    <DeliveryType>FAX</DeliveryType>
    <DeliveryContactName>Kiran</DeliveryContactName>
    <DeliveryFaxNumber>4807244340</DeliveryFaxNumber>
    <DeliveryFormatType>PDF</DeliveryFormatType>
    </Delivery>
    <Delivery>
    <DeliveryType>DOC</DeliveryType>
    <DeliveryContactName />
    <ReceivingStreet01>2600 South Price Road</ReceivingStreet01>
    <ReceivingStreet02 />
    <ReceivingCity>Chandler</ReceivingCity>
    <ReceivingState>AZ</ReceivingState>
    <ReceivingZip>85248</ReceivingZip>
    <ReceivingCountry>United States</ReceivingCountry>
    </Delivery>
    <Delivery>
    <DeliveryType>DR</DeliveryType>
    <DeliveryContactName />
    <DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
    <DeliveryCompanyId>WFADM618</DeliveryCompanyId>
    <DeliveryUserId>PAULSEN</DeliveryUserId>
    <DeliveryFormatType />
    </Delivery>
    </PartnerInfo>
    </Biller>
    </Report>')xml from dual)
    select q.* from t,xmltable('/Report' passing t.xml columns
    BillerName varchar2(20) PATH
                          '/Report//Biller/BillerName')q
            BILLERNAME     BILLERID
         DONATO TEST BILLER     999999999

  • How to read/write .CSV file into CLOB column in a table of Oracle 10g

    I have a requirement which is nothing but a table has two column
    create table emp_data (empid number, report clob)
    Here REPORT column is CLOB data type which used to load the data from the .csv file.
    The requirement here is
    1) How to load data from .CSV file into CLOB column along with empid using DBMS_lob utility
    2) How to read report columns which should return all the columns present in the .CSV file (dynamically because every csv file may have different number of columns) along with the primariy key empid).
    eg: empid report_field1 report_field2
    1 x y
    Any help would be appreciated.

    If I understand you right, you want each row in your table to contain an emp_id and the complete text of a multi-record .csv file.
    It's not clear how you relate emp_id to the appropriate file to be read. Is the emp_id stored in the csv file?
    To read the file, you can use functions from [UTL_FILE|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#BABGGEDF] (as long as the file is in a directory accessible to the Oracle server):
    declare
        lt_report_clob CLOB;
        l_max_line_length integer := 1024;   -- set as high as the longest line in your file
        l_infile UTL_FILE.file_type;
        l_buffer varchar2(1024);
        l_emp_id report_table.emp_id%type := 123; -- not clear where emp_id comes from
        l_filename varchar2(200) := 'my_file_name.csv';   -- get this from somewhere
    begin
       -- open the file; we assume an Oracle directory has already been created
        l_infile := utl_file.fopen('CSV_DIRECTORY', l_filename, 'r', l_max_line_length);
        -- initialise the empty clob
        dbms_lob.createtemporary(lt_report_clob, TRUE, DBMS_LOB.session);
        loop
          begin
             utl_file.get_line(l_infile, l_buffer);
             dbms_lob.append(lt_report_clob, l_buffer);
          exception
             when no_data_found then
                 exit;
          end;
        end loop;
        insert into report_table (emp_id, report)
        values (l_emp_id, lt_report_clob);
        -- free the temporary lob
        dbms_lob.freetemporary(lt_report_clob);
       -- close the file
       UTL_FILE.fclose(l_infile);
    end;This simple line-by-line approach is easy to understand, and gives you an opportunity (if you want) to take each line in the file and transform it (for example, you could transform it into a nested table, or into XML). However it can be rather slow if there are many records in the csv file - the lob_append operation is not particularly efficient. I was able to improve the efficiency by caching the lines in a VARCHAR2 up to a maximum cache size, and only then appending to the LOB - see [three posts on my blog|http://preferisco.blogspot.com/search/label/lob].
    There is at least one other possibility:
    - you could use [DBMS_LOB.loadclobfromfile|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i998978]. I've not tried this before myself, but I think the procedure is described [here in the 9i docs|http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96591/adl12bfl.htm#879711]. This is likely to be faster than UTL_FILE (because it is all happening in the underlying DBMS_LOB package, possibly in a native way).
    That's all for now. I haven't yet answered your question on how to report data back out of the CLOB. I would like to know how you associate employees with files; what happens if there is > 1 file per employee, etc.
    HTH
    Regards Nigel
    Edited by: nthomas on Mar 2, 2009 11:22 AM - don't forget to fclose the file...

  • Putting a .pdf file into a column in an oracle table

    I have created a table with one column as a blob so I can put 4800 .pdf files into that column of a table. Can anyone correct the ways I am trying to do this or let me know of a better way. I have tried several ways and have not been successful. Thanks.
    Here are the two ways I have tried that haven't worked.
    -- the storage table for the image file
    CREATE TABLE pdm (
    dname VARCHAR2(30), -- directory name
    sname VARCHAR2(30), -- subdirectory name
    fname VARCHAR2(30), -- file name
    iblob BLOB); -- image file
    -- create the procedure to load the file
    CREATE OR REPLACE PROCEDURE load_file (
    pdname VARCHAR2,
    psname VARCHAR2,
    pfname VARCHAR2) IS
    src_file BFILE;
    dst_file BLOB;
    lgh_file BINARY_INTEGER;
    BEGIN
    src_file := bfilename('O:\twilliams\DD_promotion\cards\', pfname);
    -- insert a NULL record to lock
    INSERT INTO pdm
    (dname, sname, fname, iblob)
    VALUES
    (pdname, psname, pfname, EMPTY_BLOB())
    RETURNING iblob INTO dst_file;
    -- lock record
    SELECT iblob
    INTO dst_file
    FROM pdm
    WHERE dname = pdname
    AND sname = psname
    AND fname = pfname
    FOR UPDATE;
    -- open the file
    dbms_lob.fileopen(src_file, dbms_lob.file_readonly);
    -- determine length
    lgh_file := dbms_lob.getlength(src_file);
    -- read the file
    dbms_lob.loadfromfile(dst_file, src_file, lgh_file);
    -- update the blob field
    UPDATE pdm
    SET iblob = dst_file
    WHERE dname = pdname
    AND sname = psname
    AND fname = pfname;
    -- close file
    dbms_lob.fileclose(src_file);
    END load_file;
    This one I get an error message on this statements:(dbms_lob.LOADBLOBFROMFILE(blob_loc,bfile_loc,dbms_l ob.lobmaxsize,bfile_offset,
    blob_offset) ; )
    DECLARE
    bfile_loc BFILE;
    blob_loc BLOB;
    bfile_offset NUMBER := 1;
    blob_offset NUMBER := 1;
    tot_len INTEGER;
    BEGIN
    /*-- First INSERT a row with an empty blob */
    INSERT INTO blob_tab VALUES (5, EMPTY_BLOB());
    COMMIT;
    /*-- SELECT the blob locator FOR UPDATE */
    SELECT blob_data INTO blob_loc FROM blob_tab
    WHERE id = 5 FOR UPDATE;
    /*- Obtain the BFILE locator */
    bfile_loc := bfilename('O:\twilliams\DD_promotion\cards\','00EAL.pdf');
    /*-- Open the input BFILE */
    dbms_lob.fileopen(bfile_loc, dbms_lob.file_readonly);
    /*-- Open the BLOB */
    dbms_lob.OPEN(blob_loc, dbms_lob.lob_readwrite);
    /*-- Populate the blob with the whole bfile data */
    dbms_lob.LOADBLOBFROMFILE(blob_loc,bfile_loc,dbms_l ob.lobmaxsize,bfile_offset,
    blob_offset) ;
    /*-- Obtain length of the populated BLOB */
    tot_len := DBMS_LOB.GETLENGTH(blob_loc);
    /*-- Close the BLOB */
    dbms_lob.close(blob_loc);
    /*-- Close the BFILE */
    dbms_lob.fileclose(bfile_loc);
    COMMIT;
    /*-- Display the length of the BLOB */
    DBMS_OUTPUT.PUT_LINE('The length of the BLOB after population is: '||
    TO_CHAR(tot_len));
    END ;
    /

    CREATE TABLE test_blob (
    id NUMBER(15)
    , file_name VARCHAR2(1000)
    , image BLOB
    , timestamp DATE
    CREATE OR REPLACE DIRECTORY
    EXAMPLE_LOB_DIR
    AS
    'O:\twilliams\DD_promotion\cards\'
    CREATE OR REPLACE PROCEDURE Load_BLOB_from_file_image
    AS
    dest_loc BLOB;
    src_loc BFILE := BFILENAME('EXAMPLE_LOB_DIR', '009-1395.pdf');
    BEGIN
    INSERT INTO test_blob (id, file_name, image, timestamp)
    VALUES (1001, '009-1395.pdf', empty_blob(), sysdate)
    RETURNING image INTO dest_loc;
    DBMS_LOB.OPEN(src_loc, DBMS_LOB.LOB_READONLY);
    DBMS_LOB.OPEN(dest_loc, DBMS_LOB.LOB_READWRITE);
    DBMS_LOB.LOADFROMFILE(
    dest_lob => dest_loc
    , src_lob => src_loc
    , amount => DBMS_LOB.getLength(src_loc));
    DBMS_LOB.CLOSE(dest_loc);
    DBMS_LOB.CLOSE(src_loc);
    COMMIT;
    END;
    I am getting this error when I exec load_blob_from_file_image.
    ERROR at line 1:
    ORA-00972: identifier is too long
    ORA-06512: at "SYS.DBMS_LOB", line 716
    ORA-06512: at "DRAWING.LOADBLOBFROMFILEIMAGE", line 15
    ORA-06512: at line 1
    any ideas why?

  • Load & retrieve text files from lob column

    Dear All,
    I have created a table with CLOB column in it.
    Now I have to inset text files into that column and retrieve the file/ file contents from that column through stored proc.
    Can u please tell me how can i do that??
    Thank you,
    Gautam

    Examine two packages, Dbms_Lob and Utl_File. You are building your file from clob 'piece-by-piece' until you reach the end of clob.
    Pseudo
    - open file for writing (utl_file)
    - get the length of clob
    - get first part of clob (dbms_lob.substr)
    - apend part of clob (from previous) to the file
    - while not end of clob repeat previous two steps

  • How to insert  data into BLOB column  using sql

    Hi all,
    How to insert data into BLOB column directly using sql .
    create  table temp
      a blob,
      b clob);
    SQL> /
    Insert into temp  values ('32aasdasdsdasdasd4e32','adsfbsdkjf') ;
    ERROR at line 1:
    ORA-01465: invalid hex number
    Please help in this.Thanks,
    P Prakash

    see this
    How to store PDF file in BLOB column without using indirect datastore

  • How to open external files in a Java stored procedure?

    Hi y'all,
    I'm trying to open an external text file from a Java stored procedure. The java sp has been successfully loaded, resolved, published, etc. in Oracle. I'm using the following statement to try to open the file (enclosed in a try/catch block):
    BufferedReader fileObj = new BufferedReader(new FileReader("fileName.txt"));
    I'm getting a file not found error. Where is Oracle looking (i.e., what directory)?
    Your help is greatly appreciated,
    Gary

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Gary Nool ([email protected]):
    Hi y'all,
    I'm trying to open an external text file from a Java stored procedure. The java sp has been successfully loaded, resolved, published, etc. in Oracle. I'm using the following statement to try to open the file (enclosed in a try/catch block):
    BufferedReader fileObj = new BufferedReader(new FileReader("fileName.txt"));
    I'm getting a file not found error. Where is Oracle looking (i.e., what directory)?
    Your help is greatly appreciated,
    Gary<HR></BLOCKQUOTE>
    Hi Gary,
    you must use a "database directory", e.g:
    SQL>create directory WORKING_DIR as '/home2/common/';
    SQL> select * from all_directories;
    OWNER DIRECTORY_NAME
    DIRECTORY_PATH
    SYS WORKING_DIR
    /home2/common/
    Gert

  • Read text file into clob column

    Dear Oracle users and Oracle support,
    I have a text file that includes hundreds of data entries. The format is below. What I need to do is read each entry (
    <DATALOAD ................</DATALOAD>) into the CLOB column as a table record. Then create a loop in the table to convert each record into XML data type. I have general idea on how to convert CLOB to XML. The difficult part to me is read the each entry in the text file to CLOB table. Please let me know what technique I should use. Any recommendation and sample code are welcome! I appreciate!
    Thanks,
    Bing
    <DATALOAD ................</DATALOAD>
    <DATALOAD ................</DATALOAD>
    <DATALOAD ................</DATALOAD>
    <DATALOAD ................</DATALOAD>

    RBYL wrote:
    Hi,
    Thank you for your response. What I want to achieve is read the text file into ClOB column. There are hundreds reocords in the text file. The format is below. Each entry is '<DATALOAD (sensitive data here, use....... instead)</DATALOAD>' that needs to be read into clob table as a record. That is basically what I need to achieve.
    <DATALOAD ................</DATALOAD>
    <DATALOAD ................</DATALOAD>
    hundreds of them here........
    <DATALOAD ................</DATALOAD>
    <DATALOAD ................</DATALOAD>So, is it really a text file or is it a well structured XML file?
    Just reading it into a CLOB to process is not likely to be the best way.
    If each line of the file is a record, then you're likely to be better using something like External Tables.
    If it's a structured XML file, then it can be read using CLOB functionality into an XMLTYPE datatype and then shredded down into relational table structures.
    Be more clear in what your requirements are and we can help you better.
    {message:id=9360002}

  • How to save and retrieve an excel file as an object into lob column?

    Hi ,
    I need to save and retrieve the whole excel file with 3 or more sheets as an object into the lob column of table.
    For example:
    t_docments
    (doc_id number,
    excel_data clob
    All excel files need to be saved to excel_data column.
    What should I do?
    Thanks

    Did you check the asktom thread posted by Jens?
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P1
    1_QUESTION_ID:232814159006
    There's example of varies file types.Yes, I did try some examples.
    Those work for .doc/.pdf/.jpg files, BUT NOT for excel file.
    The following error happened when retrieving excel file(retrieving .doc/.pdf are OK)
    ORA-29285: file write error
    ORA-06512: at "SYS.UTL_FILE", line 18
    ORA-06512: at "SYS.UTL_FILE", line 375
    ORA-06512: at "SYS.UTL_FILE", line 990

  • How to load rm file into ordAudio column?

    Hello everybody,
    I made many attempts trying to insert aa.mp3(3.63Mb) and bb.rm(3.58Mb) file into ORDSYS.ordAudio column respectively with the same way.
    the result is: aa.mp3 was inserted successfully, but the bb.rm was not. It showed the error message: "java.sql.SQLException:ORA-01401:inserted value too large for column"
    Why? How can I insert *.rm into the ordAudio column?
    main code are grateful.

    >
    >
    1.tonight, I made another trying to insert aa.mp3(3.63Mb) and bb.rm(3.58Mb) file into ORDSYS.ordAudio column respectively with the same way.
    the result is: aa.mp3 was inserted successfully, but the bb.rm was not. It showed the error message: "java.sql.SQLException:ORA-01401:inserted value too large for column"
    And the main code is as following:
    private final static String EMPTY_AUDIO = "ordsys.ordaudio.init()"; //declare the EMPTY_AUDIO
    stmt = (OraclePreparedStatement)conn.prepareStatement( //
    "insert into TAB_NOAUDIT_AUDIO(NOAU_AU_SERIALNUMBER,"+
    "NOAU_AU_TYPE,NOAU_AU_KEYWORD,NOAU_AU_FILENAME,"+
    "NOAU_AU_MEDIA)"+
    " values (?,?,?,?," + EMPTY_AUDIO +")" );
    stmt.setString( 1, id );
    stmt.setString( 2, filetype );
    stmt.setString( 3, new String(keyword.getBytes("ISO8859-1")) );
    stmt.setString( 4, new String(filename.getBytes("ISO8859-1")) );
    // System.out.println("after 4th set..()!!");
    stmt.executeUpdate();
    stmt.close();
    //load the audio media file into table
    stmt=(OraclePreparedStatement)conn.prepareStatement(
         "select NOAU_AU_MEDIA from TAB_NOAUDIT_AUDIO where NOAU_AU_SERIALNUMBER = ? for update" );
    stmt.setString( 1, id );
    rset = (OracleResultSet)stmt.executeQuery();
    while(rset.next()) {
    media = (OrdAudio)rset.getCustomDatum( 1, OrdAudio.getFactory());
    File file = new File(filepath);
    FileInputStream fStream = new FileInputStream(file);
    media.loadDataFromInputStream(fStream);
    // System.out.println("after aumedia.loadDataFromInputStream()!!");
    fStream.close();
    I don't know why the error occured?
    Whether the rm file format is not recognized by ORDSYS.ordAudio or not?
    How can i do next?
    The error you get has nothing to do with the size of the media data. The error you are getting has to do with another field somewhere I think. The error you say has nothing to do with media data, but regular SQL.
    It all depends on where the error is... Do you get the error on the media.loadDataFromInputStream(fStream);? I suspect, you are getting the error on the insert. and that id or filetype are too big for the column.
    Could you tell me where the problem occurs? On the first insert? on the update?? I really can't debug with the amount of information here.
    In general, for debugging problems, you need to break it down smaller to find the errror.
    Pleas break down your insert to find the problem.
    2.Would you mind telling me more detail step or code for copying ordAudio data from table
    to another table with the same ORDSYS.ordAudio column property?
    One media column to another would simply be
    select sound into soundvar from oldtable where .....
    insert into newtable(newsound) values (soundvar) where ...;
    If from a lob....
    select lob into lobvar from....
    soundvar.source.localdata := lob;
    soundvar.setlocal();
    soundvar.setProperties();
    Larry
    Larry

  • How to insert document into xmltype column through an http post request with perl

    Oracle 11.2.0.3
    Windows server 2008r2
    Apache tomcat 7.0
    Oracle APEX 4.2.1
    Oracle APEX Listener 2.0
    I would like to insert a XML document into the database through an APEX restful web service. The POST into the web service in done with PERL. The following code will insert an empty record in a table with column of XMLType type.
    Perl Code
    use strict;
    use warnings;
    use LWP::UserAgent;
    use HTTP:Headers;
    my $headers = HTTP::Headers->new();
    my $url = "http://host:port:apex/<application_workspace>/<restfull service module>/<uri template>/
    my $sendthis = ('<?xml version="1.0" enconding="utf-8"?>
    <students>
    <row>
           <name>Mark</name>
          <age>30</age>
    </row>
    <./students>';)
    $headers -> header('Content-Type' => 'text/xml; charset=utf-8');
    my $request = HTTP:Request->new('POST', $url, $headers, $sendthis);
    $request-> protocol('HTTP/1.1');
    my $browser = LWP::UserAgent->new();
    my $response = $browser->request($request);
    my $gotthis= $response->content();
    my $the_file_data = $response->content();
    APEX restful service
    Method: POST
    Source type: PL/SQL
    MIME Types allowed: blank
    require secure access: none
    source:
    {declare
    doc varchar2(32000);
    begin
    insert into table <column name>
    values(doc);
    commit;
    end;
    Table code
    { create table <tablename>
    (column name XMLType>);
    The above code will insert an empty column into the table.
    Any ideas why?

    It's a really bad idea to assemble XML using strings and string concatenation in SQL or PL/SQL. First there is a 4K limit in SQL, and 32K limit in PL/SQL, which means you end up constructing the XML in chunks, adding uneccessary complications. 2nd you cannot confirm the XML is valid or well formed using external tools.
    IMHO it makes much more sense to keep the XML content seperated from the SQL / PL/SQL code
    When the XML can be stored a File System accessable from the database, The files can be loaded into the database using mechansims like BFILE.
    In cases where the XML must be staged on a remote file system, the files can be loaded into the database using FTP or HTTP and in cases where this is not an option, SQLLDR.
    -Mark

  • PROCESS TO INSERT FILE INTO CUSTOM TABLE

    Hello - grateful if anyone can assist.
    I have followed the official guide notes but am unable to insert a line with blob file into my custom table (APEX_AM_LEASES)
    Error message is as follows:
    ORA-06550: line 2, column 13: PL/SQL: ORA-00913: too many values ORA-06550: line 2, column 1: PL/SQL: SQL Statement ignored.
    My Process code is as follows:
    IF ( :P6_DOC_UPLOADED is not null ) THEN
    INSERT INTO APEX_AM_LEASES(id, CLIENT_REF, CLIENT_NAME, PROPERTY_REF, PROPERTY_NAME, TENANT_REF, TENANT_NAME, DOC_TYPE_NO, DOC_TYPE, URL, BLOB_CONTENT, MIME_TYPE)
    SELECT ID,:P6_DOC_UPLOADED,:P6_CLIENT_REF, :P6_CLIENT_NAME, :P6_PROPERTY_REF, :P6_PROPERTY_NAME, :P6_TENANT_REF, :P6_TENANT_NAME, :P6_DOC_TYPE_NO, :P6_DOC_TYPE, :P6_URL, blob_content,mime_type
    FROM APEX_APPLICATION_FILES
    WHERE name = :P6_DOC_UPLOADED;
    DELETE from APEX_APPLICATION_FILES WHERE name = :P6_DOC_UPLOADED;
    END IF;

    Hi srikavi - thank you for your quick response. I think I get it however I have amended and am getting a new error:
    ORA-06550: line 2, column 163: PL/SQL: ORA-00904: "MIME_TYPE": invalid identifier ORA-06550: line 2, column 1: PL/SQL: SQL Statement ignored
    IF ( :P6_DOC_UPLOADED is not null ) THEN
    INSERT INTO APEX_AM_LEASES(DOC_UPLOADED, CLIENT_REF, CLIENT_NAME, PROPERTY_REF, PROPERTY_NAME, TENANT_REF, TENANT_NAME, DOC_TYPE_NO, DOC_TYPE, URL, BLOB_CONTENT, MIME_TYPE)
    SELECT :P6_DOC_UPLOADED, :P6_CLIENT_REF, :P6_CLIENT_NAME, :P6_PROPERTY_REF, :P6_PROPERTY_NAME, :P6_TENANT_REF, :P6_TENANT_NAME, :P6_DOC_TYPE_NO, :P6_DOC_TYPE, :P6_URL, blob_content, mime_type
    FROM APEX_APPLICATION_FILES
    WHERE name = :P6_DOC_UPLOADED;
    DELETE from APEX_APPLICATION_FILES WHERE name = :P6_DOC_UPLOADED;
    END IF;

  • Load .bmp file into BLOB column in 9i - how to?

    Hello all,
    How do I update a table with a BLOB column with a .bmp file in 9i? I tried using the DBMS_LOB package but got a ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275 (and since there is more native support in 9i, I'm not sure I need it to begin with). We do not have Inter-Media. tia [email protected]

    Hi,
    please, search a bit on the forum before do a question:
    Just searching by "upload blob pdf" ...
    How to batch upload PDF files into database BLOB
    Regards,
    Jose.

  • How to insert signals into multiple columns in db, dbtoolset

    I have  a labVIEW program that is currenly simulating voltage and a current signal using the DAQ Assistant. I'm using the database connectivity toolset. I am currently able to insert one signal into the database converted to a float(I can insert both into the same column as bianary but it needs to be stored as a usable format and in seperate columns.)
    The problem I am having is at the DB Tools Insert Data block. I have the connection, dbTable, error code, and create table boolean being passed into it. Where I am a little lost is how to set the columns I want to store the multiple signals into.
    If someone could break that part down for me that would be great. In short, I want to store voltage(channel0) and current(channel1) from the DAQ Assistant into their own respective columns in the db.

    As I have often pointed out, the easiest solution to this situation is to dump the Database Connectivity Toolkit. Check out this thread and follow the references in it. If the DCT weren't in the way what you are wanting to do would be very easy.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Getting row count of file into table column

    Hi experts,
    I want to insert the row count of the file into a table column for generating a summary file containing the detials of all the files generated for the day along with the row count and also for audit purpose.
    My design is to create table in the summary file format & update the data's in it then using OdiSqlUnload to generate the required summary file, for this purpose I need to insert the row count of the file generated.
    I tried to get the row count using the http://odiexperts.com/get-file-length-and-header-in-operator post. But passing the "lines" value into a ODI variable or inserting into a table column is not working.
    Please help or suggest what can be done to achive the above scenario.
    Thanks in advance.

    There are a few excellent examples at :- COUNT
    Cheers
    John
    http://john-goodwin.blogspot.com/

Maybe you are looking for

  • How can I transfer a docx calendar to my iPhone calendar

    I just received a word document calendar that I would like to transfer into my iPhone's calendar. Could anyone help with this process

  • Pass parameter from Portlet to Form?

    Hi Frineds I created a plsql portlet in which i am displaying a combo box with the list of client id's I created a Form from locally built Provider which got a client ID as one of the column. My question is. If the user selects client id from combobo

  • IDoc Basic Type needed for FI & CO posting with local & document currency

    Hi All, I am using basic type  u201CFIDCCP02u201D which has local and document currency separately and posts to FI and CO segments but without any validations. This results in erroneous entries like posting to a cost center that cost center is not li

  • Accessing Computer over Internet?

    I'm wondering if its possible to access my computer from the internet when I'm not at home. I know if my computers on a local network one can access it, but is there a way to do a similar thing from the internet? I have my mac mini at home connected

  • Locaton & Security (My Location) Settings Grayed Out

    I recently added Where'sMyDroid from the marketplace (helps locate missing phone, gives GPS location of lost phone).  After that, my GPS stopped working.  Using the Android Power widget, I was able to turn it back on but when I go to Location & Secur