Blob conversion

Hello folks !!!
I am requesting for your valuable help , in order to solve the following
I have been requested to issue an invoice followed by a letter of credit ...
I currently have two concurrent programs, one for the invoice and the other one
for the letter of credit. Both concurrents are fired up by one parent concurrent program
The concurrent program for the invoice has no errors, it is all good.
The stored procedure that is contained within the definition of this concurrent
saves the XML in a BLOB column.
Then the stored procedure defined for the concurrent program of the letter of credit
tries to retrieve the info stored in that BLOB column, in order to write it
to the ERP applications output, so it tries to convert the BLOB in a varchar2, but it does not work.
I mean it only works like 50 % of the time.
Whenever it has an error , it is always ora-06502: numeric or value error.
I said that a parent concurrent program fires up both concurrents for the invoice and for the letter of credit (LOC).
You'd say something's wrong with that concurrent for the LOC. But every time I ONLY run this concurrent program
separated from the other it works fine.
Technical data
I am using right now
Oracle Applications 11.5.10.2
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
PL/SQL Release 10.2.0.3.0 - Production
XML Publisher version I believed is 5.5 I'll confirm later.
Please any help or advice is greatly appreciated.

All right I have solved this a while ago, but forgot to post the solution :p
My mistake was to execute one concurrent right after the first one, no delay in between.
Therefore information needed in the second concurrent still was not available as the first concurrent was not done yet.
All I do was to put a wait_request statement in between.
My bad , feel dissapointed :( . I'm still learning :P

Similar Messages

  • BLOB-- CLOB-- BLOB conversion reducing length of BLOB

    Hi,
    I am using the following BLOB-->CLOB and CLOB-->BLOB conversion functions :
    CREATE OR REPLACE FUNCTION blob_to_clob (blob_in IN BLOB)
    RETURN CLOB
    AS
         v_clob CLOB;
         v_varchar RAW(32001);
         v_varchar1 VARCHAR2(32001);
         v_start     INTEGER := 1;
         v_buffer INTEGER := 32001;
    BEGIN
         DBMS_LOB.CREATETEMPORARY(v_clob, TRUE);
         FOR i IN 1..CEIL(DBMS_LOB.GETLENGTH(blob_in) / v_buffer)
         LOOP
         DBMS_LOB.READ(blob_in,v_buffer,v_start,v_varchar);
    DBMS_LOB.WRITEAPPEND(v_clob, utl_raw.length(v_varchar), v_varchar);
         v_start := v_start + v_buffer;
         END LOOP;
    RETURN v_clob;
    END blob_to_clob;
    CREATE OR REPLACE FUNCTION clob_to_blob (clob_in IN CLOB)
    RETURN BLOB
    AS
         v_blob BLOB;
         v_varchar RAW(32001);
         v_varchar1 RAW(32001);
         v_start     INTEGER := 1;
         v_buffer INTEGER := 32001;
    BEGIN
         DBMS_LOB.CREATETEMPORARY(v_blob, TRUE);
         FOR i IN 1..CEIL(DBMS_LOB.GETLENGTH(clob_in) / v_buffer)
         LOOP
         DBMS_LOB.READ(clob_in,v_buffer,v_start,v_varchar);
    DBMS_LOB.WRITEAPPEND(v_blob, utl_raw.length(v_varchar), v_varchar);
              v_start := v_start + v_buffer;
         END LOOP;
    RETURN v_blob;
    END clob_to_blob;
    I am using these functions to convert image files, stored as BLOB to CLOB for intermediate storage, and then converting them back to BLOB. In this process, I see a loss of information when the image is converted from CLOB to BLOB ...which is seen by using dbms_lob.getlength() .Using the following sql query:
    select dbms_lob.getlength(file_body),
    dbms_lob.getlength(blob_to_clob(file_body)),
         dbms_lob.getlength(clob_to_blob(blob_to_clob(file_body)))
    from my_table where image_id in (8819)
    i see that returned length is usually half in the 3rd column, i.e. for dbms_lob.getlength(clob_to_blob(blob_to_clob(file_body))). There is no change in length for 1st and 2nd columns. Could you please let me know why length is getting lost in the CLOB to BLOB conversion ? Thanks.

    Thanks for replying.
    This is required because we have to store images in ldt files using FNDLOAD, whiich only supports CLOB, not BLOB. I understand that images stored in binary formats should be stored in BLOB only, but I am exploring the possibility of converting BLOB format to CLOB and then back to BLOB without loss of information. Any pointers in this regard are appreciated. Thanks !

  • How to call CLOB to BLOB conversion function within stored procedure?

    I have a tiny APEX application from which I need to be able to print. I’ve used these two resources: (Is there an inexpensive APEX report printer for invoices/checks/statements? and http://download.oracle.com/docs/cd/E14373_01/appdev.32/e13363/up_dn_files.htm#CJAHDJDA)
    I guess that in order to be able to download the RTF document stored in CLOB, I need to convert it into BLOB. I’ve found this function for this purpose on Oracle forums:
    CREATE OR REPLACE FUNCTION     c2b( c IN CLOB ) RETURN BLOB
    -- typecasts CLOB to BLOB (binary conversion)
    IS
              pos PLS_INTEGER := 1;
              buffer RAW( 32767 );
              res BLOB;
              lob_len PLS_INTEGER := DBMS_LOB.getLength( c );
    BEGIN
         DBMS_LOB.createTemporary( res, TRUE );
         DBMS_LOB.OPEN( res, DBMS_LOB.LOB_ReadWrite );
    LOOP
         buffer := UTL_RAW.cast_to_raw( DBMS_LOB.SUBSTR( c, 16000, pos ) );
         IF          UTL_RAW.LENGTH( buffer ) > 0
         THEN
                   DBMS_LOB.writeAppend( res, UTL_RAW.LENGTH( buffer ), buffer );
         END IF;
         pos := pos + 16000;
         EXIT WHEN pos > lob_len;
    END LOOP;
    RETURN res; -- res is OPEN here
    END c2b;And I am trying to use it in the modified download procedure that I also have found on Oracle forums:
    CREATE OR REPLACE PROCEDURE DOWNLOAD_WO(v_id IN NUMBER)
    AS
            v_mime          VARCHAR2(48);
            v_length     NUMBER;
            v_file_name     VARCHAR2(2000):= 'WO_Download.rtf';
            lob_loc          CLOB;
              v_blob      BLOB;
              v_company        jobs_vw.company%TYPE;
              v_project        jobs_vw.project%TYPE;
              v_description     jobs_vw.description%TYPE;
              v_date_          jobs_vw.date_%TYPE;
              v_job_no          jobs_vw.job_no%TYPE;
              v_apqwo               jobs_vw.apqwo%TYPE;
    --          v_mime           VARCHAR2(48) := 'application/msword';
    BEGIN
            SELECT     mime_type, report, DBMS_LOB.GETLENGTH(report)
              INTO     v_mime,lob_loc,v_length
              FROM     report_layouts
              WHERE     rl_id = 22332925279634283;
    -- JOB_VW record:
        SELECT     job_no
                   ,date_
                   ,description
                   ,apqwo
                   ,project
                   ,company       
         INTO     v_job_no
                   ,v_date_
                   ,v_description
                   ,v_apqwo
                   ,v_project
                   ,v_company
         FROM     jobs_vw
         WHERE     id = 214;
    -- Replace holders with actual values:
        lob_loc := REPLACE(lob_loc, '#COMPANY#', v_company);
        lob_loc := REPLACE(lob_loc, '#PROJECT#', v_project);
        lob_loc := REPLACE(lob_loc, '#DESCRIPTION#', v_description);
        lob_loc := REPLACE(lob_loc, '#DATE_#', TO_CHAR(v_date_, 'DD/MM/YYYY'));
        lob_loc := REPLACE(lob_loc, '#JOB_NO#', v_job_no);
        lob_loc := REPLACE(lob_loc, '#APQWO#', v_apqwo);
                  -- set up HTTP header
                        -- use an NVL around the mime type and
                        -- if it is a null set it to application/octect
                        -- application/octect may launch a download window from windows
                        owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
                    -- set the size so the browser knows how much to download
                    htp.p('Content-length: ' || v_length);
                    -- the filename will be used by the browser if the users does a save as
                    htp.p('Content-Disposition:  attachment; filename="'||replace(replace(substr(v_file_name,instr(v_file_name,'/')+1),chr(10),null),chr(13),null)|| '"');
                    -- close the headers           
                    owa_util.http_header_close;
                    -- download the BLOB
    --                wpg_docload.download_file( Lob_loc );
                             v_blob := c2b(lob_loc);
                             wpg_docload.download_file( v_blob );
    end DOWNLOAD_WO;
    /Unfortunately when I try to compile the download_wo stored procedure I am getting this error:
    Error at line 64: PL/SQL: Statement ignoredThe 64th line is:
    v_blob := c2b(lob_loc);How should I correctly call c2b within download_wo? Any advice is greatly appreciated.
    Thank you for your time.
    Daniel

    Hello there,
    Well, its invalid :(
    Object C2B is Invalid. I didn't know since when I run the create ... function, I only get this feedback:
    Statement processed.
    0.19 secondsI am investigating.
    Daniel

  • CLOB to BLOB conversion to save space

    Hi Gurus,
    I am having a table with a CLOB column which I am asked to convert into BLOB and in the process save some space. But I am finding even after the conversion, it is taking same amount of space as the previous CLOB column.
    Is there any way I can convert it to BLOB and/or save space in any way.
    Please let me know if there are any ways.
    Thanks
    Amitava.

    select * from v$version; -- it needs to be 11g+ Enterprise Edition;
    select * from v$option where parameter='Advanced Compression';
    But the best way, ask.  (on a piece of paper that requires a signature.)
    MK

  • String to Blob conversion

    ALL I want to do is update a BLOB field in a DB2 database with a string. The field is updating but I'm getting garbage. Here's the code I'm using to test. What am I doing wrong? The GDTXFT is the BLOB field.
       Connection c = DriverManager.getConnection("jdbc:db2://DEV550");
       PreparedStatement ps =c.prepareStatement("UPDATE PRODDTA.F00165 SET GDTXFT = ? WHERE GDOBNM = 'GT4311' AND GDTXKY = '72455|00005|OR|000|1.000'");
       String s="Is anyone out there?";
       ps.setBytes(1, s.getBytes());
       ps.executeUpdate();

    You normally do the following steps:
    SELECT FOR UPDATE on the BLOB column
    Use getBlob() to fetch the BLOB (you may need to cast it to a DB2-specific BLOB in your JDBC driver)
    Get a reference to the BLOB's InputStream
    Write data to the stream
    Commit- Saish

  • Need Your advice on CLOB TO BLOB conversion.

    HI
    Edited by: 982229 on Jan 18, 2013 12:34 AM

    982229 wrote:
    Need you urgent help here.This is not a place for urgent help. Using the community discussion forums for urgent issues is a violation of the terms and conditions.
    http://www.oracle.com/html/terms.html
    >
    4. Use of Community Services
    Community Services are provided as a convenience to users and Oracle is not obligated to provide any technical support for, or participate in, Community Services. While Community Services may include information regarding Oracle products and services, including information from Oracle employees, they are not an official customer support channel for Oracle.
    You may use Community Services subject to the following: (a) Community Services may be used solely for your personal, informational, noncommercial purposes; (b) Content provided on or through Community Services may not be redistributed; and (c) personal data about other users may not be stored or collected except where expressly authorized by Oracle
    >
    Anything that is solely for your personal, informational, noncommercial purposes is not urgent.
    Please log a service request with support or hire a qualified consultant for urgent issues.
    http://www.google.com/search?q=oracle+consultant

  • Conversion of BLOB datatype to CLOB datatype

    Hi,
    I would need to convert the column datatype from BLOB to CLOB. currently in the table, the BLOB column has the data. the requirement is to convert this column from BLOB to CLOB datatype.
    please help me how to convert from BLOB datatype to CLOB datatype
    Thanks
    Hari.

    I have just been dealing with the same issue -- mass conversion of data in BLOB form to CLOB. I think I've finally got it working well. I have a table that has an key column then both a BLOB and a CLOB column. I load the BLOBS into the table then run the following PLSQL block (uses the given proc) to transfer the data from the BLOB column to the CLOB column.
    -- Proc to convert BLOB to CLOB
    create or replace function stg.blob_to_clob( p_blb in blob )  return clob  is
       v_clb   clob    ;
       v_dst   integer := 1 ;
       v_src   integer := 1 ;
       v_wrn   integer ;
       v_lng   integer := dbms_lob.default_lang_ctx ;
    begin
       dbms_lob.createtemporary ( v_clb, false ) ;
       dbms_lob.converttoclob
         ( dest_lob      =>  v_clb
         , src_blob      =>  p_blb
         , amount        =>  dbms_lob.lobmaxsize
         , dest_offset   =>  v_dst
         , src_offset    =>  v_src
         , blob_csid     =>  dbms_lob.default_csid
         , lang_context  =>  v_lng
         , warning       =>  v_wrn
       if  ( dbms_lob.NO_WARNING != v_wrn )  then
          v_clb := '~~~{ Error: Invalid Character in source BLOB }~~~' ;
       end if ;
       return v_clb ;     
    exception
       when others then
          v_clb := '~~~{ Error: BLOB Conversion Function Failed }~~~' ;
          return v_clb ;
    end ;
    -- Use the proc above to convert each BLOB to a CLOB in the given table.
    declare
       cursor c1 is
          /* Select the BLOBS to be converted. */
          select  id,  m_blob,  m_clob
            from  stg.temp_cnvrt
                  /* Trying to convert NULL BLOBS will result in an error */
           where  dbms_lob.getlength(m_blob) > 0
          for update ;
       v_tmp_clob   clob ;
    begin
       FOR  nxt in c1  LOOP
          v_tmp_clob := stg.blob_to_clob( nxt.m_blob ) ;
          update  stg.temp_cnvrt
             set  m_clob = v_tmp_clob
           where  current of c1 ;  
       END LOOP ;
       commit ;
    end ;

  • LONG RAW to CLOB Conversion

    I wish to migrate records of a col. FILETYPE (LONG RAW) of existing table to col. DOCTYPE (CLOB) of a new table.
    But the function to_lob() is unable to carry out the required migration. The Error message is : " Inconsistent Data Types expected - binary .... ".
    Moreover LONG RAW to BLOB conversion works fine from a simple INSERT statement but the same fails when insertion is done using a CURSOR.
    Can u guyz help me in doing the same !
    Oracle Version used - 9i
    Regards,
    Chinmay <Infocker>

    You can transfer data from
    LONG to CLOB
    LONG RAW to BLOB only..
    In Oracle9i -- there is a very cool "alter table t modify long_col CLOB" to do
    this as well....
    you could convert a clob to a blob, or a blob to a clob using utl_raw.cast_to_varchar2/raw and doing it 32k at a time.

  • DB Adapter - DB2/JD Edwards Graphic Datatype Error

    Hello,
    I am not sure which forum I should post this question to. If there is another forum, please let me know.
    I am running into an issue with using the DB Adapter to insert into a DB2 database hosted on an AS/400. The column I am attempting to insert into is a graphic datatype which contains character data. The table is a JD Edwards table where character data is stored in graphic columns.
    My development environment consists of the following:
    J Developer 11.1.1.5
    SOA Suite 11.1.1.5
    DB2/400 Version 6, release 1
    JDBC Driver - IBM JT400.jar
    WebLogic 10.3.5
    When I run the composite application in WebLogic, the process faults at the insert statement (error messages are posted below). When I look at my or-mappings.xml file I find the following mapping for the column causing the error:
    <attribute-mapping xsi:type="direct-mapping">
    <attribute-name>absic</attribute-name>
    <field table="F0101" name="ABSIC" xsi:type="column"/>
    <attribute-classification>[B</attribute-classification>
    </attribute-mapping>
    The attribute-classification seems incorrect. In J Developer 10, the attribute-classification was java.lang.String. When I manually change this attribute to java.lang.String, the application works correctly. This same error happens on all graphic datatype columns. At the top of the or-mappings.xml file, there is a reference to eclipselink. In J Developer 10, I think there was a reference to Toplink vs Eclipselink. So it appears that J Developer is now using EclipseLink by default to create the or-mappings.xml file.
    I would rather not have to change the attribute-classification each time I want to create an insert statement. Is there a way to fix/configure how J Developer/EclipseLink creates this mapping? Is it safe to manually edit the or-mappings.xml file?
    Thanks in advance.
    The error messages I receive are:
    <bpelFault><faultType>0</faultType><bindingFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="summary"><summary>Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'insert' failed due to: DBWriteInteractionSpec Execute Failed Exception. insert failed. Descriptor name: [F0101.F0101]. Caused by Exception [EclipseLink-3001] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.ConversionException Exception Description: The object [xs:base64Binary SR Test Case - Vince], of class [class java.lang.String], could not be converted to [class java.sql.Timestamp]. Internal Exception: java.io.IOException: Error in encoded stream: needed 4 valid base64 characters but only got 3 before EOF, the 10 most recent characters were: "se - Vince". Please see the logs for the full DBAdapter logging output prior to this exception. ConnectionFactory property platformClassName was set to org.eclipse.persistence.platform.database.oracle.Oracle10Platform but the database you are connecting to is DB2 UDB for AS/400. Please validate your platformClassName setting. This mismatch can cause the adapter to trigger runtime exceptions or execute SQL that is invalid for the database you are connected to. This exception is considered not retriable, likely due to a modelling mistake. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. </summary></part><part name="detail"><detail> Exception Description: The object [xs:base64Binary SR Test Case - Vince], of class [class java.lang.String], could not be converted to [class java.sql.Timestamp]. Internal Exception: java.io.IOException: Error in encoded stream: needed 4 valid base64 characters but only got 3 before EOF, the 10 most recent characters were: "se - Vince"</detail></part><part name="code"><code>null</code></part></bindingFault></bpelFault>
    Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'insert' failed due to: DBWriteInteractionSpec Execute Failed Exception. insert failed. Descriptor name: [F0101.F0101]. Caused by Exception [EclipseLink-3001] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.ConversionException Exception Description: The object [xs:base64Binary SR Test Case - Vince], of class [class java.lang.String], could not be converted to [class java.sql.Timestamp]. Internal Exception: java.io.IOException: Error in encoded stream: needed 4 valid base64 characters but only got 3 before EOF, the 10 most recent characters were: "se - Vince". Please see the logs for the full DBAdapter logging output prior to this exception. ConnectionFactory property platformClassName was set to org.eclipse.persistence.platform.database.oracle.Oracle10Platform but the database you are connecting to is DB2 UDB for AS/400. Please validate your platformClassName setting. This mismatch can cause the adapter to trigger runtime exceptions or execute SQL that is invalid for the database you are connected to. This exception is considered not retriable, likely due to a modelling mistake. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.

    Just as an FYI for anyone else running into this problem - we have had an SR open with Oracle Support for a while on this and they are working on the issue.
    The problem is essentially this:
    JDE Oneworld running on iSeries/DB2 utilized CCSID 65535 GRAPHIC data types behind the scenes to handle storage of unicode information in EBCDIC. The JDBC driver handles this conversion for you, returning unicode data as long as you include the "translate binary=true" clause in the JDBC connection string. The driver returns string/nchar data for these CCSID 65535 GRAPHIC fields - they are not returned to the client as binary/clobs.
    SOA Suite 10.1.3.4.0 used "Oracle Toplink - 10g Release 3" for object persistence and mappings. In 11g, this was swapped out to use "Eclipse Persistence Services 2.x.x" for the object persistence and mappings. The original Toplink had a default behavior, that if it did not understand the type of the field, it would assume that the driver was handling it and would assume it was a string value, ie it would map it as xs:string and NCHAR. So one could argue (and Oracle support did...) that it was a bug that this ever worked in 10g/OAS. However it was a bug that worked out favorably. Eclipse Persistence Services did not have this bug, and whenever the developers see a GRAPHIC db data type, they assume that the information being returned to the client by the JDBC driver is in xs:base64Binary format.
    Bottom line if you do a simple hello world java project to use the jdbc driver and return the value, and examine that in hex, it is returning straight string values, not xs:base64Binary format stuff that need blob conversion code run.
    The good news is that Oracle has come up with a solution and is working on a patch for Oracle SOA 11.1.1.6.
    As a side note - Vince came up with a temporary workaround to get this working, which involves changing the three generated mappings/schema files manually to update the types, and per a suggestion from a very helpful Oracle technical Sales resource (Mike Loos) was working on an ant script to automate that process.
    If you need any more details, post and let us know. Vince or I will update this message when the patch is available.
    Jim

  • XML data from BLOB to CLOB - character set conversion

    Hi All,
    I'm trying to solve a problem with a character set conversion in PL/SQL in the following scenario:
    1. source is an XML as a BLOB variable.
    2. target is an XML as a CLOB variable.
    3. the problem I have is the following:
    - database character set is set to UTF-8
    - XML character set could be anything (UTF-8, ISO 8859-1, ISO 8859-2, ASCII, ...)
    - I need to write a procedure which converts the source BLOB content into the target CLOB taking into account the XML encoding and converts it into the DB default character set (UTF8).
    I've been able to implement a simple conversion function. However, this function expects static XML encoding ISO-8859-1. The main part of the function looks as follows:
    buffer := UTL_RAW.cast_to_varchar2(
    UTL_RAW.convert(
    DBMS_LOB.SUBSTR(source_blob_variable, 16000, pos)
    , 'American_America.UTF8'
    , 'American_America.we8iso8859p1')
    Does anyone have an idea how to rewrite the code to handle "any" XML encoding in the source BLOB file? In other words, is there a function in Oracle which converts XML character set names into Oracle character set values (ISO-8859-1 to we8iso8859p1, UTF-8 to UTF8, ...)?
    Thanks a lot for any help.
    Julius

    I want to pass a BLOB to some "createXML" procedure and get a proper XMLType in UTF8 character set, properly converted from whatever character set is the input in.As per documentation the generated XML has always the encoding set at the client side depending on NLS_LANG (default UTF-8), regardless of the input encoding, so I don't see a need to parse the PI of the XML:
    C:\>echo %NLS_LANG%
    %NLS_LANG%
    C:\>sqlplus
    SQL*Plus: Release 11.1.0.6.0 - Production on Wed Apr 30 08:54:12 2008
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> var cur refcursor
    SQL>
    SQL> declare
      2     b   blob := utl_raw.cast_to_raw ('<a>myxml</a>');
      3  begin
      4     open :cur for select xmlroot (xmltype (utl_raw.cast_to_varchar2 (b))) xml from dual;
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> print cur
    XML
    <?xml version="1.0" encoding="UTF-8"?><a>myxml</a>
    SQL> exit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    C:\>set NLS_LANG=GERMAN_GERMANY.WE8ISO8859P1
    C:\>sqlplus
    SQL*Plus: Release 11.1.0.6.0 - Production on Mi Apr 30 08:55:02 2008
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    SQL> var cur refcursor
    SQL>
    SQL> declare
      2     b   blob := utl_raw.cast_to_raw ('<a>myxml</a>');
      3  begin
      4     open :cur for select xmlroot (xmltype (utl_raw.cast_to_varchar2 (b))) xml from dual;
      5  end;
      6  /
    PL/SQL-Prozedur erfolgreich abgeschlossen.
    SQL>
    SQL> print cur
    XML
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <a>myxml</a>

  • Conversion of string to BLOB format

    Hi,
    Scenario is proxy to JDBC:
    I have a requirement where my PFD file name is maintained in one ABAP R3 table and I need to convert the PDF file name to BLOB format.
    Is there any function module available in R3 for converting to BLOB data type. or java mapping is required in graphical mappping for this conversion.
    My pdf file name is:
    SHELL_INC_123456789012_851000000005290_DE_04_2008.pdf
    Thnx
    Chirag

    Hi Chirag,
    I don't think there is any FM in ABAP is written for this purpose. you should need to write an UDF. Also my concern is that "where is the PDF file located"? If the answer is "on a file system accessible to the Oracle database" Then you can use directory objects and the DBMS_LOB package. It would look something like this:
    as SYS user do:
    -- assume the PDF files are in /data/documents filesystem directory
    create or replace directory pdfdir as '/data/documents';
    grant read on directory pdfdir to <USER>;
    as USER do:
    create table mydocs (id integer primary key, doc blob);
    declare
    bf bfile;
    b blob;
    src_offset integer := 1;
    dest_offset integer := 1;
    begin
    ' insert a new blob and return it to local variable
    insert into mydocs values(1, empty_blob()) returning doc into b;
    ' open the bfile for file "summary.pdf"
    bf := bfilename('PDFDIR', 'summary.pdf');
    dbms_lob.loadBlobFromFile(b, bf, dbms_lob.lobmaxsize, dest_offset, src_offset);
    ' done
    commit;
    end;
    I assumed that you are working with 2 different machines, one client, one server.
    If you are working on a single machine, there may be a simple bug in the code.
    try adding the line
    dbms_lob.open(bf, dbms_lob.file_readonly);
    between the calls to bfilename() and loadBlobFromFile()
    Also if you want to do this using java then please have a look in this link.
    http://publib.boulder.ibm.com/infocenter/idshelp/v111/index.jsp?topic=/com.ibm.jccids.doc/com.ibm.db2.luw.apdv.java.doc/doc/cjvjdlbv.html
    Hopefully this will help you.
    Regards
    Aashish Sinha

  • ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion

    Hi all,
    the following query select to_char(nvl(round(pc.target_cost*xx_primavera.geteurtolvrate,2),amount),'FM999G999G999G999G990D00') detail_amount,
    nvl(ct.cost_type, description) detail_description,
    tm_desc.memo_id,
    primavera_prj_name detail_prj_name,
    hp.party_number detail_party_number,
    xpid.interface_line_attribute1,
    utl_i18n.unescape_reference(replace(regexp_replace(utl_raw.cast_to_varchar2(tm_desc.task_memo), '<[^>]*>'), chr(13)||chr(10))) document_description,
    REPLACE(regexp_replace(utl_raw.cast_to_varchar2(tm_id.task_memo), '<[^>]*>'), chr(13)||chr(10)) prim_memo_client_id
    from XX_PRIMAVERA_INVOICES_DETAIL xpid
    join admuser.xx_ar_hz_parties xahp on xahp.orig_system_bill_customer_id = xpid.orig_system_bill_customer_id
    join hz_parties hp on hp.party_id = xahp.party_id
    left join admuser.projcost pc on pc.proj_id = xpid.primavera_prj_id and pc.cost_type_id != 29 and xpid.service_code = 8 and pc.task_id = xx_primavera.getTaskId(xpid.primavera_prj_id,'A1020', 'Изготвяне на оферта') and delete_session_id is null
    left join admuser.costtype ct on ct.cost_type_id = pc.cost_type_id
    left join admuser.taskmemo tm_id on tm_id.proj_id = xpid.primavera_prj_id and tm_id.memo_type_id = 53 and tm_id.task_id = xx_primavera.getTaskId(xpid.primavera_prj_id,'A1020', 'Изготвяне на оферта')
    left join admuser.taskmemo tm_desc on tm_desc.proj_id = xpid.primavera_prj_id and tm_desc.memo_type_id = 55 and tm_desc.task_id = xx_primavera.getTaskId(xpid.primavera_prj_id,'A1020', 'Изготвяне на оферта')
    where amount != 0
      and xpid.interface_line_attribute1 = :ra_ctp_attribute1
    ORDER BY xpid.primavera_prj_name, xpid.description;returns error:
    ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 2371, maximum: 2000) I found that the error occurs in the row : utl_i18n.unescape_reference(replace(regexp_replace(utl_raw.cast_to_varchar2(tm_desc.task_memo), '<[^>]*>'), chr(13)||chr(10))) document_description,and tried to change it to: utl_i18n.unescape_reference(replace(regexp_replace(utl_raw.cast_to_varchar2(dbms_lob.substr(tm_desc.task_memo,1,2000)), '<[^>]*>'), chr(13)||chr(10))) document_description,....but it returns not value for that field... am i using dbms_lob.substr at the wrong place? The column 'tm_desc.task_memo' is BLOB type.
    Any ideas how to cheat it ?
    Version: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    "CORE     11.1.0.7.0     Production"
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - ProductionThanks in advance,
    Bahchevanov.

    Your second example has the parameters reversed. The amount (length) comes first and then the offset:
    DBMS_LOB.SUBSTR (
       lob_loc     IN    BLOB,
       amount      IN    INTEGER := 32767,
       offset      IN    INTEGER := 1)
      RETURN RAW;
    DBMS_LOB.SUBSTR (
       lob_loc     IN    CLOB   CHARACTER SET ANY_CS,
       amount      IN    INTEGER := 32767,
       offset      IN    INTEGER := 1)
      RETURN VARCHAR2 CHARACTER SET lob_loc%CHARSET;
    DBMS_LOB.SUBSTR (
       file_loc     IN    BFILE,
       amount      IN    INTEGER := 32767,
       offset      IN    INTEGER := 1)
      RETURN RAW;Also, remember that # of bytes is not necessarily the same as the # of characters depending on your character set. So 2000 bytes might become 4000 characters. And you have to make sure the BLOB is actually character data and not arbitrary binary data.
    Post the results of reversing the parameters and using a smaller chunk size.

  • BLOB to CLOB conversion

    hi all,
    i have a table have 2 clounms in my DB (10.2.0.4) one colunm is varchar2 and other one was blob. as per requested from developer team, i changed it from blob to clob. after this conversion, object size is increased from 11mb to 39mb. my point is is it expected behavior ?????? if yes ! can any one pl. explain it.
    regards,

    CREATE TABLE TABLE_CLOB
    RECID VARCHAR2(255 BYTE),
    XMLRECORD SYS.XMLTYPE
    TABLESPACE DATATABLESPACE
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    LOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING
    ENABLE ROW MOVEMENT;
    CREATE UNIQUE INDEX TABLE_CLOB_PK ON TABLE_CLOB
    (RECID)
    LOGGING
    TABLESPACE INDEXTABLESPACE
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    NOPARALLEL;
    ALTER TABLE TABLE_CLOB ADD (
    CONSTRAINT TABLE_CLOB_PK
    PRIMARY KEY
    (RECID)
    USING INDEX
    TABLESPACE INDEXTABLESPACE
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    PCTINCREASE 0
    ));

  • 6i to 9i conversion OLE container stored in a LONG RAW column to BLOB

    I need to automate the migration of data stored in a long raw column to a blob column. The objects were stored in the long raw column using an Oracle Forms 6i OLE container. There is also multiple object types stored in the column, ie (word, excel, images, but mostly pdf's). I have looked at the webutil package but cannot figure out how to read the long raw column since ole containers are obsolete in 9i. I have a lot of records that need migrating and need help.
    Thanks,
    J. Broome
    [email protected]

    It doesn't appear that I am able to attach the PDF files.  Can you supply your email (or I can supply mine) so I can send you the three files:
    1.)  A good PDF (manually extracted from our old application)
    2.)  Dump of the same PDF file (includes header/footer info)
    3.)  A partially fixed PDF file (but some of the pictures / pages are cut off - specifically pages 3,5,9,10,12,14)
    The way that we have tried to fix the file (in example 3 above) is the following:
    a.)  Find the First Occurrence of "%PDF-"
    b.)  Find the Last Occurrence of "%%EOF"
    c.)  if the first "%PDF-" is found AND the last "%%EOF" is found, then
       i.)  Remove all data before the first %PDF-
       ii.)  Remove all data after the last %%EOF
    Let me know if you need any other information.
    Thanks,
    Mike

  • Urgent regarding conversion of BLOB to Text

    Hi All
    Can anybody give me an idea of how to convert a medical bill which in BLOB format to a text format.
    Please mail me at [email protected]
    thanks in advance
    Ms.Srikanthan

    FUNCTION MODULES
    http://www.erpgenie.com/abap/functions.htm
    http://www.sapdevelopment.co.uk/fmodules/fmssap.htm
    http://www.erpgenie.com/abap/index.htm
    http://www.geocities.com/victorav15/sapr3/abapfun.html

Maybe you are looking for