Need to update a column

Hi guys
I have to update a single column for around 300 id's
so apart from writing update statment for all id's or putting where condition for ID's in
Is there any other way of doing this
for say like this
Update table
set status = 's'
where id in ('Some 300 id's')Please suggest
Thanks

Hi,
The IN operator can handle up to 1000 items before you have to do anything special, so there's no problem with:
Update  table
set     status = 's'
where   id in ('A001', 'A002'. 'A003', ..., 'A300');Are all the ID's in a table, where they can be queried?
If so, you can use the IN operator with a sub-query:
Update  table
set     status = 's'
where   id in (
                  SELECT  id_column
                  FROM    table_2
                  WHERE   ...
              );Are the 300 ids in a flat file somewhere? You might be able to make a SQL*Plus sub-script out of it, or read it as an external table.

Similar Messages

  • Need to update corresponding columns in details table

    Hi,
    I have a header and lines table.
    In header table we have a comments field, requirement is whenever someone is updating comments in header it should update lines comment column as well.
    I tried using fire action on Comments field like as soon as user is entering something in Comments field I am capturing that event and firing and update statement for lines table
    but the problem here is, if user enters the comments and doesn't save it at header level it stills fire an update statement in lines and updating the comment field of lines table.
    I need to update header comments in lines level at Apply button.
    Please someone suggest something.
    Best Regards
    Ragni Gupta

    Hi Gurus/Expert,
    Please suggest something, its really urgent!!
    Thanks
    Ragni Gupta

  • Need to update multiple columns using another table

    I have 2 tables. and i need to update rows of 1 table using another table
    Table1
    Serial_no.     payment_date     Payment_amt
    101     22/11/2010     150
    101     18/03/2011      355
    102     15/04/2011      488
    103     20/05/2011      178
    102     14/06/2011      269
    101     28/06/2011      505
    Table2
    Serial_no     Charge_amt      Last_paymt_dt     Last_paymt_amt
    101     255
    102     648
    103     475
    I want to update Last_paymt_dt and Last_paymt_amt of table2 using Table1, I have written following update statement but it gives error that single row subquery return multiple row.
    Update Table2
    set (Last_paymt_dt,Last_paymt_amt) = (select max(payment_date, payment_amt) from table1
    where table1.Serial_no = table2.Serial_no group by payment_amt)
    kindly suggest how should i update.

    SQL> select * from table1
      2  /
    SERIAL_NO PAYMENT_DA PAYMENT_AMT
           101 22/11/2010         150
           101 18/03/2011         355
           102 15/04/2011         488
           103 20/05/2011         178
           102 14/06/2011         269
           101 28/06/2011         505
    6 rows selected.
    SQL> select * from table2
      2  /
    SERIAL_NO CHARGE_AMT LAST_PAYMT LAST_PAYMT_AMT
           101        255
           102        648
           103        475
    SQL> update  table2
      2     set  (last_paymt_dt,last_paymt_amt) = (
      3                                            select  max(payment_date),
      4                                                    max(payment_amt) keep(dense_rank last order by payment_date)
      5                                              from  table1
      6                                              where table1.serial_no = table2.serial_no
      7                                           )
      8  /
    3 rows updated.
    SQL> select * from table2
      2  /
    SERIAL_NO CHARGE_AMT LAST_PAYMT LAST_PAYMT_AMT
           101        255 28/06/2011            505
           102        648 14/06/2011            269
           103        475 20/05/2011            178
    SQL> SY.

  • Need to update a column - Remove some values.

    Hi,
    I have a table with say two columns
    TEST(a number, b VARCHAR2(3000))
    The record is like
    1, 'abv,ced,efer,drt,s,uywe,rerer,swewe,dfx,werrr,qwe,'
    I need to remove all those from the column value which match to following list
    'abv','drt','dfx'
    Such that the table shud have
    1,'ced,efer,s,uywe,rerer,swewe,werrr,qwe,' as its values
    I am using Oracle 10G .
    Nested Replace/Translate is an option But wanted to know a better way .:)

    Solomon's query
    SQL>with t as (
      2  select 'abv,efer,,,,s,uywe,abv,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx,' col from dual union all
      3  select 'abv,efer,,,,s,uywe,abv,,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx,' col from dual
      4  )
      5  select col, regexp_replace(regexp_replace(',' || col || ',','(,?(abv|drt|dfx),?)+',','),'(^,)|(,$)') newstr
      6  from t;
    COL                                                                    NEWSTR
    abv,efer,,,,s,uywe,abv,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx,  efer,,,,s,uywe,ced,rerer,swewe,werrr,qwe,
    abv,efer,,,,s,uywe,abv,,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx, efer,,,,s,uywe,ced,rerer,swewe,werrr,qwe,A slight variants of his, with no nested REGEXP_REPLACE
    SQL>with t as (
      2  select 'abv,efer,,,,s,uywe,abv,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx,' col from dual union all
      3  select 'abv,efer,,,,s,uywe,abv,,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx,' col from dual
      4  )
      5  select col, trim(',' from regexp_replace(',' || col || ',','(,?(abv|drt|dfx),?)+',',')) newstr
      6  from t;
    COL                                                                    NEWSTR
    abv,efer,,,,s,uywe,abv,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx,  efer,,,,s,uywe,ced,rerer,swewe,werrr,qwe
    abv,efer,,,,s,uywe,abv,,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx, efer,,,,s,uywe,ced,rerer,swewe,werrr,qwe
    SQL>
    SQL>with t as (
      2  select 'abv,efer,,,,s,uywe,abv,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx,' col from dual union all
      3  select 'abv,efer,,,,s,uywe,abv,,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx,' col from dual
      4  )
      5  select col, regexp_replace(col,',?(abv|drt|dfx),?') newstr
      6  from t;
    COL                                                                    NEWSTR
    abv,efer,,,,s,uywe,abv,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx,  efer,,,,s,uyweced,rerer,swewe,werrr,qwe
    abv,efer,,,,s,uywe,abv,,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx, efer,,,,s,uyweced,rerer,swewe,werrr,qwe

  • Need to update one column of all table in that particular schema

    hi all,
    i am using db10g.
    my task is to update one particular column's value of all the table in that schema.
    to acheive the above
    do i have to write update statement for each table or is there any way to do it in bulk?
    i hope my question make sense.
    Thanks..

    Hi karthick,
    I want to know something which is not related to this thread .
    How to include formatted post while replying to thread .
    I know using will be used  format  code before posting  . But how can we  do  it for posted message .
    I hope you understand my question .
    Thanks in advance .                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to programatically select a row in TableBean and update its column?

    Hi,
    Can anyone help me on How to programmatically select a row in a TableBean and update its column?
    Thanks,
    Jon

    Hi,
    My requirement is I need to update a column in a particular row of the table using fire action...
    I have a datefield bean serve as birhdate and base on this I need to update the age column depending on the given dates..
    Here's my code under the Process form request for your reference...
    if (actionInMainPersonScreen.equals("changeDate"))
    String checkId = pageContext.getParameter("paramDatePersonId");
    OAFormValueBean depPerId = (OAFormValueBean)depTable.findIndexedChildRecursive("ChildPersonID");
    OAMessageTextInputBean depFName = (OAMessageTextInputBean)depTable.findIndexedChildRecursive("FirstName");
    OAMessageDateFieldBean dateBirth = (OAMessageDateFieldBean)depTable.findIndexedChildRecursive("BDay");
    OAMessageStyledTextBean age = (OAMessageStyledTextBean)depTable.findIndexedChildRecursive("Age");
    Date changeBDate = new java.util.Date();
    Date dateToday = new java.util.Date();
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
    changeBDate = (Date)dateBirth.getValue(pageContext);
    Calendar cal = Calendar.getInstance();
    ResultSet empAge = null;
    String newAge = null;
    OADBTransaction trans = personam.getOADBTransaction();
    System.out.println("BirthDate: " + changeBDate + " Date Today: " + sdf.format(dateToday));
    String expQuery = "SELECT Trunc((sysdate - To_Date('" + pageContext.getParameter("paramDateBirth") + "'))/365) compAge, Sysdate from dual";
    System.out.println("SQL: " + expQuery);
    PreparedStatement expPreparedStatement = trans.createPreparedStatement(expQuery ,1);
    try
    empAge = expPreparedStatement.executeQuery();
    } catch (SQLException e) {}
    try
    while (empAge.next())
    newAge = empAge.getString("compAge");
    age.setText(pageContext, newAge);
    empAge.close();
    } catch (SQLException e) {}
    regards,
    Jon

  • Navigation to update a column in the table jtf.jtf_rs_resource_extns

    Hi All,
    I'm using oracle 11.5.10
    Can somebody tell me the frontend form which is related to the table jtf.jtf_rs_resource_extns
    I need to update a column in the above table from the frontend.
    Please explain me the navigation for doing the same
    Regards,
    Mohan

    I can't tell you the answer to your query but what I can tell you is that you have logged the thread in a wrong forum. As far as my knowledge goes, this table does not delong to HRMS.
    Just check the product in which you are working and then log the thread in the right forum.
    Thanks,

  • Update a Column during Insert

    A row is being inerted by GUI with a column as NULL. DB need to update this column.
    Trigger will create a mutating Error.
    Can you please help me how to update the column.
    (Using Oracle 10g)

    >
    UPDATE test
    SET column6 = '100'
    WHERE column1 = :new.column1;
    END trig_test;
    As updating the same table, getting Mutating Error.
    >
    Yes - you can't update the same table and you don't want to use the AFTER trigger.
    Jeneesh's uses a BEFORE INSERT .. FOR EACH ROW trigger and sets the new value. So use his code to
    create or replace trigger test_trig before insert
      on test for each row
      begin
       if :new.column6 is null then
          :new.column6 := '100';
       end if;
      end;And why are you storing what appears to be a number in a VARCHAR2 datatype? Store numbers in numeric columns.

  • Updating a column when button  pressed

    Hello,
    I have a ADF master detail table and in the detail table and I would like to add a button. When user select a row and presses the button, I need to update a column value to 'Y'. How can I do this?
    I need to have a Yes or No prompt as welll before it gets updated in the db table.
    How can I acheive this.
    Thanks a lot.

    Hi,
    if you use ADF, on the button action method, access the ADF biinding, get a hande to the iterator and call getCurrentRow() on it. The set the attribute that represents the column and set Yes or No to it.
    Make sure you use PPR to refresh the table when teh button is pressed
    Frank

  • Need logic to update Varchar column in a table

    Hi,
    Could you give me logic for below.
    I have a table xx_dbc where one of the column Attribute1 is varchar2(240).
    Attribute1 has values like 
    ==================
    (AIN,PUP,GRI,NINE)
    (AIN,PUP)
    (AIN)
    (GRI,NINE)
    I have to update this column for every record with values AIN=10 , PUP=20 , GRI=30 , NINE=40
    Columns should be updated like below
    (10,20,30,40)
    (10,20)
    (10)
    (30,40)
    Thanks.

    Hi,
    Here's one way:
    WITH  replacements  AS
        SELECT  'AIN' AS old_str, '10' AS new_str  FROM dual  UNION ALL
        SELECT  'PUP',            '20'             FROM dual  UNION ALL
        SELECT  'GRI',            '30'             FROM dual  UNION ALL
        SELECT  'NINE',           '40'             FROM dual
    ,    normalized_data  AS
        SELECT  p_key
        ,       LEVEL               AS sort_key
        ,       REGEXP_SUBSTR ( attribute1
                              , '[^(,)]+'
                              , 1
                              , LEVEL
                              )     AS str
        FROM    xx_dbc
    --  WHERE   ...     -- If you need any filtering, put it here
        CONNECT BY   LEVEL              <= 1 + REGEXP_COUNT (attribute1, ',')
                AND  PRIOR p_key        = p_key
                AND  PRIOR SYS_GUID ()  IS NOT NULL
    SELECT    '(' || LISTAGG ( NVL (r.new_str, n.str)
                             ) WITHIN GROUP (ORDER BY sort_key)
                  || ')'  AS  new_attribute1
    ,         n.p_key                         -- If wanted
    FROM             normalized_data  n
    LEFT OUTER JOIN  replacements     r  ON  r.old_str  = n.str
    GROUP BY  n.p_key
    ORDER BY  n.p_key
    Like everything else, it depends on your Oracle version.
    In the query above, p_key can be any unique key from xx_dbc, including attribute1 or ROWID.
    Relational databases, like Oracle, work best when each column of each row contains only 1 piece of information, not a delimited list of any number of pieces.  This is so fundamental to table design that it's called First Normal Form.  Most of the work in this problem involves converting your denormalized data into First Normal Form, and then converting it back again.  This problem, like many others, would be much simpler and more efficient if your table was in First Normal Form.
    The query above assumes the replacement strings (such as 'AIN' and '10') are not already in a table.  If they are, or if they can be derived from a table, then you don't need the replacements sub-query; use your real table instead.

  • Help needed in PL/SQL for updating the column for multiple records

    Hi,
    I am new to PL/SQL and need some help. What is the most effiecient way to update some field in a table as I may need to update thousands of records. I have a coulmn groupid can have multiple records tied to it. All the records attached to some groupid have a priority field also.
    How can I update the prorityfield value for all the groupids in a profiecient way. Here is a sample data
    GroupId     Priority
    1            1
    1            2
    1            3
    1            4
    1            5
    2            1
    2            2
    2            3
    3            1Here I have three groups 1, 2, 3. Now if any group contains only one record the priority remains same e.g. groupid=3 on top. If any group contains more than one record e.g. groupid=1 & 2 I want to re-arrange the priority fields e.g. If I want to update groupid=1 now if I change the priority of 2 to 5 (make it the last) I want to rearrange the remaing records priority i.e. if 2 becomes 5 as I have 5 rows for groupid=1 then 5 becomes 4, 4 becomes 3, 3 becomes 2 and 1 remains the same.
    Same wya if I want to make the priority 1 to 3 for groupid=2 then need 2 to become 1 and 3 to become 2 etc....
    Any help is appreciated.
    Thanks

    Hi,
    You don't need PL/SQL to do this (though you can put the following in PL/SQL if you want to):
    UPDATE     table_x
    SET     priority = CASE
                   WHEN  groupid     = 1
                   AND   priority = 2
                        THEN  5
                   WHEN  groupod     = 1
                   AND   priority     BETWEEN 3 AND 5
                        THEN  priority - 1
                   WHEN  groupid = 2
                   THEN
                        CASE
                             WHEN  prioity = 1
                             THEN  3
                             ELSE  priority - 1
                        END
                 END
    WHERE     groupId          IN (1, 2)
    AND     (     priority     BETWEEN 2 AND 5
         OR     groupid          = 2
         );There are lots of different techniques that can reduce your coidng: for example, the nested CASE statement used for groupid=2 above.
    You could do several smaller UPDATEs (for example, one just for groupid=1). Execution will be slower, but coding and testing will be faster.
    You could make the "magic numbers" 2 (for groupid=1) and 1 (for groupid=2) variables, even outside of PL/SQL.
    If you need more help, post the information that Satyaki requested.

  • Need help in updating "TIMESTAMP" column

    Hi,
    Below is my table description, i want to update timestamp column but i could not able to do, please help me on this.
    ID VARCHAR2(4 BYTE),
    TYPE VARCHAR2(1 BYTE),
    DATET TIMESTAMP(6),
    TYPE NUMBER
    Currently i have value "5/1/2009 9:00:00.000000 AM" for DATET column, now i want to update it to "5/1/2009 9:00:00.000000 PM". Please help me out.
    Thanks.

    Hi,
    Here's one way:
    UPDATE     table_x
    SET     datet     = datet + INTERVAL '12' HOUR
    WHERE     datet     = TO_TIMESTAMP ( '01/05/2009 09:00:00'
                          , 'DD/MM/YYYY HH24:MI:SS'     -- or whatever
                          );

  • IF Auto Update Statistics ENABLED in Database Design, Why we need to Update Statistics as a maintenance plan

    Hi Experts,
    IF Auto Update Statistics ENABLED in Database Design, Why we need to Update Statistics as a maintenance plan for Daily/weekly??
    Vinai Kumar Gandla

    Hi Vikki,
    Many systems rely solely on SQL Server to update statistics automatically(AUTO UPDATE STATISTICS enabled), however, based on my research, large tables, tables with uneven data distributions, tables with ever-increasing keys and tables that have significant
    changes in distribution often require manual statistics updates as the following explanation.
    1.If a table is very big, then waiting for 20% of rows to change before SQL Server automatically updates the statistics could mean that millions of rows are modified, added or removed before it happens. Depending on the workload patterns and the data,
    this could mean the optimizer is choosing a substandard execution plans long before SQL Server reaches the threshold where it invalidates statistics for a table and starts to update them automatically. In such cases, you might consider updating statistics
    manually for those tables on a defined schedule (while leaving AUTO UPDATE STATISTICS enabled so that SQL Server continues to maintain statistics for other tables).
    2.In cases where you know data distribution in a column is "skewed", it may be necessary to update statistics manually with a full sample, or create a set of filtered statistics in order to generate query plans of good quality. Remember,
    however, that sampling with FULLSCAN can be costly for larger tables, and must be done so as not to affect production performance.
    3.It is quite common to see an ascending key, such as an IDENTITY or date/time data types, used as the leading column in an index. In such cases, the statistic for the key rarely matches the actual data, unless we update the Statistic manually after
    every insert.
    So in the case above, we could perform manual statistics updates by
    creating a maintenance plan that will run the UPDATE STATISTICS command, and update statistics on a regular schedule. For more information about the process, please refer to the article:
    https://www.simple-talk.com/sql/performance/managing-sql-server-statistics/
    Regards,
    Michelle Li

  • Need to update mutli record in oracle forms - Urgent please

    Hi,
    We are using Oracle apps release 11i - Oracle forms 6i.
    I have a field "project_start_date" in project_block in a custom form. There is another multi-record block called role_block in the same custom form and it has a field named start_date. Requirement is when ever I make change in the project_start_date in project_block, that should reflect in role_block.start_date. I tried different means and could update only the very first record of the multi-record block - role_block. I need to update all the records in the role_block with the same project_start_date. Used looping and several other methods. But could not achieve. Any help is really appreciated.
    Thanks
    Akil

    Please first read this https://forums.oracle.com/forums/ann.jspa?annID=432
    We are using Oracle apps release 11i - Oracle forms 6i.I can't understand this together.
    I have a field "project_start_date" in project_block in a custom form. There is another multi-record block called role_block in the same custom form and it has a field named start_date. Requirement is when ever I make change in the project_start_date in project_block, that should reflect in role_block.start_date. I tried different means and could update only the very first record of the multi-record block - role_block. I need to update all the records in the role_block with the same project_start_date. Used looping and several other methods. But could not achieve. Any help is really appreciated.
    Thanks
    AkilIs there any relation between project_block and role_block ?
    Do u want to update corresponding column (specific filed) of role_block when updating project_start_date in forms? How may rows will be updated for one project_start_date update ? one or multiple or all ?

  • Update a column for a subset of data

    Hi all,
    I hope you can help me with some suggestions in how to solve the issue i have for the table below
    SQL> select * from table1;
    NAME                         ID CONCAT               SAME_GR
    A                            10 100|200|300
    B                            11 100|200|300
    C                            12 100|200
    D                            10 100|200|300
    SQL> What i need to do is to flag the rows which have the same ID & Concat value by updating the same_gr column with the same value, something like
    SQL> select * from table1;
    NAME                         ID CONCAT               SAME_GR
    A                            10 100|200|300              GR1
    B                            11 100|200|300              GR2
    C                            12 100|200                   GR3
    D                            10 100|200|300             GR1
    SQL> One important note is that the value in SAME_GR column should have the form of GR<sequence>
    I've been trying to use lag/lead functions but i can't succeed in updating the column with the same value for each group of rows where ID & CONCAT are the same.
    I forgot to mention i'm on 11gR1.
    Any help is very much appreciated.
    Cheers,
    Dani
    Edited by: DanyC on Jun 18, 2010 10:40 AM

    yes, you can.. all you need to do add is sum operation. after dense_Rank column sepecify + 254 and thus it will add up the value with dense rank output.
    sample run...
    PRAZY@11gR2> select ename,dense_rank() over (partition by deptno order by empno) from emp;
    ENAME      DENSE_RANK()OVER(PARTITIONBYDEPTNOORDERBYEMPNO)
    CLARK                                                    1
    KING                                                     2
    MILLER                                                   3
    SMITH                                                    1
    JONES                                                    2
    SCOTT                                                    3
    ADAMS                                                    4
    FORD                                                     5
    ALLEN                                                    1
    WARD                                                     2
    MARTIN                                                   3
    BLAKE                                                    4
    TURNER                                                   5
    JAMES                                                    6
    14 rows selected.
    Elapsed: 00:00:00.13
    PRAZY@11gR2> select ename,dense_rank() over (partition by deptno order by empno)+300 from emp;
    ENAME      DENSE_RANK()OVER(PARTITIONBYDEPTNOORDERBYEMPNO)+300
    CLARK                                                      301
    KING                                                       302
    MILLER                                                     303
    SMITH                                                      301
    JONES                                                      302
    SCOTT                                                      303
    ADAMS                                                      304
    FORD                                                       305
    ALLEN                                                      301
    WARD                                                       302
    MARTIN                                                     303
    BLAKE                                                      304
    TURNER                                                     305
    JAMES                                                      306
    14 rows selected.
    Elapsed: 00:00:00.01Regards,
    Prazy

Maybe you are looking for