Update a column keeping old values and adding new one

I have to update a column...
Select * from test;
RULE_NBR TYPE_TEXT
30     AAX,AAR,AAV,AAB,AAK
40     BBD,WWN,AAF,AAB,AAK
now I have to add BBB,WWW where rule_nbr = 30 and CCC,TTT where rule_nbr = 40
so this update stmt will do...
UPDATE TEST
SET type_text = 'AAX,AAR,AAV,AAB,AAK,BBB,WWW'
WHERE rule_nbr = '30';
update test
set TYPE_TEXT = 'BBD,WWN,AAF,AAB,AAK,CCC,TTT'
where rule_nbr = '40';
Just wondering is there any other way to update the same

user1692585 wrote:
I have to update a column...
Select * from test;
RULE_NBR TYPE_TEXT
30     AAX,AAR,AAV,AAB,AAK
40     BBD,WWN,AAF,AAB,AAK
now I have to add BBB,WWW where rule_nbr = 30 and CCC,TTT where rule_nbr = 40
so this update stmt will do...
UPDATE TEST
SET type_text = 'AAX,AAR,AAV,AAB,AAK,BBB,WWW'
WHERE rule_nbr = '30';
update test
set TYPE_TEXT = 'BBD,WWN,AAF,AAB,AAK,CCC,TTT'
where rule_nbr = '40';
Just wondering is there any other way to update the sameYou can do something liek below..But few questions - Why are you storing data like this..It is against normalization concept..You should store the RULE_TEXT values in multiple rows.That is how you should design your data model in an RDBMS
update test
set type_text = type_text||decode(rule_nbr,30,',BBB,WWW',40,',CCC,TTT')
where rule_nbr in (30,40);Edited by: jeneesh on Apr 25, 2013 2:28 PM

