How can i update rows  in a table based on a match from a select query

Hello
How can i update rows in a table based on a match from a select query fron two other tables with a update using sqlplus ?
Thanks Glenn
table1
attribute1 varchar2 (10)
attribute2 varchar2 (10)
processed varchar2 (10)
table2
attribute1 varchar2 (10)
table3
attribute2 varchar2 (10)
An example:
set table1.processed = "Y"
where (table1.attribute1 = table2.attribute1)
and (table1.attribute2 = table3.attribute2)

Hi,
Etbin wrote:
Hi, Frank
taking nulls into account, what if some attributes are null ;) then the query should look like
NOT TESTED !
update table1 t1
set processed = 'Y'
where exists(select null
from table2
where lnnvl(attribute1 != t1.attribute1)
and exists(select null
from table3
where lnnvl(attribute2 != t1.attribute2)
and processed != 'Y'Regards
EtbinYes, you could do that. OP specifically requested something else:
wgdoig wrote:
set table1.processed = "Y"
where (table1.attribute1 = table2.attribute1)
and (table1.attribute2 = table3.attribute2)This WHERE clause won't be TRUE if any of the 4 attribute columns are NULL. It's debatable about what should be done when those columns are NULL.
But there is no argument about what needs to be done when processed is NULL.
OP didn't specifically say that the UPDATEshould or shouldn't be done on rows where processed was already 'Y'. You (quite rightly) introduced a condition that would prevent redo from being generated and triggers from firing unnecessarily; I'm just saying that we have to be careful that the same condition doesn't keep the row from being UPDATEd when it is necessary.

Similar Messages

  • How can I update Camera raw for Photoshop CS5 to access images from Canon Rebel T4i?

    How can I update Camera Raw for Photoshop CS5 to access images from Canon Rebel T4i? The updated version of Camera Raw 7 says it only works with CS6. Outside of buying a new Photoshop, is there anything I can do?

    Buy Lightroom (much cheaper alternative to Photoshop) - does all your 'Photo-related' tasks. Full version of LightRoom 4 is $149/- - http://www.adobe.com/products/photoshop-lightroom.html
    LightRoom 4 supports ACR (Adobe Camera Raw) 7. Once processed with Lightroom, if you still need, you could take the photo in JPG or TIFF format into Photoshop CS5 for further processing.
    Another option is to use Canon Raw Codec that would've come with your camera's box to process the RAW images and then take them into Photoshop.

  • How can i update more than one table at a time?

    i would like to update more than one table at a time. In Java Studio creator2 how can i do table updation?

    Hi,
    Please go through the below thread might be of help to you.
    http://forum.sun.com/jive/thread.jspa?forumID=123&threadID=51839
    RK

  • How can I delete rows in a table from the bottom?

    I have table that I add rows to and I want to remove rows starting with the last row. For example if I have a table with 20 rows how do I remove rows 16-20. I can't figure out how to do this.

    The following script would/should/might delete the last 4 rows of a subform named 'itemsSub' : (or actually deletes the last row 4 times hopefully!)
    for (var f = 0; f<4; f++)
    _itemsSub.removeInstance(itemsSub.all.length - 1);

  • How can I add rows to a JTable based on an Abstract Table Model?

    I have done this ...
    public class myui extends JPanel {
    private AbstractTableModel jTable1Model;
    blah blah
            jTable1Model = new AbstractTableModel() {
                 String[] column = new String[]{"TID", "Name", "Address"};
                 Vector<Vector<Object>> table = new Vector<Vector<Object>>();
                 @Override
                 public int getRowCount() {
                      return table.size();
                 @Override
                 public int getColumnCount() {
                      return column.length;
                 @Override
                 public String getColumnName(int col) {
                      return column[col];
                 @Override
                 public Object getValueAt(int row, int column) {
                      return table.get(row).get(column);
                 @Override
                 public void setValueAt(Object value, int row, int column) {
                      table.get(row).set(column, value);
                      fireTableCellUpdated(row, column);
                 public void insertRow() {
                      Vector<Object> columns = new Vector<Object>();
                      columns.add(null);columns.add(null);columns.add(null);
                      table.add(columns);
                      fireTableRowsInserted(0, table.size());
    blah blah
        public synchronized void ImportVisitorDataToJTable1(Object value, int row, int col) {
            jTable1Model.InsertRow();  <-----///// This line not being recognised as a valid member function call
           jTable1.setValueAt(value, row, col);
    }I thought to insert a row I can define a function in the abstracttablemodel class and then instantiate the class and override or create new methods that I can use.
    But after instantiating the class and overriding appropriately and adding the insertRow function, when I try to use it in ImportVisitorDataToJTable1 as seen above its not being recognized as a funtion of jTable1Model

    1. respect naming conventions. Example: myui --> MyUI, ImportVisitorDataToJTable1 -->importVisitorDataToJTable1
    2. convert Anonymous to Member: AbstractTableModel --> MyTableModel
    3. row parameter makes no sense here as it depends on current row count:
        public synchronized void importVisitorDataToJTable1(Object value, int col) {
            int row = jTable1Model.getRowCount();4. here is a more adequate "fireTable.."-call for insertRow:
    fireTableRowsInserted(table.size() - 1, table.size() - 1);
    5. check if you can take advantage using DefaultTableModel as suggested by Maxideon.

  • When doing a MERGE in Oracle SQL, how can I update rows that aren't matched

    Hi,
    create table TEST1
    History_date Date,
    ID NUMBER not null
    create table TEST2
    ID NUMBER not null,
    History_date Date,
    We_history_date Date
    Can we do like this...
    merge into test2 t2
    using
    test1 t1
    ON (t1.id = t2.id)
    when matched
    update set t2.We_history_date = t1.history_date
    when not matched
    update set t2.We_history_date = NVL(t2.we_history_date,SYSDATE);Thanks,
    Edited by: 960736 on Sep 27, 2012 2:05 PM

    There is nothing to update if there is no match.
    You need to INSERT a new record.
    See the Examples section of the MERGE statement in the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm
    >
    Examples
    Merging into a Table: Example The following example uses the bonuses table in the sample schema oe with a default bonus of 100. It then inserts into the bonuses table all employees who made sales, based on the sales_rep_id column of the oe.orders table. Finally, the human resources manager decides that employees with a salary of $8000 or less should receive a bonus. Those who have not made sales get a bonus of 1% of their salary. Those who already made sales get an increase in their bonus equal to 1% of their salary. The MERGE statement implements these changes in one step:
    MERGE INTO bonuses D
    USING (SELECT employee_id, salary, department_id FROM employees
    WHERE department_id = 80) S
    ON (D.employee_id = S.employee_id)
    WHEN MATCHED THEN UPDATE SET D.bonus = D.bonus + S.salary*.01
    DELETE WHERE (S.salary > 8000)
    WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus)
    VALUES (S.employee_id, S.salary*.01)
    WHERE (S.salary <= 8000);

  • Please!!!!!!   How can i add rows in html table dynamically [use jsp,bean]

    hello, i am a fresher in jsp. i want to add new rows in html table dynamically.In my coding, just only shows in one row . please help my problem with correct coding and i don't want to use database. Thanks ...............!
    Here is my coding-------------------
    ---------------- form.jsp --------------------->
    <%@ page import="java.util.*,newtest1.Validation" %>
    <jsp:useBean id="mybean" scope="page" class="newtest1.Validation" />
    <jsp:setProperty name="mybean" property="name" param="name" />
    <jsp:setProperty name="mybean" property="age" param="age" />
    <% s[i][j] %>
    <html>
    <head><title>Form</title></head>
    <body>
    <form method="get">
    <table border="0" width="700">
    <tr>
    <td width="150" align="right">Name</td>
    <td width="550" align="left"><input type="text" name="name" size="35"></td>
    </tr>
    <tr>
    <td width="150" align="right">Age</td>
    <td width="550" align="left"><input type="text" name="age" size="35"></td>
    </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="5">
    <tr><td> </td></tr>
    <tr><td><input type="submit" name="submit" value="ADD"></td></tr>
    <tr><td> </td></tr>
    <tr><td width="100%" align="center" border=1>
    <% int count=mybean.getStart();
    for(int i=count; i<count+1; i++) { %>
    <tr>
    <td><jsp:getProperty name="mybean" property="name" /></td>
    <td><jsp:getProperty name="mybean" property="age" /></td>
    <td><%= count %></td>
    <% count+=1; %>
    </tr>
    <% } %></td></tr>
    </table>
    </form>
    </body>
    </html>
    ----------------- Validation.java ----------------->
    package newtest1;
    import java.util.*;
    public class Validation {
    private String name;
    private String age;
    static int start=0;
    public Validation() {    name=null;
    age=null;
    ++start;}
    public void setName(String username) { if(username!="")
    name=username;
    public String getName() { return name;  }
    public void setAge(String userage) {  if (age!="")
    {age=userage;}
    public String getAge() {  return age;   }
    public int getStart() {
    return start; }

    Hi, Do you mean to say,
    You have an HTML page in which you have a text field and an add button. If you enter anything in that text field and click on Add button the text field contents should be displayed in the same HTML page and you should be able to go on entering new values into the text field and you should be able to retain and display all the previously entered values..
    and finally the list of added items are not stored in the database..
    If this is the case
    i. Your html form should be submitted to the same page.
    ii. You need to have a Vector which holds the entered values.
    iii. Bind the vector object to the request object and collect the same vector object from the request and display its contents...
    I think this would help...

  • Update row in a table based on join on multiple rows in another table

    I am using SQL Server 2005. I have the following update query which is not working as desired.
    UPDATE DocPlant
    SET DocHistory = DocHistory + CONVERT(VARCHAR(20), PA.ActionDate, 100) + ' - ' + PA.ActionLog + '. '
    FROM PlantDoc PD INNER JOIN PlantAction PA on PD.DocID = PA.DocID AND PD.PlantID = PA.PlantID 
    For each DocID and PlantID in PlantDoc table there are multiple rows in PlantAction table. I would like to concatenate ActionDate and ActionLog information into DocHistory column of DocPlant table. But the above update query is considering only one row from
    PlantAction table even though there are multiple rows that match with DocID and PlantID.
    DocHistory column is of type NVARCHAR(MAX).
    How do I fix my query to achieve what I want ? Thanks for the help.

    UPDATE DocPlant
    SET DocHistory = DocHistory + CONVERT(VARCHAR(20), PA.ActionDate, 100) + ' - ' + PA.ActionLog + '. '
    FROM PlantDoc PD INNER JOIN PlantAction PA on PD.DocID = PA.DocID AND PD.PlantID = PA.PlantID 
    We do not use the old Sybase UPDATE..FROM.. syntax. Google it and learn how it does not work. We do not use the old Sybase CONVERT() string function. You are still writing 1950's COBOL with string dates instead of temeproal data types. 
    You also did not post DDL, so we have to guess about everything. Does your boss make you work without DDL? How do you do it? 
    >> For each DocID and PlantID in PlantDoc table there are multiple rows in PlantAction [singular name?] table. I would like to concatenate ActionDate and ActionLog information into DocHistory column of DocPlant table. <<
    Why? What does this new data element mean? This is like dividing Thursday by Red and expecting a reasonable answer. Now, non-SQL programmers who are still writing COBOL will violate the tiered architecture rule about doing display formatting in the database.
    If you will follow forum rules, we can help you. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How can i update all column of table without know it's structure

    hi to all
    i want to make update to all columns of table with record type of this table
    ex- consider the emp table and contain any number of columns
    and you make record is row type of this table (emp) as emp_rec
    and fech in it any record by select * from emp
    and i want to update another record this the return record from data base as
    update emp by using the emp_rec
    i want to know how this will be acheive

    It is all written in the docs:
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/collections.htm#i20479
    Although updating all columns for a table is VERY, VERY BAD practice.
    Gints Plivna
    http://www.gplivna.eu

  • HT4972 How can i update my ipad first generation with ios 7.0 from 5.0

    I need to download banking apps and facebook but it wont let me without updating to 7.0.1. or whatever it is .... i tried to update and it says i have the most current version of the IOS.

    Sorry but it the end of the road  for the ipad 1  IOS. 5.1.1 is has far has it can be upgrade two
    Time two move on and upgrade two ipad 2   Or get the ipad mini 2. Or ipad air.  

  • How can we reduce Row Chaining?

    In a 10gR2 db, how can i reduce row chaining in tables?

    Hi,
    First, the prevention techniques for chained rows vs. migrated rows is a bit different. Note that both chained rows and migrated (relocated) rows manifest as "table fetch continued row" in v$sysstat and stats$sysstat for STATSPACK and dba_hist_sysstat for AWR.
    Preventing chained rows - Chained rows can occur when a row is to large for a data block. In these cases, moving large objects into a tablespace with a larger blocksize can often relieve chained rows.
    Preventing migrated rows - Migrated rows occur when a row expands (usually w2ith a varchar2 data type), and there is not enough reserve defined by PCTFREE for the row to expand. In this case, you adjust the PCTFREE to ensure that future rows will have room to expand and reorganize the table to remove the fragments.
    On some tables which are stored tiny and grow huge, you may need to set PCTFREE to a "large" value, so that only one row is stored per block. For example, if I have a row with a varchar2 that is stored at 2k and grows to 30k, I would need to use a 32k blocksize and set PCTFREE=95 so that only one rows is stored on each data block. That way, at update time, there will be room for the row to expand without fragmenting.
    Operationally, Oracle consultant Steve Adams offers this tip for finding the difference between chained and migrated rows:
    http://www.freelists.org/archives/oracle-l/10-2008/msg00750.html
    +"You can tell the difference between row migration and chaining by listing the chained rows with ANALYZE table LIST CHAINED ROWS and then fetching the first column from each "chained row" in a single query.+
    +The count of continued row fetches will be incremented for every migrated row, but not for most chained rows (unless the first cut point happens to fall with the first column, which should be rare)."+
    Hope this helps . . .
    Donald K. Burleson
    Oracle Press author
    Author of "Oracle Tuning: The Definitive Reference"
    http://www.rampant-books.com/book_2005_1_awr_proactive_tuning.htm

  • How can I update software on iPhone 3g from ios 3.1.3 to ios 4?

    Recently been given an iPhone 3g. I had to restore the phone to sync to my iTunes. Now a lot of apps will not download as I need at least iOS 4 but the phone is iOS 3. iTunes tells me that this is the latest software for this model when I check for updates. Is there anyway to update to iOS 4?

    The iPhone in question, iPhone 3g is running software version ios 3.1.3, my current iTunes is running 10.6.3. How can I update the software on said iPhone to iOS 4 from 3.1.3 if iTunes informs me that the current software is up to date.
    The iPhone has pretty much been rendered useless as I can not download majority of apps. Therefore it just works as a pretty basic phone.

  • How can i update my app with i tunes?not by my device.

    how can i update my app with i tunes?not by my device.

    Select Apps in iTunes sidebar. A list of all your apps should be displayed in the main window. At bottom right of the window is a Check for updates button. Click on it, then click to download the updated apps. It's also possible that iTunes checked for updatedin the background, in which case the check button will already display how many updates you have.

  • HT5457 I do not have software updates on my iPad 2. How can I update

    I would like to update my iPad 2 to iOS 6 but there is nothing in settings for software updates. The support site shows that there is an icon under general just below "about" but this does not exist on my settings. How can I update if I don't have this feature?

    From iTunes on a computer.
    (77188)

  • How to find newly updated rows in a table

    Hi..
    How to know newly updated rows in a table.
    Thanks in advance
    pal

    Or other good thing would be to add LAST_UPDATED column to your table, that can reflect the time the row gets updated.
    G

Maybe you are looking for

  • How to create diferents deliveries for each schedule line

    Dear gurus, I have sales orders with many schedule lines in order to deliver in diferents dates. We need to create all the deliveries together but each schedule line needs to be in a diferent delivery with the corresponding delivery date. I analiced

  • I want to Install Windows 8 Pro with Bootcamp

    I have Windows 8 running currently on Parellals 8. I cannot enter my product key for Windows yet but can use my flight simulater which works perfectly. I have tried to install Windows 8 using bootcamp (just to keep up to date) but keep getting the er

  • Running apex_util.get_print_document with APEX_MAIL

    I am trying to automate the running of an apex_util.get_print_document, emailing the output to my users. When the job tries to run I get this error in the log: ORA-20022: Null value supplied for parameter p_attachment. ORA-06512: at "FLOWS_030100.WWV

  • Segmentation fault while updateing [SOLVED]

    Hello all, I got this probem a few days ago, trying to run 'pacman -syu' ends in a segmentation fault. I have no clue what to do abou it.. I first tryed to update zlib manual as it was last in the list, worked fine. So i tryed wine and trying to upda

  • Changing screen name in pidgin

    i got the pidgin contacts and conversations add-on, which is working great. i went to settings, VoIP and changed the display name, but it isn't changing in the actual conversation. any suggestions?