Need help with update statement with multiple joins

I've got the following select statement that is pulling 29 records:
SELECT
PPA.PROJECT_ID,
PPA.SEGMENT1,
peia.expenditure_item_id,
peia.expenditure_type,
pec.expenditure_comment
FROM PA.PA_PROJECTS_ALL PPA,
pa.pa_expenditure_items_all peia,
pa.pa_expenditure_comments pec
where PPA.segment1 < '2008' and
PPA.project_id = 52 and -- just run for project # 20077119 for testing
peia.expenditure_type = 'PAYROLL' and
peia.project_id = ppa.project_id and
PEC.EXPENDITURE_ITEM_ID = PEIA.EXPENDITURE_ITEM_ID;
I need to update the pec.expenditure_comments to a static field for those 29 records. I assume I should start with the following, but not sure how to complete the where:
update
pa.pa_expenditure_comments pec
set pec.expenditure_comment = 'REFERENCE HD#728'
where
First time that we've ever needed to update, so any and all help appreciated.

Try using exists:
update pa.pa_expenditure_comments pec
set    pec.expenditure_comment = 'REFERENCE HD#728'
where exists ( select null
               from   pa.pa_projects_all ppa
               ,      pa.pa_expenditure_items_all peia
               ,      pa.pa_expenditure_comments pec2
               where  ppa.segment1 < ''    -- not sure what you posted here, so for next time:
                                           -- please put your examples between the code tags.
               and    ppa.project_id = 52  -- just run for project # 20077119 for testing
               and    peia.expenditure_type = 'PAYROLL'
               and    peia.project_id = ppa.project_id
               and    pec2.expenditure_item_id = peia.expenditure_item_id
               and    pec2.expenditure_item_id = pec.expenditure_item_id
             );

