Updating CLOB in Oracle 8i

We are using Oracle 8i.
And I need to update country code inside the message body. Please help me.
Sample table structure
  CREATE TABLE test_xml_tab ( message_id NUMBER,
                              message_body CLOB);
-- Test data
Sample data for Message_body
<ADDRESSES>
<ADDRESS>
  <TYPE>Ship To</TYPE>
  <SWADDRESS1>ABC 5</SWADDRESS1>
  <SWADDRESS2/>
  <SWADDRESS3/>
  <SWADDRESS4/>
  <SWADDRESS5/>
  <SWCITY>AA</SWCITY>
  <SWCOUNTY/>
  <SWCOUNTRY>22</SWCOUNTRY>
  <SWPROVINCE>.</SWPROVINCE>
  <SWMAILSTOP/>
  <SWNOTE/>
  <SWPOBOX/>
  <SWSTATE>.</SWSTATE>
  <SWZIP>50197</SWZIP>
  <SWDEFAULT/>
  <SWSTREETNUM/>
</ADDRESS>
</ADDRESSES>
I need to update SWCOUNTRY value to IN.

It can be done using UPDATEXML.
SQL> with rec as (
Select Xmltype(
  2    3  ' <ADDRESSES>
  4    <ADDRESS>
  5    <TYPE>Ship To</TYPE>
  6    <SWADDRESS1>ABC 5</SWADDRESS1>
  7    <SWADDRESS2/>
  8    <SWADDRESS3/>
  9    <SWADDRESS4/>
10    <SWADDRESS5/>
11    <SWCITY>AA</SWCITY>
12    <SWCOUNTY/>
13    <SWCOUNTRY>22</SWCOUNTRY>
14    <SWPROVINCE>.</SWPROVINCE>
15    <SWMAILSTOP/>
16    <SWNOTE/>
17    <SWPOBOX/>
18    <SWSTATE>.</SWSTATE>
19    <SWZIP>50197</SWZIP>
20    <SWDEFAULT/>
21    <SWSTREETNUM/>
22   </ADDRESS>
23   </ADDRESSES>') xml
24   From Dual)
25  select updatexml (xml,'//SWCOUNTRY/text()','INDIA') new_xml  from rec;
NEW_XML
<ADDRESSES>
  <ADDRESS>
    <TYPE>Ship To</TYPE>
    <SWADDRESS1>ABC 5</SWADDRESS1>
    <SWADDRESS2/>
    <SWADDRESS3/>
    <SWADDRESS4/>
    <SWADDRESS5/>
    <SWCITY>AA</SWCITY>
    <SWCOUNTY/>
    <SWCOUNTRY>INDIA</SWCOUNTRY>
    <SWPROVINCE>.</SWPROVINCE>
    <SWMAILSTOP/>
    <SWNOTE/>
    <SWPOBOX/>
    <SWSTATE>.</SWSTATE>
    <SWZIP>50197</SWZIP>
    <SWDEFAULT/>
    <SWSTREETNUM/>
  </ADDRESS>
</ADDRESSES>
SQL>But I am not sure whether UPDATEXML function is available in Oracle 8i .

Similar Messages

  • Problem updating CLOBs across multiple schemas

    I am having a problem trying to update CLOB data in a schema owned by a user other than the logged-in user.
    Suppose I have user UA who owns table TA and user UB who owns table TB, and TA and TB contain CLOB columns. TA owns a package PA and TB owns package PB; these packages provide functions for updating the CLOB data via LOB locators.
    I have a JDBC connection logged on as user UA, and I can successfully call package PA to update the CLOB data in TA from my Java app. However, I cannot use this connection to similarly call package PB to update the CLOB data in TB - the app successfully calls CallableStatement.executeUpdate() but then I try to get the output stream of the returned CLOB:
    oracle.sql.CLOB oOraClob = (oracle.sql.CLOB)oCall.getClob(SQLPAR_CLOBCOL);
    Writer oOut = oOraClob.getCharacterOutputStream();
    and I get the following exception on the getCharacterOutputStream() call:
    java.sql.SQLException: ORA-01031: insufficient privileges ORA-06512: at "SYS.DBMS_LOB", line 498 ORA-06512: at line 1
    This is despite user UA having execute privilege on PB and update on table TB.
    I only get this problem when I try to update the CLOB directly from JDBC - I have another function in package PA which copies CLOB data directly from TA to TB and that works without any problem. Given this, I tried writing a procedure in PA to act as a kind of proxy between PB's CLOB-update function and user UA, i.e. UA calls a proc in PA which in turn calls PB which returns a LOB locator to PA, which in turn returns the LOB locator to user UA, but this still gave the same error.
    Does anyone know what might be causing the problem? Is there some user permission I'm missing?
    I don't want to have to use a separate DB connection as user UB just to update the CLOB. The only other solution I can see at present is to pass the string data to PA as a LONG and have PA copy the data to the LOB locator returned by PB. How could I achieve this? Is there a built-in function which enables a LONG to be copied to a CLOB?
    Any help would be very much appreciated. Thanks.
    Al.
    null

    Ian - You can use a different schema for each application while keeping the applications in a common workspace. This would allow users to authenticate once and for the applications to share the same authenticated session. In doing this, however, a user has to be given links from one application to another, e.g., from a menu page, in order for the "session continuity" to remain unbroken (a requirement to prevent another login challenge). But since these may be unrelated applications that have no need to access one anothers' session state, it might be better to use Single Sign-On. With this method there is only one login required and a user can access each application which will maintain its own private session.
    Scott

  • Insert CLOB into oracle under weblogic

    Situation: running my servlet under weblogic, want to insert more than 4000 characters into CLOB of oracle 8.1.7
    Problem: cannot be done by using code which is able to do it under tomcat
    i use this code in tomcat:
    import java.sql.*;
    import oracle.sql.CLOB;
    import oracle.jdbc.driver.OracleResultSet;
    con.setAutoCommit(false);
    Statement stmt = con.createStatement();
    rs = stmt.executeQuery("SELECT clob_field FROM table where rid=id FOR UPDATE");
    rs.next();
    CLOB clob = ((OracleResultSet)rs).getCLOB(1);
    Writer writer = clob.getCharacterOutputStream();
    writer.write(dataString);
    writer.close()l
    con.commit();
    con.setAutoCommit(true);
    stmt.close();
    after that i know that i can't use API of oracle when i'm using weblogic (e.g. oracle.sql.CLOB)
    and i find this code from other user:
    import weblogic.jdbc.vendor.oracle.OracleThinClob;
    import java.io.*;
    import java.sql.*;
    PreparedStatement stmt = con.prepareStatement ( "INSERT INTO database VALUES ( ?, EMPTY_CLOB() )" );
    stmt.setInt ( 1, 1 );
    // inserts a new entry with an empty clob object
    stmt.executeUpdate ();
    if ( stmt != null )
    stmt.close();
    // retrieves CLOB-Object
    stmt = con.prepareStatement ( "SELECT clob_field FROM database WHERE id=?" );
    stmt.setInt ( 1, 1 );
    ResultSet rs = stmt.executeQuery ( );
    if ( rs.next() )
    Clob cl = rs.getClob(1);
    Writer clobWriter = ((OracleThinClob)cl).getCharacterOutputStream();
    // Open the sample file as a stream for insertion into the Clob column
    File testFile = new File ( "file.txt" );
    FileReader testReader = new FileReader ( testFile );
    // buffer to hold data to being written to the clob.
    char[] cBuffer = new char[((OracleThinClob)cl).getBufferSize()];
    // Read data from file, write it to clob
    int iRead = 0;
    while( (iRead= testReader.read(cBuffer)) != -1 )
    clobWriter.write( cBuffer, 0, iRead);
    testReader.close();
    clobWriter.close();
    if ( rs != null )
    rs.close();
    if ( stmt != null )
    stmt.close();
    // update clob-data in database
    stmt = con.prepareStatement ( "UPDATE database SET clob_field = ? WHERE id = ?" );
    stmt.setClob ( 1, cl );
    stmt.setInt ( 2, 1 );
    stmt.executeUpdate();
    it throws java.lang.ClassCastException: oracle.sql.CLOB
    but i haven't imported or used any API from oracle.........
    please help
    thanks

    hi,
    unfortunatly, you can't do this with welbogic6.1 because it 'manage' itself oracle librairies (weblogic.jar),
    here is the way i solved the pb for BLOB :
    i replaced :
    BLOB blob = ((OracleResultSet)rs).getBLOB(1);
    by
    weblogic.jdbc.rmi.SerialOracleBlob cast1 =(weblogic.jdbc.rmi.SerialOracleBlob)rs.getBlob("myBlob");
    weblogic.jdbc.rmi.internal.OracleTBlobImpl cast2 =(weblogic.jdbc.rmi.internal.OracleTBlobImpl)cast1.getTheRealBlob();
    BLOB myBlob = (oracle.sql.BLOB)cast2.getTheRealBlob();
    it is the same for clob (i suppose ^_^)
    hope this helps !
    Badr.

  • Not able to see ikm oracle incremental update and ikm oracle slowly changing dimensions under PHYSCIAL tab in odi 12c

    not able to see ikm oracle incremental update and ikm oracle slowly changing dimensions under PHYSCIAL tab in odi 12c
    But i'm able to see other IKM's please help me, how can i see them

    Nope, It has not been altered.
    COMPONENT NAME: LKM Oracle to Oracle (datapump)
    COMPONENT VERSION: 11.1.2.3
    AUTHOR: Oracle
    COMPATIBILITY: ODI 11.1.2 and above
    Description:
    - Loading Knowledge Module
    - Loads data from an Oracle Server to an Oracle Server using external tables in the datapump format.
    - This module is recommended when developing interfaces between two Oracle servers when DBLINK is not an option.
    - An External table definition is created on the source and target servers.
    - When using this module on a journalized source table, the Journaling table is first updated to flag the records consumed and then cleaned from these records at the end of the interface.

  • Difference in select for update of - in Oracle Database 10g and 11g

    Hi, I found out that Oracle Database 10g and 11g treat the following PL/SQL block differently (I am using scott schema for convenience):
    DECLARE
      v_ename bonus.ename%TYPE;
    BEGIN
      SELECT b.ename
        INTO v_ename
        FROM bonus b
        JOIN emp e ON b.ename = e.ename
        JOIN dept d ON d.deptno = e.deptno
       WHERE b.ename = 'Scott'
         FOR UPDATE OF b.ename;
    END;
    /While in 10g (10.2) this code ends successfully (well NO_DATA_FOUND exception is raised but that is expected), in 11g (11.2) it raises exception "column ambiguously defined". And that is definitely not expected. It seems like it does not take into account table alias because I found out that when I change the column in FOR UPDATE OF e.empno (also does not work) to e.mgr (which is unique) it starts working. So is this some error in 11g? Any thoughts?
    Edited by: Libor Nenadál on 29.4.2010 21:46
    It seems that my question was answered here - http://stackoverflow.com/questions/2736426/difference-in-select-for-update-of-in-oracle-database-10g-and-11g

    The behaviour seems like it really is a bug and can be avoided using non-ANSI syntax. (It makes me wonder why Oracle maintains two query languages while dumb me thinks that this is just a preprocessor matter and query engine could be the same).

  • Error While reading CLOB from Oracle using WebLogic Connection Pool, Works fine with out using pool

    PROBLEM DESCRIPTION :
         When I try to read a clob from Oracle, I receive "ORA-03120: two-task
    conversion routine: integer overflow" Error.
         This error occurs only for CLOB Type and only if I try to connect to
    Oracle using WebLogic JDriver/Oracle POOL.
         IMPORTANT NOTE: I can read CLOB or any other data using direct JDBC
    connection to ORacle with out any problem.
         Below Please find the JAVA CODE for Both Working and NON Working .
    Created a Connection Pool as:
    Name: MyJDBCConnectionPool
    URL : jdbc:weblogic:oracle
    DIRVER:weblogic.jdbc.oci.Driver
    NON WORKING JAVA CODE (USES WEBLOGIC JDBC CONNECTION POOL TO ORACLE):
    Driver myDriver =
    (Driver)Class.forName("weblogic.jdbc.pool.Driver").newInstance();
    Connection mconn =
    myDriver.connect("jdbc:weblogic:pool:MyJDBCConnectionPool",null);
    mconn.setAutoCommit (false);
    CallableStatement cs = mconn.prepareCall("{call
    P_XMLTEST2(?)}"); //This returns a CLOB
    cs.registerOutParameter(1,java.sql.Types.CLOB);
    cs.execute();
    Clob clob = null;
    clob = cs.getClob(1);
    String data =new String();
    data = clob.getSubString(1, (int)clob.length());
    System.out.println(data); //print the data
    data = null;
    clob=null;
    cs.close();
    WORKING JAVA CODE (USES DIRECT THIN JDBC CONNECTION TO ORACLE):
    Driver myDriver =
    (Driver)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    Connection mconn =
    myDriver.connect("jdbc:oracle:thin:@server:1521:DB",null);
    mconn.setAutoCommit (false);
    CallableStatement cs = mconn.prepareCall("{call
    P_XMLTEST2(?)}"); //This returns a CLOB
    cs.registerOutParameter(1,java.sql.Types.CLOB);
    cs.execute();
    Clob clob = null;
    clob = cs.getClob(1);
    String data =new String();
    data = clob.getSubString(1, (int)clob.length());
    System.out.println(data); //print the data
    data = null;
    clob=null;
    cs.close();
    ERROR MESSAGE:
         ORA-03120: two-task conversion routine: integer overflow
    I appreciate your help on this problem.

    PROBLEM DESCRIPTION :
         When I try to read a clob from Oracle, I receive "ORA-03120: two-task
    conversion routine: integer overflow" Error.
         This error occurs only for CLOB Type and only if I try to connect to
    Oracle using WebLogic JDriver/Oracle POOL.
         IMPORTANT NOTE: I can read CLOB or any other data using direct JDBC
    connection to ORacle with out any problem.
         Below Please find the JAVA CODE for Both Working and NON Working .
    Created a Connection Pool as:
    Name: MyJDBCConnectionPool
    URL : jdbc:weblogic:oracle
    DIRVER:weblogic.jdbc.oci.Driver
    NON WORKING JAVA CODE (USES WEBLOGIC JDBC CONNECTION POOL TO ORACLE):
    Driver myDriver =
    (Driver)Class.forName("weblogic.jdbc.pool.Driver").newInstance();
    Connection mconn =
    myDriver.connect("jdbc:weblogic:pool:MyJDBCConnectionPool",null);
    mconn.setAutoCommit (false);
    CallableStatement cs = mconn.prepareCall("{call
    P_XMLTEST2(?)}"); //This returns a CLOB
    cs.registerOutParameter(1,java.sql.Types.CLOB);
    cs.execute();
    Clob clob = null;
    clob = cs.getClob(1);
    String data =new String();
    data = clob.getSubString(1, (int)clob.length());
    System.out.println(data); //print the data
    data = null;
    clob=null;
    cs.close();
    WORKING JAVA CODE (USES DIRECT THIN JDBC CONNECTION TO ORACLE):
    Driver myDriver =
    (Driver)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    Connection mconn =
    myDriver.connect("jdbc:oracle:thin:@server:1521:DB",null);
    mconn.setAutoCommit (false);
    CallableStatement cs = mconn.prepareCall("{call
    P_XMLTEST2(?)}"); //This returns a CLOB
    cs.registerOutParameter(1,java.sql.Types.CLOB);
    cs.execute();
    Clob clob = null;
    clob = cs.getClob(1);
    String data =new String();
    data = clob.getSubString(1, (int)clob.length());
    System.out.println(data); //print the data
    data = null;
    clob=null;
    cs.close();
    ERROR MESSAGE:
         ORA-03120: two-task conversion routine: integer overflow
    I appreciate your help on this problem.

  • How can I get the content of clob in oracle db?

    In jsp,if I want to get the characters from CLOB column in ORACLE DataBase,what should I do?
    I am waiting for the answer hurrily.Thank you!

    import these two classes:
    import oracle.sql.CLOB;
    import oracle.jdbc.driver.OracleResultSet;To retrieve the clob, use
                  ResultSet rs;
                      get the rs from database
                  int i = 1;  //  this is the column Index in the rs
                  CLOB cl = ((OracleResultSet)rs).getCLOB(i);
                  int len = (int)cl.length();
                  String str = cl.getSubString(1,len);

  • Which is better: Oracle incremental update (merge) or Oracle incremental update

    Hi All,
    We have big data load happening from Oracle RDBMS(source) to Oracle RDBMS(target). The data is huge (in billions) and new insertions, updates will happen. I would like to understand which among
    Oracle incremental update (merge) or Oracle incremental update is better and faster -  for first load and subsequent incremental updates, deletes? I request you all to provide valid reasons since I need to present the same to my client
    If at all Oracle incremental update (merge) is better, then why ODI needs to have Oracle incremental update IKM.
    I have seen some discussions on the same topic but I have not yet got a proper response with reasons and that is why I am posting the question again
    Thanks & Regards,
    Sijee Sadasivan

    Hi Sijee Sadasivan,
    IKM SQL Control Append could be faster for the initial load. You will therefore need another interface for the initial load.
    From my experience IKM Oracle Incremental Update (Merge) is faster than IKM Oracle Incremental Update for the incremental load, but I think the best thing to do is to try it on your environment. Nothing is better than a benchmark .
    IKM Oracle Incremental Update is useful for Oracle RDBMS < 9i, before this syntax was introduced.
    Regards,
    JeromeFr

  • Writing an update statement in oracle forms 9i

    Hi ,
    I have a problem situation in which
    I am fetching values from a cursor and a recod group into two data block items text box and combo box respectively .
    Both the data is fetched from different tables .
    Now based on the selection from combo box I have to update the selected value in another table by writing an update statemet .
    I have created a button and on the trigger event of when button pressed I wrote a simple update statement but it's not working that way .
    Kindly help me how to write manual update statements in oracle forms 9i
    I can't used the update buil in of forms as I want to update in a table which is not mentioned in the property pallete of data block
    please help

    I just wrote a procedure
    PROCEDURE update_current IS
    BEGIN
    update table abc set xculumn= :block_name.item_name2 where ycolumn = :block_name.item_name1 ;
    commit;
    and I called the procedure from a when button pressed trigger
    it gave an error invalid identifier abc ( which is table name)
    pls help
    I am trying to do it with form_ddl(update_query)
    but here I am facing another problem
    I have update_query = 'update table abc set xculumn= ' || :block_name.item_name2 || 'where ycolumn = '||:block_name.item_name1
    now since xculumn and y column are varchar type so I suppose while preparing the query I have to concatenate single quotes ( ' ) at the start and end
    but i am facing problems in doing so
    please tell me an alternative way or how to concatenate single quotes in the above update_query variable

  • How to update column in Oracle SQL Developer?

    Hi everybody,
    How can I update table in Oracle SQL Developer like in PL/SQL Developer use:
    Select * from table for update;
    Thank you~

    Do you mean you want to edit the result grid?
    You can't edit the result grid of a query, but you can edit the data tab of a table.
    Click on the table in the object browser
    Click on the data tab
    Optionally filter the results using the filter field at the top
    Type into the data cells.
    Click on the commit button

  • Converting Varchar into Clob in Oracle 8i

    Hi All,
    Kindly tell me how can we convert a varchar variable into a Clob in Oracle 8i inside a stored procedure. I searched alot on the net, we have a To_Clob function available from 9i but doesn't exist in 8i. There was also talk about using dbms_lob, but i dont know how to use that to convert it.
    Kindly provide me with the details of how to do this as I am just starting out with Oracle.
    Thanks in Advance,
    Sajid.

    Hi,
    You can use the dbms_lob.to_clob() function(In oracle8i).
    In oracle 9i it is not required.
    Thanks & Regards
    venkata

  • Accessing CLOBs in Oracle 8i

    From the research i've done, it seems that there are two ways to access CLOBs in Oracle 8i: InputStream or Reader.
    The InputStream method uses byte streams and the Reader uses character streams.
    Is that correct? I haven't been able to determine the pros/cons of the two approaches. Can anyone shed some light on this for me?

    Jack Shirazi claims in his book, "Java Performance Tuning", that in most situations Readers provide better performance than InputStreams.
    Read the section, "From Raw I/O to Smokin' I/O", in Chapter 8 for details.

  • To update my remote oracle server through e mail

    hai,
    i want to update my remote oracle server through e mail which should run automatically for every 3 hours(for example)
    both(remote and local) are oracle 8.1.7 running in windows 2000 server
    Please let me know how to go about....
    help me in this context...
    urs
    srini

    Sri
    you can do with some SMTP programming like that one available in VisuaBasic. you can read the mail from an inbox
    from a mail account of an SMTP SERVER. Then you may try to update the remote database.
    Well i have mentioned VB as i heard it long back from my GURUJI that it is possible thru SMTP programming in VB
    using the socket controls etc,.
    Please check it out in some visuabasic forum sites and ask some VB Gurus.
    Thanks
    Prakash
    [email protected]

  • Using eclipse Web services to retrieve and update data to Oracle DB

    Hi,
    Can I have a sample about to use eclipse to retrieve/update data from Oracle DB by using axis web services?
    thank you

    Hi,
    If you have a sheet in Excel with data from a SharePoint Online list you can switch to the PowerPivot ribbon and ask to add it to the model. This will allow you to reference this table when you create a PowerView report.
    This workbook, with the Odata feed can then be refreshed via the scheduled refresh feature of Power BI Site.
    Insert the data using the Odata feed
    The Odata URL will be something like:
    https://MyCompany.sharepoint.com/MySite/MySubSite/_vti_bin/listdata.svc/MyList
    If you are not sure what is the list name, you can drop just browse to
    https://MyCompany.sharepoint.com/MySite/MySubSite/_vti_bin/listdata.svc and this will provide a list of all the lists in that site/sub-site.
    Once you have those in the model and you setup scheduled refresh, it will refresh the lists directly from SPO (using the owner identity)
    Hope this helps.
    Guy
    GALROY

  • Problem installing Oracle Linux Release 5 Update 2 from Oracle e-Delivery

    Hello
    I have been trying to install Oracle Linux Release 5 Update 2 from Oracle e-Delivery so that I can install Oracle 11g express edition beta.
    Here are the steps that I took and the problem that I am having:
    1. I downloaded the file, unzipped the file twice, which gave me 3,042 files and 13 folders with the total size = 3.07 GB.
    2. I put in the DVD and restarted my PC hoping that my PC will boot from the DVD, but instead Window started.
    I reported this issue to tech support from e-Delivery, but they referred me to contact you. Please assist.
    Julia

    3,042 files and 13 folders with the total size = 3.07 GBWhich download .zip did you choose from edelivery? Under linux-x64 I peeked "Oracle Linux Release 5 Update 2 for x86_64 (64 Bit) - DVD" file V15099-01.zip downloaded, it has just the one .iso file. You'll need to burn that to DVD, but with burn s/w that handles ISO files.
    Also keep in mind you'll need 64 bit hardware (amd/intel 64? itanium? those are different), the only *nix platform I've got handy to try it out is -x86 :(                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • No WiFi icon and not detecting any networks on new ipad 2

    Hi I have a new ipad 2 16G wifi. I went through all the setup but have been unable to connect to any networks. I have updated software I have restored I have turned router on / off I have made router public I have tried to specify the network I have

  • Is there an issue with Edit Auto-Blend Layers in Photoshop CC 2014?

    The command Edit > Auto-Blend Layers in Photoshop CC 2014.1 does not seem to produce the expected results for me. For example, I used the Edit > Auto-Blend Layers command when I was doing the exercise on Adding Depth of Field starting on page 122 of

  • Call to ABAP webservice failed following upgrade to ECC6

    Hi all, I have the following interface : LDAP (webservice) ->XI 3.0sp17 -> ECC5 (webservice) sending employees id. it works fine. But, these days, SAP ECC has been upgraded from ECC5 to ECC6 (was 7.0). And now the call to the ECC webservice does not

  • Need to send my PC in

    I need to send my computer in to be repaired and i cant seem to locate a link or anything to register the necessary information. Can someone help me out plz?

  • Mounting NTFS,FAT32 and USB FLASH drive

    Problem and problem!! I am going to fade up with Solaris 10. Please somebody help me!! Problem is with mounting my FAT32, NTFS partitions and USB flash drive (twinmos). How can I mount FAT32, NTFS file system and my USB flash drive in Solaris 10??