Reg: UTL_URL.Unescape and CLOB -

Hi Experts,
I'm trying to un-escape the data of a table column using the package function - UTL_URL.Unescape
But the problem is my column is a CLOB and length of my data exceeds that acceptable by the function.
So, i'm just trying to simulate that function behavior normally.
My logic is to scan all characters with pattern '%yy' (HEX) and then convert it into DECIMAL using TO_CHAR(,'XX')
But got stuck in this regexp-replace.
Am I going correct...? Any help guys...??
with xx as(
    select '<p>%3Cp%3Ewefwef%3C/p%3E</p>' col from dual
select
    UTL_URL.unescape(col) x1,
    regexp_replace(col,'%([a-zA-Z0-9]){2}','\2|.') x2
from
    xx;gives
<p><p>wefwef</p></p>     
<p>|.p|.wefwef|./p|.</p>my database:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE     11.2.0.2.0     Production
TNS for Solaris: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - ProductionThanks,
Ranit B.

ranit B wrote:
But can't we do it this way that we'll just replace the '%yy' (HEX) characters from the string into DEC using TO_CHAR(?,'XX')
You can use this:
Example "how to convert % hex hex into ASCII char":
╔═══════╤══════╤══════╗
║ char  │ Dec  │ Hex  ║
╠═══════╪══════╪══════╣
║ @     │ 64   │ 40   ║
╟───────┼──────┼──────╢
║ n     │ 110  │ 6E   ║
╟───────┼──────┼──────╢
║ {     │ 123  │ 7B   ║
╟───────┼──────┼──────╢
║ space │ 32   │ 20   ║
╟───────┼──────┼──────╢
║ <     │ 60   │ 3C   ║
╚═══════╧══════╧══════╝
with t as (
select '%40' hex from dual union all
select '%6E' from dual union all
select '%7B' from dual union all
select '%20' from dual union all
select '%3C' from dual)
select chr(to_number(ltrim(t.hex,'%'),'xx')) out from t;
        OUT
1     @
2     n
3     {
4     "space"
5     <Edited by: stefan nebesnak on Feb 8, 2013 3:49 PM

Similar Messages

  • BLOB and CLOB data in BI Publisher

    Hello,
    I have an XML file with blob and clob data in it. I am using BI desktop publisher to load the xml file and create the rtf template. I am getting the following error:
    ConfFile: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\config\xdoconfig.xml
    Font Dir: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\fonts
    Run XDO Start
    Template: C:\work\employee.rtf
    RTFProcessor setLocale: en-us
    FOProcessor setData: C:\work\employee.xml
    FOProcessor setLocale: en-us
    Do i need to install anything or am i missing any configuration to read the blob and clob? Please advise
    thanks

    Check this out, hopefully it'll help you
    http://oraclebizint.wordpress.com/2007/11/12/oracle-bi-ee-101332-working-with-clob-fields/
    Fiston

  • How to copy a table with LONG and CLOB datatype over a dblink?

    Hi All,
    I need to copy a table from an external database into a local one. Note that this table has both LONG and CLOB datatypes included.
    I have taken 2 approaches to do this:
    1. Use the CREATE TABLE AS....
    SQL> create table XXXX_TEST as select * from XXXX_INDV_DOCS@ext_db;
    create table XXXX_TEST as select * from XXXX_INDV_DOCS@ext_db
    ERROR at line 1:
    ORA-00997: illegal use of LONG datatype
    2. After reading some threads I tried to use the COPY command:
    SQL> COPY FROM xxxx/pass@ext_db TO xxxx/pass@target_db REPLACE XXXX_INDV_DOCS USING SELECT * FROM XXXX_INDV_DOCS;
    Array fetch/bind size is 15. (arraysize is 15)
    Will commit when done. (copycommit is 0)
    Maximum long size is 80. (long is 80)
    CPY-0012: Datatype cannot be copied
    If my understanding is correct the 1st statement fails because there is a LONG datatype in XXXX_INDV_DOCS table and 2nd one fails because there is a CLOB datatype.
    Is there a way to copy the entire table (all columns including both LONG and CLOB) over a dblink?
    Would greatelly appriciate any workaround or ideas!
    Regards,
    Pawel.

    Hi Nicolas,
    There is a reason I am not using export/import:
    - I would like to have a one-script solution for this problem (meaning execute one script on one machine)
    - I am not able to make an SSH connection from the target DB to the local one (although the otherway it works fine) which means I cannot copy the dump file from target server to local one.
    - with export/import I need to have an SSH connection on the target DB in order to issue the exp command...
    Therefore, I am looking for a solution (or a workaround) which will work over a DBLINK.
    Regards,
    Pawel.

  • Display BLOB and CLOB on browser

    Hi All.
    I need to display contents of BLOBs and CLOBs on the browser. They can be any docFlavour eg. .jpg, .gif, .pdf, .doc etc
    Is there some standard way of doing this ???
    If any all possible I would rather not use swing class because of its footprint and its slow performance over the net.

    Hi !
    Just in case anyone read this and is willing to comment on it...
    I have one BLOB and one CLOB column in the same record.
    I have been able to stream documents into and out of the BLOB's incl. MS .doc Also I have been able to get the content from BLOB and write it to a target directory.
    However I am having odd problems with CLOB, a simple text file. My servlet attempts to read the CLOB and does create the output file in the target directory, but does not copy the content over. It also returns 0 for clobLength !?! Here is the stub-code :
    ResultSet clobRS = thisStmt.executeQuery (
    "SELECT ATextMsg " +
    "FROM ... " +
    "WHERE ... " );
    clobRS.next();
    CLOB thisCLOB = ((OracleResultSet) clobRS).getCLOB("ATextMsg");
    int chunkSize = thisClob.getChunkSize();
    System.out.println("chunkSize is " + chunkSize); // default us 8132...
    char [] textBuffer = new char[chunkSize];
    String targetFile = targetDir + "retrieved_" + fileName;
    File thisFile = new File(targetFile); // it does create an empty target file...
    // read content as ASCII (text) content...
    FileOutputStream thisFileOutputStream = new FileOutputStream(thisFile);
    OutputStreamWriter thisWriter = new OutputStreamWriter(thisFileOutputStream);
    BufferedWriter thisBufferedWriter = new BufferedWriter(thisWriter);
    // things go wrong here, returns length of 0, why ?!?
    long clobLength = thisClob.length();
    System.out.println("clobLength is " + clobLength);
    // flush to targetFile - but since clobLength=0, nothing gets copied over...
    for (position=1; position<=clobLength; position+=chunkSize)
    int charsRead = thisClob.getChars(position, chunkSize, textBuffer);
    thisBufferedWriter.write(testBuffer);
    Since the clobLength is 0, obviously it will not copy from the database CLOB to the file.
    Manually change the clobLength = 8132, recompile and run, then it copies some junk to the targetFile, certainly not the textual data in the CLOB itself.
    The BLOB is fine...
    Can someone comment on this please and if possible, give me a hint on where I might have gone wrong with a simple text file ???

  • Help required in handling of Oracle BLOB and CLOB in OC4J

    Hi,
    I am in a process of porting my application from Weblogic 6 to OC4J.
    I have problem while handling CLob and Blob's in oracle. Weblogic has
    classes defined to do the same. (weblogic.jdbc.common.OracleClob)
    Does any one know how I can achieve this.
    Thanks in advance.
    Regards,
    Moin

    We have an application running on OC4J accessing an Oracle 8.1.7 db, and have no problems using BLOBs and CLOBs. It is explained quite clearly in the Oracle documentation.
    If you require further assistance let me know :-)

  • Code for using thin client over connection pool to access blob and clob

    Hi,
    Currently I am running WL5.1SP12 with oracle thin client 8.1.7 to access blob
    and clob data. As the performance for concurrent users is very bad, I like to
    use the thin client over a connection pool to access the blob and clob instead.
    My question is whether this is possible and if so does anyone have a sample code?
    Thanks.
    This is urgent as the site has to roll out in 2 weeks..
    Rgd,
    Jason

    See http://e-docs.bea.com/wls/docs61/jdbc/thirdparty.html#1043705.
    "Jason" <[email protected]> wrote in message news:3eba851f$[email protected]..
    >
    Hi Stephen,
    Thanks for the reply. Can I confirm that what you are saying is that in release
    6.1 I am able to access blob/clob data via thin client over connection pool?
    Rgd.
    Jason
    "Stephen Felts" <[email protected]> wrote:
    Blob/clob support through the connection pool came in with release 6.1.
    "Jason" <[email protected]> wrote in message news:[email protected]..
    Hi,
    Currently I am running WL5.1SP12 with oracle thin client 8.1.7 to accessblob
    and clob data. As the performance for concurrent users is very bad,I like to
    use the thin client over a connection pool to access the blob and clobinstead.
    My question is whether this is possible and if so does anyone havea sample code?
    Thanks.
    This is urgent as the site has to roll out in 2 weeks..
    Rgd,
    Jason

  • APEX and CLOB value in trigger

    Hi,
    I am using APEX 3.2.1 with Oracle 11gR1.
    I have two tables:
    CREATE TABLE "TSI"."ATT_TEST2"
    (     "ID" NUMBER NOT NULL ENABLE,
         "TITLE" VARCHAR2(250 BYTE),
         "TOPIC" CLOB
    and
    CREATE TABLE "TSI"."ATT_TEST2"
    (     "ID" NUMBER NOT NULL ENABLE,
         "TITLE" VARCHAR2(250 BYTE),
         "TOPIC" CLOB
    My trigger is:
    create or replace TRIGGER "TSI"."ATT_TEST_TRG"
    BEFORE INSERT ON ATT_TEST
    FOR EACH ROW
    BEGIN
    SELECT ATT_TEST_SEQ.NEXTVAL INTO :new.ID FROM DUAL;
    insert into att_test2(id, title, topic) values (ATT_TEST_SEQ.NEXTVAL, :new.title, :new.topic);
    END;
    Now if I insert a record to ATT_TEST using SQL Developer ATT_TEST2 gets populated.
    If create an APEX form and try to insert into ATT_TEST i get all the fields inserted into ATT_TEST2 except for the CLOB column. The TOPIC column is not copied into ATT_TEST2.
    Any idea why this works from SQL Developer and not from APEX?
    Thank you

    Hello:
    I believe this behaviour is seen because APEX uses the 'DBMS_LOB' API to update LOB/CLOB columns.For the example posted APEX does something like
    INSERT INTO "ATT_TEST" ( "ID","TITLE","TOPIC") VALUES (:B1 ,REPLACE(:B2 ,'%null%',NULL),EMPTY_CLOB()) RETURNING ROWID INTO :0;
    begin select "TOPIC" into wwv_flow.g_dml_clob_text from "ATT_TEST" where rowid = :p_rowid for update; end;
    begin dbms_lob.write( wwv_flow.g_dml_clob_text, length(wwv_flow.g_dml_varchar32767_text), 1, wwv_flow.g_dml_varchar32767_text ); end;
    varad

  • Long and  clob datatype

    Hello Gurus
    we are working on oracle 8.1.4.0.in our database i have a table that contain a long column and a clob cloumn. i need backup of this table so that i can create the same table with data in other schema. Is there any recommmanded way. Can use copy or i need to use an export backup .
    thanks

    If possible, try to upgrade your long columns to lob. Working with long columns will severely limit the possibilities of adopting new features. It would have been easier to use the
    ALTER TABLE MOVE ... command.
    ~ Madrid
    http://hrivera99.blogspot.com/

  • $200 reward to solve problem with JDBC and CLOB.getCharacterOutputStream

    I'm trying to update CLOB with the getCharacterOutputStream as suggested in the example code. It works with US7ASCII DB instance but not instances in UTF8.
    I've been browsing through all the Oracle doc's and found some rather confusing statements:
    In the page at http://oradoc.photo.net/ora816/java.816/a81354/oralob2.htm#1043220
    it says: [When writing to or reading from a CLOB, the JDBC drivers perform all character set conversions for you.]
    also: [The oracle.sql.CLOB class supports all the character sets that the Oracle data server supports for CLOB types.]
    So far so good.
    In the page at http://oradoc.photo.net/ora816/java.816/a81354/oraint3.htm#1012518
    it says [The oracle.sql package supports these datatypes in several ways: CLOBs point to large fixed-width character data items (that is, characters that require a fixed number of bytes per character) and are supported by the oracle.sql.CLOB class.]
    Ooh no! Is this for real? UTF8 is variable width and does this mean it is not supported?
    Any way to get around this?
    In the page at http://oradoc.photo.net/ora816/java.816/a81358/03_pub2.htm#36009
    says [6.The mappings to oracle.sql classes are optimal because they preserve data formats and require no character-set conversions (apart from the usual network conversions). Those classes are especially useful in applications that "shovel" data between SQL and Java.]
    "No character set conversion"? Very confusing!
    I've been hammering on this CLOB/JDBC/UTF8 problem for more than a week now and I really appreciate some solutions, workarounds, or whatever help I can get. I'm running java stored procedure in 8.1.6 on Linux RH6.2.
    For your trouble, I'd pay $200 for the first guy who come up with a verifiable solution.

    This is just findings based upon your comments:
    Please refer to document Oracle8i National Language Support Guide
    Release 2 (8.1.6) from Oracle Documentation Library, Release 8.1.7
    Chapter 6 Java,
    There its clearly mention that:
    "Oracle JDBC drivers provide globalization support by allowing users to retrieve data from or insert data into a database in any character set that Oracle supports. Because Java strings are UCS2 encoded (16-bit Unicode) for JDBC programs, the target character set on the client is always UCS2. Character set conversion is required to convert data from the database character set (Db Charset) to UCS2. This applies to CHAR, LONG, CLOB, and VARCHAR2 data types; RAW data is not converted. "
    Also..please refer this...
    "oracle.sql.CLOB's method getCharacterStream() returns the contents of a CLOB as a Unicode stream."
    "The techniques that Oracle's drivers use to perform character set conversion for Java applications depend on the character set the database uses. The simplest case is where the database uses a US7ASCII or WE8ISO8859P1 character set. In this case, the driver converts the data directly from the database character set to UCS2,which is used in Java applications. "
    "If you are working with databases that employ a non-US7ASCII or non-WE8ISO8859P1 character set (for example, Japanese or Korean), then the driver converts the data, first to UTF8, then to UCS2. "
    In my case the characte-set of the database is WE8ISO8859P1 and for security reason i can't change the character set but my feeling is that if you are updating the CLob from the java client you are forming a reference of a clob in the client which is UCS2 at the Java side. Now when you are populating the clob through java.io.Writer and call the procedure to pass the reference of the clob to the procedure then I believe the JDBC will convert the UCS2 datatype of Clob to UTF8 in the database.
    You can try out the code snippet:
    package ServletGDC;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import oracle.sql.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    import ClassesGDC.*;
    public class testUpload extends HttpServlet {
    private String m_strMessage="";//It stores the message to be uploaded along with the Document
    Connection conn=null;
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    String strContent="";
    //res.setContentType("application/msword");
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    try {
    CallableStatement cmt=null;
    OutputStream output=null;
    ByteArrayOutputStream byteoutput=null;
    String strDocString="";
    oracle.sql.CLOB tempClob = null;
    String strPassedFileName="";     // the file name passed in the request object
    String strStdFilename="";//the file name to be given to the best practice
    String strSaveDirectory="";     //the directory in which the bp is to be saved
    String strParamName="";//name of parameters
    String strParamValue="";//value of parameters
    int intTempVariable=0; // temporaty variable
    long lngSizeOfFileUploaded=0;//stores the size of the file which had been uploaded in the file system
    File filePathOfFileUploaded=null;//stores the path of the file uploaded to the file system
    String strQuery="";
    //ST------------checks if the user has logged in or not-----------------------
    HttpSession session=req.getSession(true);
    if(req.getContentLength()>20*1024*1024)
    throw new skip("The size of the posted content is more than 10 MB . If you have a best practice whose size is more than 1 MB please mail it to Us.");
    byteoutput = new ByteArrayOutputStream();
    MultipartParser mp = new MultipartParser(req, 20*1024*1024); // 10MB is the limit of the file to be uploaded
    Part part;//Its an abstact part which helps in retrieving information about the file and the parameters
    while ((part = mp.readNextPart()) != null) {//Reads the next part
    strParamName = part.getName();
    // the following if is executed if the part is for a parameter rather than a file
    if (part.isParam()) {
    }else if (part.isFile()) {
    // it's a file part
    m_strMessage="inside file part";
    FilePart filePart = (FilePart) part;
    strPassedFileName = filePart.getFileName();
    strContent= filePart.getContentType();
    out.println("<BR><font color=red>strPassedFileName is "+strPassedFileName+"</font>");
    if(strPassedFileName != null || !(strPassedFileName.trim().equals("")) ) {
    // the part actually contained a file
    out.println("<BR><font color=red> before forming long</font>");
    //lngSizeOfFileUploaded = filePart.writeTo(filePathOfFileUploaded);      //the statement upload the bestpractice in the
    lngSizeOfFileUploaded = filePart.writeTo(byteoutput);     //specified file path filePathOfFileUploaded.
    out.println("<BR><font color=red> after file is written into the outputstream</font>");
    else {
    throw new skip("The file name is null or it is empty space. Files in such Format are not accepted");
    }//end of else if
    }//end of while loop
    if(     lngSizeOfFileUploaded==0)     {// the size of the file uploaded is zero then the file supplied was not proper and hence exception is to be thrown
    //if(filePathOfFileUploaded.exists())
    //     filePathOfFileUploaded.delete();
    throw new skip("The File could not be uploaded,Possible reasons may be that the file is sent null or the file is corrupted");
    //END---------------the file is uploaded in the proper directory--------------------
    //res.setContentType(strContent);
    out.println("<BR><font color=red>long value is : "+lngSizeOfFileUploaded+" and content is "+strContent+"</font>");
    String strbyte= byteoutput.toString();
    byteoutput.flush();
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // Establish network connection to database
    conn = DriverManager.getConnection("jdbc:oracle:thin:@pc-p32670:1521:GDCDBI","gdc_user","myuser");
    //if(conn!=null)
    out.println("<BR><font color=red>Connection formed"+conn);
    //els
    //out.println("<BR><font color=red>long value is : "+strbyte+"</font>");
    try{
    tempClob = oracle.sql.CLOB.createTemporary(conn,true, oracle.sql.CLOB.DURATION_SESSION);
    out.println("<BR><font color=red>tempClob : "+tempClob);
    tempClob.open( oracle.sql.CLOB.MODE_READWRITE);
    java.io.Writer tempClobWriter = tempClob.getCharacterOutputStream();
    // writing the string formed from the multipart file to the clob
    tempClobWriter.write(strbyte);
    if(tempClob!=null){}
    out.println("<BR><font color=red>CLOB value is : "+tempClob+"</font>");
    strQuery="{call INSERT_CLOB(?,?)}";
    cmt=conn.prepareCall(strQuery);
    cmt.setString(1,strPassedFileName);
    cmt.setClob(2,tempClob);
    cmt.registerOutParameter(2,java.sql.Types.CLOB);
    cmt.execute();
    tempClobWriter.flush();
    tempClobWriter.close();
    tempClob.freeTemporary();
    //res.setContentType(strContent);
    //strDocString.toString();
    out.println("<BR><font color=red>bob is "+strbyte+"</font>");
    tempClob.close();
    }catch(Exception e){
    tempClob.close();
    out.println("<font color=blue> Error is :"+e.getMessage()+"</font>");
    //e.printStackTrace(out);
    cmt.close();
    //out.println("<BR><font color=red><h2><b>SUCCESS</h2></font>");
    //res.sendRedirect("../test/showfile.jsp?contentype="+strContent.trim()+"");
    }catch(Exception e){
    java.util.Date d = new java.util.Date();
    String s =d.toString();
    out.println("<font color=blue> Error is :"+e.getMessage()+"</font>");
    //e.printStackTrace(out);
    }finally{
    try{
    if(conn!=null)
    conn.close();
    }catch(Exception e){
    out.println("<font color=blue> Error is :"+e.getMessage()+"</font>");
    }// end of finally
    } //end of doPost
    } //end of class
    in the Procedure you will be inserting/updating the clob in a table with the reference clob in the out parameter of the procedure
    Thanks.

  • Retrieving data from a relational table and CLOB as a whole XML file

    I created the table lob_example and I have managed to insert XML document into it using XML SQL Utility. In this document I put contents of <DESCRIPTION> tag into CDATA section.
    LOB_EXAMPLE
    Name Null? Type
    ID NOT NULL NUMBER
    DESCRIPTION CLOB
    NAME VARCHAR2(40)
    But I could not retrieve this data properly. I can think of only one solution - to parse and build the whole XMLDocument. I found the suggestion of another solution to use Oracle8i views to do that in http://technet.oracle.com/tech/xml/infoocs/otnwp/about_oracle_xml_products.htm, but this text is not clear enough for me.
    I would like to quote the fragment from document mentioned above, which is ambiguous for me:
    "Combining XML Documents and Data Using Views
    Finally, if you have a combination of structured and unstructured XML data, but still want to view and operate on it as a whole, you can use Oracle8i views. Views enable you to construct an object on the "fly" by combining XML data stored in a variety of ways. So, you can store structured data (such as employee data, customer data, and so on) in one location within object -relational tables, and store related unstructured data (such as descriptions and comments) within a CLOB. When you need to retrieve the data as a whole, you simply construct the structure from the various pieces of data with the use of type constructors in the view's select statement. The XML SQL Utility then enables retrieving the constructed data from the view as a single XML document."
    The main question is - how to use type constructors in the view's select statement?

    Hello
    Sorry for asking the same question again, but any responses would be greatly appreciated.
    How to use type constructors in the view's select statement?
    I could not find any answers for this question on Technet. Maybe the other approaches are more efficient to combine the part of data from CLOB with data from other column types?
    Thank you

  • Migration from Oracle OC4J to Weblogic 10.3 and CLOB ClassCastException

    I am migrating a web application from Oracle OC4J to Weblogic 10.0.3. In this application there are number of java files which uses the following piece of code and I can't change that:
    oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob(columnNumber);
    I have deployed the application on Weblogic Application Server. But when I run the application, it gives me the following exception:
    *1. SEVERE: Standard exception info for exception of type: 'java.lang.ClassCastException' at level: 0 - Error Text: 'weblogic.jdbc.wrapper.Clob_oracle_sql_CLOB'*
    *2. Apr 3, 2008 10:19:33 AM com.agencyport.menu.MenuController insert*
    *3. SEVERE: java.lang.ClassCastException: weblogic.jdbc.wrapper.Clob_oracle_sql_CLOB*
    *4.*
    *5. at com.agencyport.database.OracleDatabaseAgent.updateLOB(OracleDatabaseA*
    *6. gent.java:111)*
    *7. at com.agencyport.menu.MenuController.insert(MenuController.java:815)*
    [Post New]posted Today 11:09:13 AM private message
    Quote [Up]
    Dear Marcos,
    I have tried using ojdbc5, ojdbc6 and classess12 but with the same result. I am stuck with the problem. I have googled a lot but in vein. In some posts I got the idea to use weblogic.jdbc.vendor.oracle.OracleThinClob. But there is no package or class like mentioned in bold, available in weblogic.jar that I get from WEBLOGIC_HOEM/lib. I have downloaded weblogic 10.3 two times but still got no solution. weblogic.jar does not contain weblogic.jdbc.vendor.oracle.OracleThinClob.
    I have also read about using weblogic.jdbc.common.OracleClob to write unicode data but I do not find this package within the weblogic.jar
    Any idea please......
    Regards
    Muhammad Ijaz

    Have you reviewed this set of documentation:
    http://download.oracle.com/docs/cd/E12839_01/wls/docs103/jdbc/thirdparty.html#wp1043705
    http://download.oracle.com/docs/cd/E12839_01/wls/docs103/jdbc/thirdparty.html#wp1045809
    http://download.oracle.com/docs/cd/E12839_01/wls/docs103/jdbc/thirdparty.html#wp1043777
    There is also a special forum for WebLogic JDBC related questions:
    WebLogic Server - JDBC

  • Using DB Adapter with XMLDB and CLOB

    Hi,
    with oracle xmldb i can store XMLs in lob or structured storage (s. Oracle® XML DB Developer's Guide 10g Release 2 (10.2) B14259-02).
    Now my question:
    If want to use a database adapter in the ESB to wake up several BPELs. Is there a functionality how i can transform such a clob into a XML where i can use XSLTs?
    The db adapter does only map each column to one xml-tag...
    If i try to use a table with xmltype the creation of a database adapter fails with:
    "some tables contain columns that are not recognized by the database adapter, so they will captured as strings:
    sys_nc_rowinfo$(sys.xmltype)
    change teh type of the above columns to that of the closest supported type...."
    Message was edited by:
    HEWizard

    Hi,
    To get it working you have to create an AQ-table with payload type xmltype. The xmltype payload data type is available on rdbms 10g and up. If you are on 9i or lower use raw data type. Create a queue inside the AQ-table. I'm not quite sure what's the best scenario for you to the queue with data, but I would imagine that you could create a database trigger on the table you're talking about and enqueue the xml-data (payload) to the AQ-table. Thus using the AQ-table as a staging table for the ESB system.
    Next, create an ESB system using an AQAdapter to dequeue the queue (like you did using a DBAdapter). The adapter can handle both single-user and multi-consumer queue's and all data types (raw, xmltype and object types).
    Messages are dequeued generally within a second after you commited the transaction.
    Kind regards,
    H

  • Encoding problem with convert and CLOB involving UTF8 and EBCDIC

    Hi,
    I have a task that requires me to call a procedure with a CLOB argument containing a string encoded in EBCDIC. This did not go well so I started narrowing down the problem. Here is some SQL to illustrate it:
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> select value from v$nls_parameters where parameter = 'NLS_CHARACTERSET';
    VALUE
    AL32UTF8
    SQL> select convert(convert('abc', 'WE8EBCDIC500'), 'AL32UTF8', 'WE8EBCDIC500')
    output from dual;
    OUT
    abc
    SQL> select convert(to_char(to_clob(convert('abc', 'WE8EBCDIC500'))), 'AL32UTF8', 'WE8EBCDIC500') output from dual;
    OUTPUT
    ╒╫¿╒╫¿╒╫¿
    So converting to and from EBCDIC works fine when using varchar2, but (if I am reading this right) fails when involving CLOB conversion.
    My question then is: Can anyone demonstrate how to put correct EBCDIC into a CLOB and maybe even explain why the examples do what they do.

    in order to successfully work with xmldb it is recommended that you use 9.2.0.4
    and above. Its seems to have lower version.
    Okay now related to the problem , if your data that you want to send to the attributes are not greater than 32767, then you can use the pl/sql varchar2 datatype to hold the data rather then CLOB and overcome this problem.
    here is the sample. use function with below pl/sql to return the desired output.
    SQL> declare
      2   l_clob     CLOB := 'Hello';
      3   l_output   CLOB;
      4  begin
      5    select  xmlelement("test", xmlattributes(l_clob AS "a")).getclobval()
      6      into l_output from dual;
      7  end;
      8  /
      select  xmlelement("test", xmlattributes(l_clob AS "a")).getclobval()
    ERROR at line 5:
    ORA-06550: line 5, column 44:
    PL/SQL: ORA-00932: inconsistent datatypes: expected - got CLOB
    ORA-06550: line 5, column 3:
    PL/SQL: SQL Statement ignored
    SQL> declare
      2   l_vchar     varchar2(32767) := 'Hello';
      3   l_output   CLOB;
      4  begin
      5    select  xmlelement("test", xmlattributes(l_vchar AS "a")).getclobval()
      6      into l_output from dual;
      7    dbms_output.put_line(l_output);
      8  end;
      9  /
    <test a="Hello"></test>
    PL/SQL procedure successfully completed.

  • BC4J, Triggers, and Clobs

    I'm on a J2EE web-application that is using the BC4J framework. At one point, we're taking some information from a form and saving that info into a table (composed of a couple varchar columns and a couple of CLOB columns). There are two triggers associated with this table, one that fires before insert that grabs a seq number as well as a date, and another that fires after insert that calls a PL/SQL procedure that creates a txt file on our filesystem with the appropriate info. The text file, however, does not contain the information from the CLOB fields. When inserting a new record from SQL*PLUS, the text file is created correctly, meaning the triggers work fine, the insert works fine, the writing to the file system works fine. So, what's the difference between inserting from SQL*PLUS and inserting through the web application?
    To test a theory, I removed the trigger and put the call to the PL/SQL procedure into a callablestatement in one of the actions. This actually led to a correct writing to the file system. This solution, however, is unacceptable due to some legacy issues.
    So, how is BC4J treating the insert of CLOB's? Does it issue an insert statement that only puts in the non-CLOB columns and then updates the table with the CLOBs? Or is the something else that I'm missing?
    Any help would be greatly appreciated.
    -chris

    In BC4J, CLOB fields are updated after the row is inserted and an empty CLOB locator has been created in the db. So you may also want to update your textfile trigger to apply on update of the clob field.

  • Oracle 10g XE and CLOB data type

    I am using Oracle 10.2.0.1.0 Express Edition and I wish to store large amounts of data in a CLOB column. I have created my table using a "standard" SQL statement similar to the following:
    CREATE TABLE LotsofData(
    id INT NOT NULL,
    data CLOB);
    The table is created successfully, so far so good.
    And I used a "standard" insert SQL statement to insert large amount of data into the before mentioned table, similar to the follwing:
    INSERT INTO LotsofData VALUES('4043', 'The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog <insert more iterations>');
    The data being inserted takes up 4043 bytes. Now when attempting, using among other programs the handy web interface, to execute the insert statement I get this error:
    Error starting at line 1 in command:
    INSERT INTO LotsofData VALUES('4043', 'The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog <insert more iterations>');
    Error at Command Line:1 Column:38
    Error report:
    SQL Error: ORA-01704: string literal too long
    Now if I reduce the size of the data to be inserted to 4000 bytes or below there is no problem. I have performed searches on google groups, google search engine, the oracle site, this forum but not found a way to solve it... I have found documentation stating that there is support for 4gb of user data, but well that doesn't really help.
    I have been on the trail of TABLESPACE and working with that, but with no luck. The data type BFILE will not work as I need to be able to change the data after it has been inserted into the table.
    Is the 4000 bytes a limitation in the Express Edition and I should just forget it, or is there a way I configure the database to accept large amounts of data. Should I be creating the table using a different SQL statement?
    kind regards
    Chris Nilsson

    Right... I found out how you can solve this, well not through the web interface... but oh well it is possible though...
    the error I was getting was: ORA-01704:     string literal too long.
    the keyword/phrase is "bind variables"... Did a little more searching and found this site:
    http://www.akadia.com/services/ora_bind_variables.html
    So basically you use bind variables to insert data which fills more than 4000 bytes...
    Since the data I will be inserting will be inserted via Java/.NET application I found the section called "Bind Variables in VB, Java and other applications" the most interesting... During my testing and I had neglected to use PreparedStatements in Java, and according to the site, using PreparedStatement provided an easier solution as the API does most of the work for you. My solution was to create a small program which read the large amounts of data from a file then feed this to a PreparedStatement, setObject or setASCIIStream/setCharacterStream, then execute it.
    Well I hope this helps other people who get the same error code.

Maybe you are looking for