Similar Messages

  • Need help in update statement

    hi,
    how can i achieve the following logic
    I have table ABC with column A varchar(20), B(int), C(varchar(20))
    if A is null and B is valid number then C has to be updated with 'text'
    if A is valid text and B is null then C has to be updated with 'number'
    if A is valid text and B is valid number then C has to be updated with 'text-number'
    thanks in advance

    First Update
    UPDATE ABC
    SET C= 'text'
    where A is null;since B is int data type it will always storeintegeres hence check not required.
    Second Update
    UPDATE ABC
    set C = 'number'
    where A is not null
    and B IS NULLThird Update
    UPDATE ABC
    SET C = 'number-text'
    WHERE A IS NOT NULL;Hope this answers.
    You can get this in single update too
    AND B IS NOT NULL

  • Update statement with joining other tables

    Hi ,
    I have two table one is containing xml file , basically i need to read from those xml file then update to another table based on some condition.
    UPDATE TRCB_XBRL_STG_2 STG
    SET PROFIT =
      case when xbrl.isconsolidatedacc='Y' and EXTRACTVALUE(XBRL.XBRLFILE,'//PROFIT ', 'xmlns:acra="..."') is not null
      THEN EXTRACTVALUE(XBRL.XBRLFILE,'//PROFIT ', 'xmlns:acra="..."')
      WHEN XBRL.ISCONSOLIDATEDACC='N' AND EXTRACTVALUE(XBRL.XBRLFILE,'//PROFIT ', 'xmlns:acra="..') IS NOT NULL
      THEN extractValue(XBRL.xbrlfile,'//PROFIT ', 'xmlns:acra=".."')
      ELSE STG.PROFIT
      END,
      SET REVENUE=
      case when xbrl.isconsolidatedacc='Y' and EXTRACTVALUE(XBRL.XBRLFILE,'//REVENUE', 'xmlns:acra="..."') is not null
      THEN EXTRACTVALUE(XBRL.XBRLFILE,'//REVENUE.', 'xmlns:acra="..."')
      WHEN XBRL.ISCONSOLIDATEDACC='N' AND EXTRACTVALUE(XBRL.XBRLFILE,'//REVENUE', 'xmlns:acra="..') IS NOT NULL
      THEN extractValue(XBRL.xbrlfile,'//REVENUE', 'xmlns:acra="REVENUE"')
      ELSE STG.REVENUE
      END,
      ... (around 100 columns)
    FROM  TRCB_XBRL xbrl ,TRCB_XBRL_STG_2 STG
    WHERE STG.XBRL_ID = XBRL.XBRL_ID Number of columns are around 100 , please anyone suggest how to use update statement with joining two tables.

    Hi,
    If all the values needed to update a given row of table_x are coming from the same row of table_y (or from the same row of a result set of a query involving any number of tables), then you can do something like this:
    UPDATE  table_x  x
    SET     (col1, col2, col3, ...)
    =     (
             SELECT  NVL (y.col1, x.col1)
             ,         NVL (y.col2, x.col2)
             ,         NVL (y.col3, x.col3)
             FROM    table_y  y
             WHERE   x.pkey   = y.expr
             AND         ...
    WHERE   ...
    ;If the WHERE clause depends on the same row of table_y, then it will probably be simpler and more efficient to use MERGE instead of UPDATE.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • Update statement with inner join

    Hello everyone. I am am trying to do an update statement with an inner join. I have found several examples of SQL statements that work with Sql server and mysql but they don't work in Oracle. Does anyone know the proper way in Oracle 10G? I am trying to update all fields in one table from fields in another table.
    for example:
    UPDATE table3
    SET
    TL3.name = TL2.name,
    TL3.status = TL2.status,
    TL3.date = TL2.date
    FROM table3 TL3 JOIN table2 TL2
    ON (TL3.unique_id = TL2.unique_id);
    any help will be appreciated.

    Hi,
    You can also use MERGE, like this:
    MERGE INTO  table3     dst
    USING   (
             SELECT  unique_id
             ,         name
             ,         status
             ,         dt          -- DATE is not a good column name
             FROM    table2
         )          src
    ON     (dst.unique_id     = src.unique_id)
    WHEN MATCHED THEN UPDATE
    SET     dst.name     = src.name
    ,     dst.status     = src.status
    ,     dst.dt          = src.dt
    ;Unlike UPDATE, this lets you avoid essentially doing the same sub-query twice: once in the SET clause and then again in the WHERE clause.
    Like UPDATE, you don't acutally join the table being changed (table3 in this case) to the other table(s); that is, the FROM clause of the suib-query does not include table3.
    Riedelme is right; you'll get better response to SQL questions like this in the SQL and PL/SQL forum:
    PL/SQL

  • I have misplaced my iPod Touch 4th Generation. According to Find my iPhone, it should show up in offline mode. I need help on locating it with a software or some other way. Help?

    I have misplaced my iPod Touch 4th Generation. According to Find my iPhone, it should show up in offline mode. I need help on locating it with a software or some other way. Help?

    There is no other way.
    Sorry

  • Need help on struts configuration with ColdFusion 10 using IIS

    We need help on struts configuration with ColdFusion 10 using IIS.
    Earlier we were using ColdFusion 8 with IIS 6 for one of our application.  This application internally calls struts. After upgrading to ColdFusion 10 struts calls are not loading. We get 404 error.
    In ColdFusion 8 struts were configured using  actions extension .do in IIS from this file-
    C:\ColdFusion8\runtime\lib\wsconfig\jrun_iis6.dll.
    But in ColdFusion 10 this file is not present as ColdFusion 10 uses Tomcat in place of Jrun.
    Also there is no information in ColdFusion log file.

    Duane wrote:
    doctormirabilis, Welcome to the discussion area!
    1) how can i configure the time capsule in order to operate as a remote base station synchronizing with the relay using the ethernet port?
    Configure the Time Capsule to act as a bridge (not distributing IP addresses). Also configure the Time Capsule to create an 802.11n wireless network with a unique network name (SSID). That's it.
    2) how can i avoid that my powerbook while accessing my wireless network does connect through the relay station instead of using the time capsule?
    Configure the Time Capsule to use a different network name than the WDS link between the 2 AirPort Express (AX). Configure the PowerBook to use the Time Capsule network.
    There are 2 pieces of information that you should be aware of...
    (1) None of the PowerBooks are capable of 802.11n.
    (2) The WDS link cuts your available bandwidth in half. So the wireless link to your neighbor's has a maximum potential of 27 Mbps.
    Let's for a minute assume that you have a Mac compatible with 802.11n. In your configuration the time you could take advantage of the 802.11n speed is when the Mac is sending/recieving data directly from/to the Time Capsule.
    There would be NO speed increase in Internet access. The speed of Internet access is going to be controlled by the slowest link in the path to the Internet. That is probably the connection to the ISP. The next slowest path is the WDS link to your neighbor's.
    Duane,
    I am in a similar situation, sharing internet with my neighbor. Do you think it would be plausible to hook up a vonage phone adapter to time capsule's ethernet port if time capsule is bridging from my neighbor's router in the configuration you have described? A check of my upload speed shows 1.67Mbps (powerbookG4 w/ airport extreme). Vonage reccommends 90kbps minimum upload speed. Am I going to lose some speed putting the Vonag adapter behind time capsule?
    Thank you

  • Need help re-synching iPods with new computer and getting iTunes to...

    Need help re-synching iPods with new computer and getting iTunes to recognize our iPods (it doesn't even recognize them when they're plugged in).
    Hubby wiped my harddrive for me, so now I need to get everything back in proper places. I'm using windows XP and installed iTunes once again (I believe it's version 8). I also installed all of my iTunes songs. Now I need to know where to go from here. We have 3 iPods and I need to get them all synched once again. I know how to create different libraries for each of us, but I can't figure out how to get our songs back into our iTunes libraries. When I open iTunes and plug in an iPod, iTunes doesn't even show that an iPod is plugged in.
    What do I do now to get each of our iPods synched with our own libraries?
    TIA
    Brandy

    Thanks Zevoneer. The "Restart ipod service" worked and itunes is now recognizing my ipod! Hooray!
    Okay, now how do I synch all of our ipods with our individual libraries (I don't want all of my kids' songs and vice versa)? We each have hundreds of songs on our ipods that we don't want to lose.
    Thanks again!

  • Update statement, with dups

    This query has worked well for me, but now, the driving table (tt) has duplicates in it, because of a database upgrade and the client wants to keep the duplicates there is value to them there...
    The problem is that now I get, you guessed it: ORA-01427: single-row subquery returns more than one row
    I need help to update so that it can handle the more than one row, duplicates are ok.
    UPDATE /*+ PARALLEL (16) */ UPDATE_TABLE_07092011  ta
                         SET (ta.GO_TO_PERSON, ta.UPDATE_DT) =
                                       (SELECT /*+ PARALLEL (16) */ tt.GO_TO_PERSON, SYSDATE
                                        FROM DRIVER_TABLE tt
                                        WHERE ta.cust_id = tt.cust_id
                                        AND ta.STAMP_DATE = tt.STAMP_DATE)
                          WHERE EXISTS (SELECT 1
                                       FROM  DRIVER_TABLE tt
                                       WHERE ta.cust_id = tt.cust_id
                                       AND ta.STAMP_DATE = tt.STAMP_DATE
                                       AND (NVL(ta.GO_TO_PERSON, 'X') != NVL(tt.GO_TO_PERSON, 'X')));Edited by: Kodiak_Seattle on May 10, 2012 11:04 AM

    How about adding "AND ROWNUM = 1" to the first subquery ?

  • Update Statement with group by query

    I need to an update statement that updates the records return from this query:
    SELECT
    GROUP,
    SECTION,
    MAX(ASSIGNED_DATE)
    FROM
    ASSIGNMENTS
    GROUP BY GROUP, SECTION
    I need to update all those records and set HISTORY = 1
    I'm not sure how to form the update statement.
    UPDATE ASSIGNMENTS SET HISTORY = 1 WHERE (SELECT
    GROUP,
    SECTION,
    MAX(ASSIGNED_DATE)
    FROM
    ASSIGNMENTS
    GROUP BY GROUP, SECTION) ?
    Edited by: user9179751 on Apr 18, 2011 11:23 AM

    Just doing a select query: (these are the records that were updated when I ran the update statement you posted)
    SELECT * FROM ASSIGNMENS WHERE (GROUP, SECTION, ASSIGNED_DATE) IN (SELECT GROUP,
    SECTION, MAX(ASSIGNED_DATE)FROM ASSIGNMENTS GROUP BY GROUP, SECTION)
    Records:
    GROUP SECTION    ASSIGNED_DATE
    0010        050098       20011108
    0334    000003       19980116
    0505        320000       20000712
    0676        380000       19980914
    0676        067931       20011221
    0801        600500       19910409
    0801    601701       20090903These are the records I want updated:
    Which I would get using:
    SELECT GROUP, SECTION, MAX(ASSIGNED_DATE)FROM ASSIGNMENTS GROUP BY GROUP, SECTION
    GROUP SECTION ASSIGNED_DATE
    0002                  20100519
    0003                  20090724
    0005          
    0007       360000     
    0007                  20040913
    0009                  19970814
    0010       050098     20011108
    0010                  20000926
    0011          I'm assuming it skips over null values?

  • Need Help ASAP  my State tax form is in a PDF file and the attachment in my email says Please wait

    Need Help ASAP  my State tax form is in a PDF file and the attachment in my email says Please wait...
    I tried downloading updates like it said to but it still will not display the document.  How do I print the PDF file ASAP

    Can you give us a LOT more info?
    What email client? What version of Reader (I can only assume you even have Reader at this point)?
    Please wait? I'm sure it says more than that, right?
    Have you tried simply saving the PDF (it IS a PDF correct?) to your desktop and opening it from there?
    Did you get this form from the IRS or did it come from somewhere else? If the IRS again, what version of Reader?
    Help us help you.

  • HT4623 I need help ASAP updating my jailbroken iPod touch 4th generation

    I have a 4th generation iPod that's jailbroke by Cydia, I need help to update it to IOS 6. From my ipod

    You can't, over-the-air update did not become available until iOS 5, you show iOS 4.1.
    And we cannot discuss jailbroken devices here per the moderators.

  • Please i need help i updated my iphone 3gs and now its not activating

    i need help i updated my iphone 3gs and now its not activating

    What happens when you try to activate the iPhone?
    If there is an error message, what is the exact wording of that message?

  • Need help for Update and cancel SalesOrder

    Hi All,
    I  written java code for create sales order based on salesquotation,now i want to update and cancel sales order ,i need help to update and cancel salesorder.
    can give any related links for update and cancel salesorder.
    Thanks and Regards,
    Srinivas

    Hi srinivas.L
    It is simple, here is some sample code. You must use getbykey to get the document. Then once you got it you can make whatever changes you need. Then update it. where i have oOrder.Update() you can have oOrder.cancel
    Dim oOrder As SAPbobsCOM.Documents
            oOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
            If oOrder.GetByKey(530) Then
                oOrder.Lines.SetCurrentLine(1)
                oOrder.Lines.WarehouseCode = "01"
                If oOrder.Update() <> 0 Then
                    MsgBox(oCompany.GetLastErrorDescription)
                End If
            Else
                MsgBox("Nothing found")
            End If
    Hope this helps

  • Need help to write a query for Update statement with  join

    Hi there,
    The following update statement gives me error as the given table in set statement is invalid. But its the right table .
    Is the statement correct? Please help .
    update (
           select distinct(vpproadside.VEHICLE_CRED_OVERRIDE.vin)            
             from vpproadside.VEHICLE_CRED_OVERRIDE
             join vpproadside.vpp_vehicle
               on vpproadside.vpp_vehicle.vin = vpproadside.VEHICLE_CRED_OVERRIDE.vin
            where VPP_CARRIER_SEQ_NUMBER = 90
              and EXPIRY_DATE = '17-MAR-10'
       set vpproadside.VEHICLE_CRED_OVERRIDE.EXPIRY_DATE = '15-SEP-10';Edited by: Indhu Ram on Mar 12, 2010 1:00 PM
    Edited by: Indhu Ram on Mar 12, 2010 1:22 PM
    Edited by: Indhu Ram on Mar 12, 2010 2:35 PM
    Edited by: Indhu Ram on Mar 15, 2010 8:04 AM
    Edited by: Indhu Ram on Mar 15, 2010 8:06 AM
    Edited by: Indhu Ram on Mar 15, 2010 8:28 AM

    Ask Tom has very good discussion about this, if UPDATE does not work for PK issue, you can use MERGE
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:760068400346785797

  • Help needed with Update statements.

    Hello All,
    I am trying to learn Berkeley XMLDB and facing problem to query the inserted XML file. I have a small XML file with the following contents:
    &lt;?xml version="1.0" standalone="yes"?&gt;
    &lt;Bookstore&gt;
    &lt;Book&gt;
    &lt;book_ID&gt;1&lt;/book_ID&gt;
    &lt;title&gt;Harry Potter and the Order of the Phoenix&lt;/title&gt;
    &lt;subtitle&gt;A Photographic History&lt;/subtitle&gt;
    &lt;author&gt;
    &lt;author_fname&gt;J.K.&lt;/author_fname&gt;
    &lt;author_lname&gt;Rowling&lt;/author_lname&gt;
    &lt;/author&gt;
    &lt;price&gt;9.99&lt;/price&gt;
    &lt;year_published&gt;2004&lt;/year_published&gt;
    &lt;publisher&gt;Scholastic, Inc.&lt;/publisher&gt;
    &lt;genre&gt;Fiction&lt;/genre&gt;
    &lt;quantity_in_stock&gt;28997&lt;/quantity_in_stock&gt;
    &lt;popularity&gt;20564&lt;/popularity&gt;
    &lt;/Book&gt;
    &lt;/Bookstore&gt;
    When I try to update the TITLE of this node I have the following error message:
    C:\Users\Chandra\Desktop\BDB&gt;javac -classpath .;"C:\Program Files\Sleepycat Soft
    ware\Berkeley DB XML 2.1.8\jar\dbxml.jar";"C:\Program Files\Sleepycat Software\B
    erkeley DB XML 2.1.8\jar\db.jar" bdb.java
    bdb.java:75: illegal start of expression
    public static final String STATEMENT1 = "replace value of node collection("twopp
    ro.bdbxml")/Bookstore/Book/bookid/title with 'NEWBOOK'";
    ^
    bdb.java:80: ')' expected
    System.out.println("Done query: " + STATEMENT1);
    ^
    2 errors
    But when I remove the update statements and just try to display the TITLE of this node, I dont see any outputs. Please help me to catch up with my mistakes. Below is source code I am using to run this functionality.
    Thanks.
    import java.io.File;
    import java.io.FileNotFoundException;
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.Environment;
    import com.sleepycat.db.EnvironmentConfig;
    import com.sleepycat.dbxml.XmlContainer;
    import com.sleepycat.dbxml.XmlException;
    import com.sleepycat.dbxml.XmlInputStream;
    import com.sleepycat.dbxml.XmlManager;
    import com.sleepycat.dbxml.XmlUpdateContext;
    import com.sleepycat.dbxml.XmlDocument;
    import com.sleepycat.dbxml.XmlQueryContext;
    import com.sleepycat.dbxml.XmlQueryExpression;
    import com.sleepycat.dbxml.XmlResults;
    import com.sleepycat.dbxml.XmlValue;
    public class bdb{
    public static void main(String[] args)
    Environment myEnv = null;
    File envHome = new File("D:/xmldata");
    try {
    EnvironmentConfig envConf = new EnvironmentConfig();
    envConf.setAllowCreate(true); // If the environment does not
    // exits, create it.
    envConf.setInitializeCache(true); // Turn on the shared memory
    // region.
    envConf.setInitializeLocking(true); // Turn on the locking subsystem.
    envConf.setInitializeLogging(true); // Turn on the logging subsystem.
    envConf.setTransactional(true); // Turn on the transactional
    envConf.setRunRecovery(true);
    // subsystem.
    myEnv = new Environment(envHome, envConf);
    // Do BDB XML work here.
    } catch (DatabaseException de) {
    // Exception handling goes here
    } catch (FileNotFoundException fnfe) {
    // Exception handling goes here
    } finally {
    try {
    if (myEnv != null) {
    myEnv.close();
    } catch (DatabaseException de) {
    // Exception handling goes here
    XmlManager myManager = null;
    XmlContainer myContainer = null;
    // The document
    String docString = "D:/xmldata/test.xml";
    // The document's name.
    String docName = "cia";
    try {
    myManager = new XmlManager(); // Assumes the container currently exists.
    myContainer =
    myManager.createContainer("twoppro.bdbxml");
    myManager.setDefaultContainerType(XmlContainer.NodeContainer); // Need an update context for the put.
    XmlUpdateContext theContext = myManager.createUpdateContext(); // Get the input stream.
    XmlInputStream theStream =
    myManager.createLocalFileInputStream(docString); // Do the actual put
    myContainer.putDocument(docName, // The document's name
    theStream, // The actual document.
    theContext, // The update context
    // (required).
    null); // XmlDocumentConfig object
    theStream.delete();
    // Update the title
    public static final String STATEMENT1 = "*replace value of node collection("twoppro.bdbxml")/Bookstore/Book/[bookid=1]/title with 'NEWBOOK'";*
    XmlQueryContext context = myManager.createQueryContext();
    XmlQueryExpression queryExpression1 = myManager.prepare(STATEMENT1, context);
    System.out.println("Try to execute query: " +
    System.out.println("Done query: " + STATEMENT1);
    queryExpression1.execute(context);
    // Get a query context
    XmlQueryContext context = myManager.createQueryContext();
    // Set the evaluation type to Lazy.
    context.setEvaluationType(XmlQueryContext.Lazy);
    // Declare the query string
    String queryString =
    "for $u in collection('twoppro.dbxml')/Bookstore/Book/[bookid=1]"
    + "*return $u/title";*
    // Prepare (compile) the query
    XmlQueryExpression qe = myManager.prepare(queryString, context);
    XmlResults results = qe.execute(context);
    System.out.println("ok");
    System.out.println(results);
    } catch (XmlException e) {
    // Error handling goes here. You may want to check
    // for XmlException.UNIQUE_ERROR, which is raised
    // if a document with that name already exists in
    // the container. If this exception is thrown,
    // try the put again with a different name, or
    // use XmlModify to update the document.
    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } finally {
    try {
    if (myContainer != null) {
    myContainer.close();
    if (myManager != null) {
    myManager.close();
    } catch (XmlException ce) {
    // Exception handling goes here

    Thanks Rucong. The change you suggested did helped me to run the program correct. But I also have the display function to retrive the results and my program is parsed without any output.
    C:\Users\C\Desktop\BDB&gt;Clientbuild.bat
    C:\Users\C\Desktop\BDB&gt;javac -classpath .;"C:\Program Files\Sleepycat Soft
    ware\Berkeley DB XML 2.1.8\jar\dbxml.jar";"C:\Program Files\Sleepycat Software\B
    erkeley DB XML 2.1.8\jar\db.jar" bdb.java
    C:\Users\C\Desktop\BDB&gt;Client.bat
    C:\Users\C\Desktop\BDB&gt;java -classpath .;"C:\Program Files\Sleepycat Softw
    are\Berkeley DB XML 2.1.8\jar\dbxml.jar";"C:\Program Files\Sleepycat Software\Be
    rkeley DB XML 2.1.8\jar\db.jar" bdb
    See there is no OUPUT displayed. Is there somethinglike a 'print' I have to use in this java code.
    Any ideas ? Below is the code I am using now
    import java.io.File;
    import java.io.FileNotFoundException;
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.Environment;
    import com.sleepycat.db.EnvironmentConfig;
    import com.sleepycat.dbxml.XmlContainer;
    import com.sleepycat.dbxml.XmlException;
    import com.sleepycat.dbxml.XmlInputStream;
    import com.sleepycat.dbxml.XmlManager;
    import com.sleepycat.dbxml.XmlUpdateContext;
    import com.sleepycat.dbxml.XmlDocument;
    import com.sleepycat.dbxml.XmlQueryContext;
    import com.sleepycat.dbxml.XmlQueryExpression;
    import com.sleepycat.dbxml.XmlResults;
    import com.sleepycat.dbxml.XmlValue;
    public class bdb{
    public static void main(String[] args)
    Environment myEnv = null;
    File envHome = new File("D:/xmldata");
    try {
    EnvironmentConfig envConf = new EnvironmentConfig();
    envConf.setAllowCreate(true); // If the environment does not
    // exits, create it.
    envConf.setInitializeCache(true); // Turn on the shared memory
    // region.
    envConf.setInitializeLocking(true); // Turn on the locking subsystem.
    envConf.setInitializeLogging(true); // Turn on the logging subsystem.
    envConf.setTransactional(true); // Turn on the transactional
    envConf.setRunRecovery(true);
    // subsystem.
    myEnv = new Environment(envHome, envConf);
    // Do BDB XML work here.
    } catch (DatabaseException de) {
    // Exception handling goes here
    } catch (FileNotFoundException fnfe) {
    // Exception handling goes here
    } finally {
    try {
    if (myEnv != null) {
    myEnv.close();
    } catch (DatabaseException de) {
    // Exception handling goes here
    XmlManager myManager = null;
    XmlContainer myContainer = null;
    // The document
    String docString = "D:/xmldata/test.xml";
    // The document's name.
    String docName = "cia";
    try {
    myManager = new XmlManager(); // Assumes the container currently exists.
    myContainer =
    myManager.createContainer("twoppro.bdbxml");
    myManager.setDefaultContainerType(XmlContainer.NodeContainer); // Need an update context for the put.
    XmlUpdateContext theContext = myManager.createUpdateContext(); // Get the input stream.
    XmlInputStream theStream =
    myManager.createLocalFileInputStream(docString); // Do the actual put
    myContainer.putDocument(docName, // The document's name
    theStream, // The actual document.
    theContext, // The update context
    // (required).
    null); // XmlDocumentConfig object
    theStream.delete();
    // Update the title
    String STATEMENT1 = "for $n in collection('twoppro.bdbxml')/Bookstore/Book[book_ID=1]/title return replace value of node $n with 'NEWBOOK'";
    XmlQueryContext context = myManager.createQueryContext();
    XmlQueryExpression queryExpression1 = myManager.prepare(STATEMENT1, context);
    System.out.println("Done query: " + STATEMENT1);
    queryExpression1.execute(context);
    // Get a query context
    XmlQueryContext thiscontext = myManager.createQueryContext();
    // Set the evaluation type to Lazy.
    context.setEvaluationType(XmlQueryContext.Lazy);
    // Declare the query string
    String queryString =
    "for $u in collection('twoppro.dbxml')/Bookstore/Book/[bookid=1]"
    + "return $u/title";
    // Prepare (compile) the query
    XmlQueryExpression qe = myManager.prepare(queryString, thiscontext);
    XmlResults results = qe.execute(thiscontext);
    System.out.println("ok");
    System.out.println(results);
    } catch (XmlException e) {
    // Error handling goes here. You may want to check
    // for XmlException.UNIQUE_ERROR, which is raised
    // if a document with that name already exists in
    // the container. If this exception is thrown,
    // try the put again with a different name, or
    // use XmlModify to update the document.
    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } finally {
    try {
    if (myContainer != null) {
    myContainer.close();
    if (myManager != null) {
    myManager.close();
    } catch (XmlException ce) {
    // Exception handling goes here
    Thanks.

Maybe you are looking for

  • Can't type anythings in console mode

    i can see all booting process in CLI mode but can't type anything. Pls help me this.

  • Excise invoice SL No not coming

    Dear Guru In SAP at the time of Outgoing Excise Invoice Serial No.generating (TCODE-J1IIN) some times  instead of regular SL No. it generate different No. How it possible, this is client issue. Thanks in advance Satya

  • Acrobat 6 - Save As - Removing Unused Objects

    When using the "Save As" feature to save from a mapped network drive to the personal drive, documents that are created from a scanned image take a long time to save, and on the progress bar show the message "Removing Unused Objects".  My client is us

  • Can't add simulated SCXI chassis in MAX

    Hi all I wanted to test some hardware by simulating it on my workstation.  I'm using Labview 8.2 and MAX 4.1.0 When I try and simulate the SCXI 1000 chassis, the first dialog box appears with the chassis communicator dropdown control greyed out.  The

  • Compilation Error on Launch.aspx after Update from SP2 to SP4

    Hi experts, I have installed BPC 5.1 SP 2, SP 3 and also SP 4 on a Testmachine and do not have problems with it. On the productive machine at the customer HTTPS was not working with SP3 after upgrading, with SP2 HF1 it worked fine. (We reinstalled th