Similar Messages

  • Get Old Value and the new value based on the date

    Hi
    I have a table called roster created below with following insert statements.
    CREATE TABLE ROSTER
    ROSTER_EMPLOYEE_DEF_ID NUMBER,
    EMPLOYEE_ID NUMBER,
    DEFINITION_REGION_CODE NUMBER,
    DEFINITION_DISTRICT_CODE NUMBER,
    DEFINITION_TERRITORY_CODE NUMBER,
    START_DATE DATE,
    END_DATE DATE
    INSERT INTO ROSTER
    (ROSTER_EMPLOYEE_DEF_ID,EMPLOYEE_ID,DEFINITION_REGION_CODE,DEFINITION_DISTRICT_CODE,DEFINITION_TERRITORY_CODE,START_DATE,END_DATE)
    VALUES
    (1,299,222,333,444,'1-JUN-2011','30-JUN-2011')
    INSERT INTO ROSTER
    (ROSTER_EMPLOYEE_DEF_ID,EMPLOYEE_ID,DEFINITION_REGION_CODE,DEFINITION_DISTRICT_CODE,DEFINITION_TERRITORY_CODE,START_DATE,END_DATE)
    VALUES
    (2,299,223,334,445,'1-JUL-2011','20-JUL-2011')
    INSERT INTO ROSTER
    (ROSTER_EMPLOYEE_DEF_ID,EMPLOYEE_ID,DEFINITION_REGION_CODE,DEFINITION_DISTRICT_CODE,DEFINITION_TERRITORY_CODE,START_DATE,END_DATE)
    VALUES
    (3,299,224,335,446,'1-AUG-2011','30-AUG-2011')
    INSERT INTO ROSTER
    (ROSTER_EMPLOYEE_DEF_ID,EMPLOYEE_ID,DEFINITION_REGION_CODE,DEFINITION_DISTRICT_CODE,DEFINITION_TERRITORY_CODE,START_DATE,END_DATE)
    VALUES
    (4,300,500,400,300,'1-JUN-2011','20-JUN-2011')
    INSERT INTO ROSTER
    (ROSTER_EMPLOYEE_DEF_ID,EMPLOYEE_ID,DEFINITION_REGION_CODE,DEFINITION_DISTRICT_CODE,DEFINITION_TERRITORY_CODE,START_DATE,END_DATE)
    VALUES
    (5,300,501,401,301,'1-JUL-2011','20-JUL-2011')
    In the above table we have columns like
    EMPLOYEE_ID,DEFINITION_REGION_CODE,DEFINITION_DISTRICT_CODE,DEFINITION_TERRITORY_CODE,START_DATE,END_DATE
    The result i am looking from the above table is based on the EMPLOYEE_ID OF START_DATE AND END_DATE
    I need to get OLD_DEFINITION_REGION_CODE and the NEW_DEFINITION_CODE
    Similarly OLD_DEFINITION_REGION_CODE and the NEW_DEFINITION_REGION_CODE
    and OLD_DEFINITION_TERRITORY_CODE and the NEW_DEFINITION_TERRITORY_CODE
    I need to get one row of data for each employee saying old value and new value
    for employee 299 there are 3 records it must give the new record which is the latest date i.e start date 1-aug-2011 and end date 30-aug-2011 old record will be
    start date 1-jul-2011 and 20-jul-2011
    For the above table data i need to get the data as below
    EMPLOYEE_ID OLD_DEFINITION_REGION_CODE NEW_DEFINITION_CODE OLD_DEFINITION_REGION_CODE NEW_DEFINITION_REGION_CODE START_DATE END_DATE
    299 223 224 334 335 20-JUL-11 30-AUG-11
    300 500 501 400 401 20-JUN-11 20-JUL-11
    Please suggest me to get the above result based on the data. Please let me know if my posts are not clear
    Thanks
    Sudhir

    SELECT  EMPLOYEE_ID,
            OLD_DEFINITION_REGION_CODE,
            NEW_DEFINITION_REGION_CODE,
            OLD_DEFINITION_DISTRICT_CODE,
            NEW_DEFINITION_DISTRICT_CODE,
            OLD_DEFINITION_TERRITORY_CODE,
            NEW_DEFINITION_TERRITORY_CODE,
            START_DATE,
            END_DATE
      FROM  (
             SELECT  EMPLOYEE_ID,
                     ROW_NUMBER() OVER(PARTITION BY EMPLOYEE_ID ORDER BY START_DATE DESC) RN,
                     LAG(DEFINITION_REGION_CODE) OVER(PARTITION BY EMPLOYEE_ID ORDER BY START_DATE) OLD_DEFINITION_REGION_CODE,
                     DEFINITION_REGION_CODE NEW_DEFINITION_REGION_CODE,
                     LAG(DEFINITION_DISTRICT_CODE) OVER(PARTITION BY EMPLOYEE_ID ORDER BY START_DATE) OLD_DEFINITION_DISTRICT_CODE,
                     DEFINITION_DISTRICT_CODE NEW_DEFINITION_DISTRICT_CODE,
                     LAG(DEFINITION_TERRITORY_CODE) OVER(PARTITION BY EMPLOYEE_ID ORDER BY START_DATE) OLD_DEFINITION_TERRITORY_CODE,
                     DEFINITION_TERRITORY_CODE NEW_DEFINITION_TERRITORY_CODE,
                     LAG(END_DATE) OVER(PARTITION BY EMPLOYEE_ID ORDER BY START_DATE) START_DATE,
                     END_DATE
               FROM  ROSTER
      WHERE RN = 1
    EMPLOYEE_ID OLD_DEFINITION_REGION_CODE NEW_DEFINITION_REGION_CODE OLD_DEFINITION_DISTRICT_CODE NEW_DEFINITION_DISTRICT_CODE OLD_DEFINITION_TERRITORY_CODE NEW_DEFINITION_TERRITORY_CODE START_DAT END_DATE
            299                        223                        224                          334                          335                           445                           446 20-JUL-11 30-AUG-11
            300                        500                        501                          400                          401                           300                           301 20-JUN-11 20-JUL-11
    SQL>  SY.

  • Why is finder switching between my old username and my new one?

    After changing my username finder keep switching between my old one and my new one rapidly. I've tried logging out and back in and rebooting, but other than that, I have no idea how I might fix this. A video of the issue can be found here: http://www.youtube.com/watch?v=oU661gxKtqY

    I think you have Fast User Switching switched on, and it's causing your user name to toggle like you were logged into both accounts at the same time.
    Try and turn it off, just to see if that cures the problem.  Go to System Preferences>Users&Groups>Click on lock to unlock, then on Login Options.  Check off Fast User Switching.  I have no clue if this is a cure, but let's see.

  • HT4137 I want to keep my old ipad and the new one going.  Is this possible.?

    I want to keep my old ipad 2 and the new ipad 4. Is this possible.

    of course it is.  what is your actual question?

  • How to remove old id and add new one for apps

    old id is not allowed me to update the apps since i forgot the password . I had made new one since the old one is added in my account i cloud , it has not me to allowed to do anything , please inform how to remove my old id without password since i forgot the same

    You need to delete and redownload all of the applications associated with that Apple ID; it's stored inside them.
    (123008)

  • Differences between old JavaFX and the new one: some questions

    Hi,
    I'm coming back to my JavaFX studies after 2/3 months and I see that some things are different.. Now, I have some questions:
    1) I see that javafx.ui was deprecated or rewritten in favor of javafx.ext.swing. Why there are a javafx.application.Frame and a javafx.ext.swing.SwingFrame? Which one should I use?
    2) Neither javafx.application.Frame or SwingFrame has the "*undecorated*" attribute that javafx.ui.Frame has. I got this feature only reimplementing createWindow() function like this:
    function createWindow(): java.awt.Window {
           //this is a trick, because Frame don't has a undecorated attribute.
           var f: java.awt.Window = super.createWindow();
           (f as javax.swing.JFrame).setUndecorated(true);
           return f;
    }Should I report this as a bug/RFE in [http://bugreport.sun.com/bugreport/] ? Where should I report bugs and RFEs to JavaFX?
    3) Why frame's opacity don't work in Linux? Is this a Linux restriction or only a "not yet implemented" feature?
    My java -version:
    java version "1.6.0_10"
    Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
    Java HotSpot(TM) 64-Bit Server VM (build 11.0-b15, mixed mode)
    4) Where is that cool feature that permits me to easily animate in JavaFX doing only x = [1..100] dur 1000? Now, I need to use this more advanced (and more complicated) Timeline object.
    Timeline {
            keyFrames:Timeline [
                    KeyFrame{time  : 0s values: x => 0.0},
                    KeyFrame{time  : 2s values: x =< 180.0 tween Interpolator.LINEAR}
            ]//keyFrames
    }//Timeline;Sorry for the amount of questions.
    TIA,
    Bruno E. Grossi

    The new ones will be substantially faster than yours because it has 8-cores instead of four, a faster Frontside Bus, and faster RAM speed.
    You could use the same RAM, but since the new ones can accommodate a faster RAM module you would cause the machine to run slower by using the slower RAM from your old machine.
    You can use the same hard drives since both machines support SATA drives.
    On the other hand you could just be happy with what you have! It's probably more than you need.

  • Bought new computer- how do i get all my itunes song off old computer and onto new one?

    i recently purchased a new computer and installed ITUNES on it.  Once I put in my APPLE ID all my purchased songs showed up (songs i purchased through ITUNES on my old computer).  Here is the problem, my old computer has around 800 songs on it from cd's that I owned and downloaded those songs into ITUNES.  Now i want those songs on my new ITUNES on my new computer but don't know how to get them there.  I have tried the following so far:
    - Tried syncing my ipod and ipad to the new computer but each time I do this the new computer ITUNES wants to wipe out the 800 songs and just put on the transfered purchases songs. 
    - Tried 'home sharing'.  When I did home sharing with both computers on and ITUNES opened all the songs showed up on my new computer but as soon as I closed out ITUNES on the old computer the 800 songs went away on the new computer and it went right back to the songs I purchased.
    Please someone tell me there is an easy way to take all these songs I have on ITUNES on the old computer and transfer them to my new computer and ITUNES without having to bust out all these old cd's and sit there and re-burn them all on the new computer. 
    I have in addition to this all ready authorized my new computer with ITUNES so that is good to go.  Any help would be appreciated...

    Are they not on your new computer after you restored your iTunes backup?
    Didn't have a backup?
    Unlike music you can download apps multiple times. Go to each app, download it (ignore the price) and after you click it will tell you that you've already purchased the app and ask if you want to download it again.

  • Surrender old iphone and get new one

    Hi,
    I have Iphone 4S. Its been almost 2 years that i m using that cell with no problems, but now from few days the battery get drained very fast and last for 2-3 hours only.
    Is there are facility available with apple care, if i surrender my old iphone 4s and by paying some amount get the new box packed one.
    Want to know urgently.
    And if there is any facility available than how much do i need to pay to get the new iphone 4s and who is the POC (Point of contact).
    Regards,
    Ritesh Parakh

    There are sites that will buy your old device and then you can use that towards buying a new one. Look at gazelle.com as an example

  • HT1420 deleat old pc and add new one

    how do i deleat my old pc and add my new one

    No idea what you are asking.
    Please explain.

  • Difference between my old Macpro and the new one?

    1.) Would you consider the new Two 3.2GHz Quad-Core Intel Xeon (8-core) a minor or major upgrade from what I currently have (I use it for Final Cut Pro):
    Mac Pro Dual-Core Intel Xeon 3 GHz
    Number Of Processors: 2
    Total Number Of Cores: 4
    L2 Cache (per processor): 4 MB
    Memory: 4 GB
    Bus Speed: 1.33 GHz
    2.) Can I use my old harddrives and RAM in the new Macpro?
    Thanks.

    The new ones will be substantially faster than yours because it has 8-cores instead of four, a faster Frontside Bus, and faster RAM speed.
    You could use the same RAM, but since the new ones can accommodate a faster RAM module you would cause the machine to run slower by using the slower RAM from your old machine.
    You can use the same hard drives since both machines support SATA drives.
    On the other hand you could just be happy with what you have! It's probably more than you need.

  • UNINSTALL OLD HP AND INSTALL NEW ONE

    I want to uninstall my HP 2050 and install new HP 4510.  How do I do this?  I am 84 alone visually impaired and need simplest explanation.  thank you.

    Hello @airlinelady , I hope you are well
    I will do my best to help you uninstall your 2050 and install your new printer.
    Before I provide any instructions, I will need to know which Operating System you are running on your computer. All you need to do is click this link - Whats My OS, and when the windows pops up, it will tell you which Operating System you are running (Windows 7 for example).
    Also, I cannot find the printer you mentioned you want to install. Please check the model number of the printer and please clarify the information. This link will help you find the model number: How Do I Find My Model Number?
    Please write me back with those two pieces of information and I will help with uninstalling and reinstalling your printers.
    Have a wonderful day
    R a i n b o w 7000I work on behalf of HP
    Click the “Kudos Thumbs Up" at the bottom of this post to say
    “Thanks” for helping!
    Click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution!

  • HT4847 i have two backups of my old iphone and my new one, can i merge them together?

    i broke my iphone and backed it up before i sent off for a new one, when i got my new one it automatically made a new icloud, can i merge the two?

    No, you can't merge back ups.

  • How do i delete old bbid and create new one

    i created my blackberry id using the email from the company i was working and now am no longer working there as such the email is deactivated as it was belonging to that company so i cant access my bbw anymore i want to delete the acount and create a new one please help

    Without access to the original email you can't delete it. See this KB:
    http://www.blackberry.com/btsc/KB25464
    Can you get in to the account to change the email address on it? If you know the password you should be able to change it at www.bbid.com. See this KB:
    http://www.blackberry.com/btsc/KB28060
    If you can't change it, or delete it, then all you can do is create a new one. In order to log in to the same device with a new BBID you have to perform a security wipe on the device. See this KB:
    http://www.blackberry.com/btsc/KB26694
    1. Please thank those who help you by clicking the "Like" button at the bottom of the post that helped you.
    2. If your issue has been solved, please resolve it by marking the post "Solution?" which solved it for you!

  • Is there any difference between the old iPod and the new one?

    Hello everyone,
    first of all i'd like to thank you for reading my post:)
    My question is a simple one, i bought the new iPod Video 30 GB, and i came across a couple of questions while i was heading home with my new toy.
    How can i actually see the difference between this my new iPod and the one that they where selling before?
    Is there any visible difference amongst those two that i can notice?
    Thanks once again.

    Hello everyone,
    first of all i'd like to thank you for reading my
    post:)
    My question is a simple one, i bought the new iPod
    Video 30 GB, and i came across a couple of questions
    while i was heading home with my new toy.
    How can i actually see the difference between this
    my new iPod and the one that they where selling
    before?
    Is there any visible difference amongst those two
    that i can notice?
    The new update has a scroll feature on it to make it easier to search for songs on your ipod. It also lets you control the maximum volume your ipod can reach. It has better video quality as well. It lets you play games on your ipod (you have to download them from the Muisc Store)
    and thats about it! Have fun with your new ipod!
    kEat0n

  • I have a old ipod and a new one I haven't synced the new one but my computer says it's my old one and I've lost all my photos can I get them back?

    please help

    - Look in you computr, maybe you imported the photos into yur computer.
    iOS: Importing personal photos and videos from iOS devices to your computer
    - If they are in an iPod backup then restore from that backup. See the restore topic of:
    iOS: How to back up
    Go to iTunes>Preferences>Devices and see what backups and dates are listed.
    - If they are in the iTunes backup then get them from the backup by:
    Recover iPhone, iPad or iPod photos from backups with Picturescue
    - If you used PhotoStream then try getting them from your PhotoStream. See that topic of:
    iOS: Importing personal photos and videos from iOS devices to your computer

Maybe you are looking for