Update multiple columns with single update statement..

HI all,
i am reading the columns value from different table but i want to update it with signle update statement..
such as how to update multiple columns (50 columns) of table with single update statement .. is there any sql statement available i know it how to do with pl/sql..

As I understood, may be this. Here i am updating ename,sal, comm columns all at once.
SQL> select * from emp where empno=7369;
     EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
      7369 SMITH      CLERK           7902 17/12/1980 12:00:00        800                    20
SQL> UPDATE emp
  2     SET ename = lower (ename),
  3         sal = sal + 1000,
  4         comm = 100
  5   WHERE empno = 7369;
1 row updated.
SQL> select * from emp where empno=7369;
     EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
      7369 smith      CLERK           7902 17/12/1980 12:00:00       1800        100         20
SQL> UPDATE emp
  2     SET ename = (SELECT 'ABCD' FROM DUAL),
  3         sal = (SELECT 1000 FROM DUAL),
  4         comm = (SELECT 100 FROM DUAL)
  5   WHERE empno = 7369;
1 row updated.

Similar Messages

  • Update Multiple Column with Single Command with Join between Two tables.

    This is our command where we are trying to update a table's two columns by pulling values from another table after joining. This query takes too much time to execute. Any suggestions ?
    UPDATE raw_alc_rmfscombinednew
    SET (BSC, CELL_NAME) =
    SELECT distinct raw_alc_R110combinednew.BSC, raw_alc_R110combinednew.CELL_NAME
    FROM raw_alc_R110Combinednew
    WHERE
    raw_alc_R110Combinednew.OMC_ID = raw_alc_rmfscombinednew.OMC_ID
    AND raw_alc_R110Combinednew.CELL_CI = raw_alc_rmfscombinednew.CI
    AND RAW_ALC_R110COMBINEDNEW.START_TIME = RAW_ALC_RMFSCOMBINEDNEW.START_TIME
    Results of Last execution:
    Elapsed Time (sec) 4,476.56
    CPU Time (sec) 4,471.88
    Wait Time (sec) 4.68
    Executions that Fetched all Rows (%) 100.00
    Average Persistent Mem (KB) 32.43
    Average Runtime Mem (KB) 31.59
    --------------------------------------------------------------

    Your update requires a full execution of the subquery for each row in the destination table (raw_alc_rmfscombinednew). Try rewriting as a MERGE. Tons faster.
    MERGE INTO raw_alc_rmfscombinednew  D
          USING ( SELECT distinct
                         BSC,
                         CELL_NAME
                         START_TIME
                    FROM raw_alc_R110Combinednew )  S
             ON (    S.OMC_ID     = D.OMC_ID
                 AND S.CELL_CI    = D.CI
                 AND S.START_TIME = D.START_TIME )
        WHEN MATCHED THEN
          UPDATE
             SET D.BSC        = S.BSC,
                 D.CELL_NAME  = S.CELL_NAME

  • UPDATE multiple columns with conditional SET parameters

    I have a procedure that updates multiple columns of a table using the procedure's parameter. Is it possible to have one update statement with conditional SET parameter?
    CREATE TABLE TEMP
    (POL_NUM NUMBER,
    OED DATE,
    TERM NUMBER,
    TRANS_CD CHAR(2));
    INSERT INTO TEMP VALUES (1, '1 AUG 2009', 12, 'NB');
    INSERT INTO TEMP VALUES (2, '4 AUG 2009', 12, 'XL');
    INSERT INTO TEMP VALUES (3, '2 AUG 2009', 12, 'RN');
    COMMIT;
    CREATE OR REPLACE PROCEDURE TMP_PROC (
      pPOL_NUM NUMBER,
      pOED IN DATE,
      pTERM IN NUMBER,
      pTRANS_CD CHAR2)
    AS
    BEGIN
      IF pOED IS NOT NULL THEN
        UPDATE TEMP SET OED = pOED WHERE POL_NUM = pPOL_NUM;
      END IF;
      IF pTERM IS NOT NULL THEN
        UPDATE TEMP SET TERM = pTERM WHERE POL_NUM = pPOL_NUM;
      END IF;
      IF pTRAN_CD IS NOT NULL THEN
        UPDATE TEMP SET TRANS_CD = pTRANS_CD WHERE POL_NUM = pPOL_NUM;
      END IF;
      COMMIT;
    EXCEPTION
      WHEN OTHERS THEN
         NULL;
    END;Is it possible to replace multiple IFs from the code to have only one UPDATE statement with condition that update the column only if the passed parameter is not null? In real scenario I have more than 3 columns and I don't want to write many IF blocks.
    Please help Gurus!!
    Edited by: Kuul13 on Sep 18, 2009 1:26 PM

    Hi,
    You certainly don't want to issue separate UPDATE statements for every column; that will be really inefficent.
    SQL has several ways to implement IF-THEN-ELSE logic. CASE is the most versatile, but NVL will do everything you need for this job. You can use one of those to set a column to itself (and therefore not really update that column) when appropriate.
    For example:
    CREATE OR REPLACE PROCEDURE TMP_PROC (
      pPOL_NUM   IN       NUMBER,
      pOED          IN   DATE,
      pTERM          IN   NUMBER,
      pTRANS_CD  IN       CHAR
    AS
    BEGIN
         UPDATE  temp
         SET     oed      = NVL (poed,       oed)
         ,     term      = NVL (pterm,       term)
         ,     trans_cd = NVL (ptrans_cd, trans_cd)
         WHERE     pol_num      = ppol_num;
      COMMIT;     -- Maybe
    END    tmp_proc;"EXCEPTION WHEN OTHERS THEN NULL" is almost always a bad idea. If there's an error, don't you want to know about it? Shouldn't you at least log a message in a warnings table or something?
    Think careflully about whether or not you want to COMMIT every time you call this procedure.
    Just as it's inefficient to issue a separate UPDATE statement for every column, it's also inefficient to issue a separate UPDATE statement for every row. If efficiency is important, it should be possible to UPDATE several rows in a single UPDATE statement, using NVL (or CASE, or COALESCE, or NULLIF, or NVL2, or ...).
    This was a very well-written question! Thanks for providing the CREATE TABLE and INSERT statements, and such a clear explanation.

  • Inserting multiple rows with single insert statement ?

    Hi ,,
    Consider a PL/SQL procedure.
    I want to pass an array of values and insert in a table with a single statement.
    Moreover I want to call this procedure to insert multiple rows from OCI program.
    Can some body help ? :(
    Thanks
    Chandu

    Hi Vincent,
    Regular array insert which you have mentioned works in case of insert statement(This is to eliminate multiple calls to server)
    Will it work for passing array to Stored procedure, in this case procedure will be called only once with an array.
    It will be of great help if you give an example.
    Thanks
    Chandra

  • Update Multiple Columns when concerned about redo/undo log sizes.

    Hi ,
    I have update statements that updates multiple columns at once if any of them is changed. What I see that even though the value of column is not changed it still increases the redo size.
    Below is a sample code similar to the ones in my code. Basically I check whether there is a difference in any of the columns to be updated and update all of them.
    Is there a way to improve redo log size without splitting the update statement for every column that I will be updating. Redo/Undo log size is a concern for us..
      For i In 1.rec.Count Loop
        Update employees e
           Set e.first_name = rec(i).first_name, e.last_name = rec(i).last_name
         Where e.first_name != rec(i).first_name
            Or e.last_name != rec(i).last_name;
      End Loop;My database is 10g.

    Muhammed Soyer wrote:
    Redo/Undo log size is a concern for us..You are worried about the wrong thing.
    If you are concerned about the amount of undo and redo, you should be less concerned about the small diffrence between updating 1 or 3 columns and remove the loop that is contributing to a massive increase in both undo and redo.
    Re: global temporary table row order
    Name                                  Run1        Run2        Diff
    STAT...undo change vector size     240,500   6,802,736   6,562,236
    STAT...redo size                 1,566,136  24,504,020  22,937,884Run2 shows what adding a loop to a regular SQL statement will do to undo and redo. It made the redo used 15 times greater and the undo almost 30 times greater.

  • How to update multiple columns from different tables using cursor.

    Hi,
    i have two tables test1 and test2. i want to udpate the column(DEPT_DSCR) of both the tables TEST1 and TEST2 using select for update and current of...using cursor.
    I have a code written as follows :
    DECLARE
    v_mydept1 TEST1.DEPT_CD%TYPE;
    v_mydept2 TEST2.DEPT_CD%TYPE;
    CURSOR C1 IS SELECT TEST1.DEPT_CD,TEST2.DEPT_CD FROM TEST1,TEST2 WHERE TEST1.DEPT_CD = TEST2.DEPT_CD AND TEST1.DEPT_CD = 'AA' FOR UPDATE OF TEST1.DEPT_DSCR,TEST2.DEPT_DSCR;
    BEGIN
    OPEN C1;
         LOOP
              FETCH C1 INTO v_mydept1,v_mydept2;
              EXIT WHEN C1%NOTFOUND;
              UPDATE TEST2 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
              UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
         END LOOP;
         COMMIT;
    END;
    The above code when run says that it runs successfully. But it does not updates the desired columns[DEPT_DSCR].
    It only works when we want to update single or multiple columns of same table...i.e. by providing these columns after "FOR UPDATE OF"
    I am not sure what is the exact problem when we want to update multiple columns of different tables.
    Can anyone help me on this ?

    oops my mistake.....typo mistake...it should have been as follows --
    UPDATE TEST1 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
    UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
    Now here is the upated PL/SQL code where we are trying to update columns of different tables --
    DECLARE
    v_mydept1 TEST1.DEPT_CD%TYPE;
    v_mydept2 TEST2.DEPT_CD%TYPE;
    CURSOR C1 IS SELECT TEST1.DEPT_CD,TEST2.DEPT_CD FROM TEST1,TEST2 WHERE TEST1.DEPT_CD = TEST2.DEPT_CD AND TEST1.DEPT_CD = 'AA' FOR UPDATE OF TEST1.DEPT_DSCR,TEST2.DEPT_DSCR;
    BEGIN
    OPEN C1;
    LOOP
    FETCH C1 INTO v_mydept1,v_mydept2;
    EXIT WHEN C1%NOTFOUND;
    UPDATE TEST1 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
    UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
    END LOOP;
    COMMIT;
    END;
    Please let us know why it is not updating by using using CURRENT OF

  • How to update a column with default in a tabular form.

    We have a tabular form that has a submit button that does a multi row update. We would like to update a column with a defaut like APP_USER = updated user when the row is updated. Is this possible and how?

    used lovs and conditions.

  • Can we create multiple application with single MSI(or Same MSI) in biztalk admin console ?

    Can we create multiple application with single MSI(or Same MSI) in biztalk admin console ?
    My client requirement is process 100 files  from biztalk with in 5 min ,actually it is taking 20 min .
    So I decided to created same instance of the application with multiple time in BTS admin console ,as I understand biztalk admin console never allow to install same
    schema’s with multiple  time .
    Any help can be  appreciate ..

    BizTalk will automatically process multiple messages on separate threads so you may need to tune your system. The following link should get you started:
    http://social.technet.microsoft.com/wiki/contents/articles/7801.biztalk-server-performance-tuning-optimization.aspx
    Another possibility is to set the Batch Size property on your receive location if the adapter uses batch size to determine how messages are picked up.  As an example, it you want  the MSMQ adapter to immediately pick up messages and start
    to process them, set the batch size to 1.
    You may also need to distribute the processing across multiple BizTalk servers by installing BizTalk on additional servers and joining the existing BizTalk group.
    David Downing... If this answers your question, please Mark as the Answer. If this post is helpful, please vote as helpful.

  • Single report with multiple queries OR multiple reports with single query

    Hello Experts,
    I have a confusion regarding Live Office connection for many days. I asked many people but did not get a concrete answer. I am re-posting this question here and expecting an answer this time.
    The product versions that I am using are as follows:
    FrontEnd:
      BOE XI 3.1 SP4 FP 4.1
      Xcelsius Enterprise 2008 SP4
    Backend:
      SAP BW 7.0 EHP1
    I have created a dashboard which is getting data from a webi report using LO connections.
    The webi report has five report parts which are populated by five different queries.
    Now my question is, when the five LO connections are refreshed, is the webi report refreshed five times or just once?
    If the report is refreshed five times, then I guess it is better to have five different webi reports containing single report part, because in that way we can prevent same query being executed multiple times.
    SO what is the best practice- to have a single report having multiple queries - OR - to create multiple webi reports with single query?
    Thanks and Regards,
    PASG

    HI
    I think Best Practice is Multiple reports with single query
    Any way If LO connections refresh 5 time the query will refresh 5 timesRegards
    Venkat

  • When iam loading multiple datatargets with single datasource request failed

    when iam loading multiple datatargets with single datasource request failed
    i want to delete the  bad request at a time in all datatargets

    Hi Neeraj,
    The only thing you can do is go in to theMonitor screen of that IP and select the datatargets from the Monitor screen.In the next screen you can see all the targets included in the IP at the top.But the only bad thing is you have to manually delete the Bad request only from each target.
    Regards
    Sandeep

  • Is it possible to integrate multiple instances with single OAM (Oracle Acce

    Hi All,
    Please could anyone clarify,is it possible to integrate multiple instance with single OAM(Oracle Access Manager).
    We have two instance in development environment, Among them one is already integrated with OAM 11g,Now we want to integrate the second one with OAM 11g. For this already configured OAM is enough or we need to configure the another OAM separately.
    Application Version is 12.1.1
    Database Version : 11.1.0.7
    OS : RHEL 5.3 64 bit
    Thanks in advance.

    Hi Hussein ,
    I Ran below script,
    ant -f txkEBSAuth.xml \
    -Dwlshosturl=appora.corp.hexaware.com:7021 \
    -Dwlsuser=weblogic \
    -Dwlspwd=password1 \
    -DuseDefaults=true \
    -DforceDataSource=true \
    -DdataSourceName=DEV \
    -DdataSourceJNDIName=jndi/DEV \
    -DasadminUser=SSO11GLOGIN \
    -DasadminPassword=welcome1 \
    -DdbcFile=/u06/oamfmw/Middleware/appsutil/accessgate/DEV/DEV.dbc \
    -DserverName=AdminServer \
    -DdeploymentName=ebsauth_DEV \
    -DfndauthWarFile=/u06/oamfmw/Middleware/appsutil/accessgate/DEV/fndauth.war \
    -DplanPath=/u06/oamfmw/Middleware/appsutil/accessgate/DEV/plan/plan.xml \
    -DforceDeployment=true \
    -DSSOServerRelease=11 \
    -DSSOServerURL=http://appora.corp.hexaware.com:14100 \
    -DWebgateLogoutURL=http://appora.corp.hexaware.com:7780/public/oacleanup.html \
    -DlogConfigfile=/u06/oamfmw/Middleware/appsutil/accessgate/DEV/sample/logging.properties
    -bash: ant: command not found
    Thanks in advance

  • Merge statement - update multiple columns from a single sub-select

    Is it possible to write in 10gR2, a MERGE statement, with UPDATE for multiple columns from a single sub_select?
    like this:
    MERGE INTO tableA
    using ( select * from temp) tmp
    on( tableA. col1 = tmp.col1)
    when matched then
    update set  ( tableA.col5,
                       tableA.col6,
                       tableA.col7) = ( select sum(col2), sum(col3), sum(col5)
                                                                                 from tableX
                                                                                where tableX.col1 = tableA.col1...)

    Hi,
    The USING clause is not a sub-query, so it can't reference columns from tables that are not in it.
    Include tableA in the USING clause if you really need to refer to it there. (It's not obvious that you do.)
    As always, it helps if you post:
    (1) The version of Oracle (and any other relevant software) you're using
    (2) A little sample data (just enough to show what the problem is) from all the relevant tables
    (3) The results you want from that data (In the case of a DML statement, such as MERGE, this will be the state of the tables when everything is finished.)
    (4) Your best attempt so far (formatted)
    (5) The full error message (if any), including line number
    Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
    If you can present your problem using commonly available tables (for example, tables in scott schema, or views in the data dictionary), then you can omit (2).
    Formatted tabular output is okay for (3).

  • Single Update command to update multiple rows with multiple rows

    Hi Gurus!
    Can I update table A with a result set of table b (multiple rows returns) where a.c1 = b.c1
    regards,
    SH

    As Joel mentioned this update will update all rows in a table based on another one:
    update tableA set seq_no = (select seqno from tableB where tableA.ID = tableB.ID)
    Also, any rows that don't match the select criteria will get updated to null. This could be very bad depending on what you want to do.
    To update a subset of tableA with data from tableB:
    update tableA set seq_no = (select seqno from tableB where tableA.ID = tableB.ID)
    where exists (select 1 from tableB where tableA.ID = tableB.ID)

  • Update multiple records with update button???

    I was wondering if someone could explain how I can use the developer tool box to update multiple records at once.
    I have a repeat region with a title and a check box if the item is active. I would like to update all records of the table at once. I have see folks state the developer tool box can do this. However I am not sure how..
    I am using php with mysql dreamweaver cs3

    Hi Chris,
    that can be done with first creating an ADDT "dynamic list", means to apply ADDT´s "Dynamic List Wizard" to an empty page -- this list will provide checkboxes for all displayed records, and here´s where you can select the to-be-updated (or deleted) records.
    Besides creating the list, this wizard will also be creating a blank "form" php page in the same directory, which is by default "tied" to the created list -- you´ll just need to open this blank document with DW and apply ADDT´s "Create Dynamic Form Wizard" to it. However, this form will contain all required routines for single and multiple updates, depending on how many records you select in the list.
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Best way to implement oracle TEXT on multiple tables with regular updates

    Hi,
    I have the following situation:
    5 tables where we want full text search on multiple columns.
    Some of the tables have a master/detail relation. (1 to 1000, or more)
    because of the number of transactions on these tables we can't have a lag in the sync time.
    Currently I have create a dummy table just for the search with 2 columns: for the primary key to all the other tables and one for the update trigger.
    I use the user_datastore with a procedure to join all the necessary columns resulting in a clob.
    My question is regarding the update.
    Of course I can create triggers to update the dummy field in the search table, but this will give lot of updates on that table with possible locking issues.
    What would be the best approach to have this search functionality working?
    I am open for any ideas!
    Thanks,
    Edward

    Ok, I will focus on building a solution on 12c.
    right now I have used a USER_DATASTORE with a procedure to glue all the field together in one document.
    This works fine for the search.
    I have created a dummy table on which the index is created and also has an extra field which contains the key related to all the tables.
    So, I have the following tables:
    dummy_search
    contracts
    contract_ref
    person_data
    nac_data
    and some other tables...
    the current design is:
    the index is on dummy_search.
    When we update contracts table a trigger will update dummy_search.
    same configuration for the other tables.
    Now we see locking issues when having a lot of updates on these tables as the same time.
    What is you advice for this situation?
    Thanks,
    Edward

Maybe you are looking for

  • Worried about purchasing online, looking for answers

    I was thinking about buying an iPad online as I don't really much like going into the apple store, Too crowded, dont like the atmosphere, but after doing some searching and actually seeing threads with alot of ****** of, empty-handed people, I'm unsu

  • Upgrading Itunes 7 ver

    Hi, I have an old version of Itunes 6. but when I wanted to install the latest version of Itunes 7. The Itunes 7's setup cannot be open. The downloading of the setup is fine and ok but doesn't know why cannot open it once I double click it? Is there

  • PDF 1.2 Filter for a wmf image stream

    Does anybody know how to embed a wmf image as a stream in the PDF 1.2? I saw a filter for jpeg but it's not what I need. Thanks in advance!

  • Interlacing artifacts / jagged edges

    Hi, I've read many of the posts on the Apple Final Cut forum and elsewhere about interlacing artifacts in video. For background info, I'm working with a client's SD DV footage (16:9). It was shot on mini-DV @ shutter rate 125. (BTW, completely white

  • Vistex

    Hi SD gurus, what is integration between VISTEX and ABAP,SD,IP,CPOA and also FI? could we please help me. Warm regards, murali krishna