Compare and update the same Column

Hi ,
SQL> select * from
v$version;
BANNER
Oracle Database 10g Express
Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 -
Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows:
Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 -
Production
I am having an issue in Updating the column in a Table.......
What i am trying to do is ...Compare 2 column and then update one of the compared column....
Table 1 Name: TEST1 _
bq. LNID \\ NEW_AN8 \\ OLD_AN8 \\ OLD_DESC \\ 2 \\ 123002 \\ 100001 \\ C2370 \\ 125846 \\ 100001 CS24 \\ 123024 \\ 100028 \\ C2392 \\ 125868 \\ 100028 CS25 \\ 123025 \\ 100036 C2393 \\ 125869 \\ 100036 CS26 123026 \\ 100116 \\ C2394 \\ 125870 \\ 100116 \\ CS
TEST2_
SZAN8     SZAN82     SZAN86     SZAT1
123,002 100,001 100,001 C
125,846 100,001 100,001 CS
123,024 100,028 100,028 C
125,868 100,028 100,028 CS
125,869 100,036 100,036 CS
123,025 100,036 100,036 C
125,870 100,116 100,116 CS
123,026 100,116 100,116 C
I wanted to update SZAN82 of TEST2 table..... based on the SZAT1 value ...
I shud be able to pick the CS type record first then the C type record and the SZAN82 value and check whether it is present in the TEST1 table if it present then I shud update the AN82 value,,
UPDATE LPLSCHEMA.LPL_F0101Z2_CUSTOMER C SET (SZAN82)=
(SELECT NEW_AN8 FROM LPL_CROSS_CUSTOMER B,LPL_F0101Z2_CUSTOMER C WHERE C.SZAT1='CS' AND B.OLD_DESC='CS'and C.szan82=B.old_an8);
I tried like tis .... i got an Error sub query more than one rows ...
Thanks in Advance !!
Ananda
Edited by: Ananda on Jan 2, 2009 6:30 PM
Edited by: Ananda on Jan 2, 2009 6:30 PM
Edited by: Ananda on Jan 2, 2009 6:34 PM
Edited by: Ananda on Jan 2, 2009 6:37 PM

Or:
UPDATE  LPLSCHEMA.LPL_F0101Z2_CUSTOMER C
  SET   SZAN82 = (
                  SELECT  NEW_AN8
                    FROM  LPL_CROSS_CUSTOMER B
                    WHERE C.SZAT1='CS'
                    AND B.OLD_DESC='CS'
                    AND C.szan82=B.old_an8
  WHERE (SZAT1,szan82) IN (
                            SELECT  'CS',
                                    old_an8
                              FROM  LPL_CROSS_CUSTOMER B
                              WHERE B.OLD_DESC='CS'
                          );Or, depending on your version and table structure:
UPDATE  (
         SELECT  C.SZAN82,
                 B.NEW_AN8
           FROM  LPL_CROSS_CUSTOMER B,
                 LPL_F0101Z2_CUSTOMER c
                 WHERE C.SZAT1='CS'
                 AND B.OLD_DESC='CS'
                 AND C.szan82=B.old_an8
  SET   SZAN82 = NEW_AN8
/SY.

Similar Messages

  • Insert a field and update the same row.

    Hi,
    I am inserting a value in a row.
    And later within a cursor loop I am trying to update the same row. But it is not working....
    CREATE OR REPLACE procedure Del_Note_stage
    Is
    v_delNote Delivery_Note.Delivery_Note_id%type;
    Cursor C1 is Select Heading_Name,File_Data from Sqlload_Stage;
    Begin
    dbms_output.put_line('i am here a ');
    Select Delivery_Note_Id_Seq.nextval into v_delNote from dual;
    Insert into DELIVERY_NOTE_STAGING(Delivery_Note_ID,LUT,LUB,PROCESSED) Values(v_delNote,sysdate,'Config','N');
    commit;
    dbms_output.put_line('i am here b'||v_delNote);
    For sqlload_rec in C1
       Loop
        dbms_output.put_line(sqlload_rec.Heading_Name);
        dbms_output.put_line('Del Note Id is :'||v_delNote);
        update DELIVERY_NOTE_STAGING  set deployed_by='TOM' where delivery_note_id=v_delNote;
    End loop;
    End;

    But it is not working....Why not?
    Please read: http://tkyte.blogspot.com/2005/06/how-to-ask-questions.html
    Why are you updating after inserting?
    Just add deployed_by to the insert statement, or use a default value for that column.
    Also you don't need to select your Delivery_Note_Id_Seq.nextval from dual, just use it in your insert statement.
    Something like:
    Insert into DELIVERY_NOTE_STAGING(Delivery_Note_ID,LUT,LUB,PROCESSED,deployed_by )
    Values( Delivery_Note_Id_Seq.nextval,sysdate,'Config','N', 'TOM' /*or USER*/);

  • Possible? two users/computers to share and update the same calendar?

    We would like to have two people update the same calendar. How is this possible? Subscribers can't update?
    Thanks

    In short it isn't possible (currently). Subscribers cannot edit a calendar they subscribe to - it is read-only.
    See this thread for more detail: http://discussions.apple.com/thread.jspa?threadID=705054&tstart=45

  • Can I paste and keep the same columns and rows?

    Paste problems. I regularly download data from the Transport for London, Oystercard website. When I used Windows I could highlight and copy on their webpage (displayed in columns and rows) and when I pasted into Excel it pasted the data in the same format (columns and rows). With iPages when I try this it pastes everything into a single downwards column. Paste and Match style does not seem to alter this just the font etc. Am I able to paste in iPages in the same format as I copy.

    I'm guessing you're using Safari to access the web site. The problem is with Safari, not Pages (no "i") or Numbers. Safari just doesn't "understand" tables in web pages & puts lots of spaces and/or returns instead of the needed tabs. I long since gave up & use Camino or FireFox for copying the tables to Numbers or any other program I want the data separated by tabs. There are some web sites, Discover Card is one, that appear to have tables but the data doesn't copy as such.

  • Finding a combination of data in several rows and on the same column

    In a table I have two cloumn
    ID
    and
    ID6 that repersent joined account that have several partners ID
    for example:
    ID ID6
    ====== ===========
    11215 6100
    11152 6100
    11242 6101
    11523 6101
    11125 6101
    11254 6101
    there is about 60,000 rows
    I have a table with several ID in a row and I need to find the missing ID6 if it exist (not all ID are join account) and put it in that row if exist
    the table look like this
    11523,11125,11254, 11242
    11658,15662
    11458
    11215,11152
    there is about 5,000 rows
    I use plsql developer.
    How do I do that ?
    ELI

    Solution
    SELECT ID
            FROM T2
            MODEL
                RETURN UPDATED ROWS
                PARTITION BY (ROWNUM  RN)
                DIMENSION BY (0 I)
                MEASURES (ID)
                ( ID [FOR I FROM 1 TO NVL(LENGTH(REGEXP_REPLACE(ID[0],'[^,]','')),0) + 1 INCREMENT 1]
                  = REGEXP_SUBSTR(ID[0],'[^,]+',1,CV(I)))
    MINUS
    SELECT TO_CHAR(ID) ID
    FROM T1
    Demo
    SQL> WITH T1 AS (              SELECT 11215 ID,6100 ID6 FROM DUAL UNION ALL
      2                 SELECT 11152,6100 FROM DUAL UNION ALL
      3                 SELECT 11242,6101 FROM DUAL UNION ALL
      4                 SELECT 11523,6101 FROM DUAL UNION ALL
      5                 SELECT 11125,6101 FROM DUAL UNION ALL
      6                 SELECT 11254,6101 FROM DUAL
      7                 ), T2 AS (
      8                 SELECT '11523,11125,11254,11242' ID FROM DUAL UNION ALL
      9                 SELECT '11658,15662' FROM DUAL UNION ALL
    10                 SELECT '11458' FROM DUAL UNION ALL
    11                 SELECT '11215,11152' FROM DUAL
    12               )
    13  SELECT ID
    14          FROM T2
    15          MODEL
    16              RETURN UPDATED ROWS
    17              PARTITION BY (ROWNUM  RN)
    18              DIMENSION BY (0 I)
    19              MEASURES (ID)
    20              ( ID [FOR I FROM 1 TO NVL(LENGTH(REGEXP_REPLACE(ID[0],'[^,]','')),0) + 1 INCREMENT
    1]
    21                = REGEXP_SUBSTR(ID[0],'[^,]+',1,CV(I)))
    22  MINUS
    23  SELECT to_char(ID) id
    24  FROM T1
    25  /
    ID
    11458
    11658
    15662
    SQL>

  • Nsert/Update and Add Column at the same Table and at the "same" Time

    Hello,
    I want Insert/Update and Add Column at the same Table and at the "same" Time but in different sessions.
    Example:
    At first the "insert/update" statement:
    Insert into TestTable (Testid,Value) values (1,5105);
    After that the "add" statement:
    Alter table TestTable add TestColumn number;
    - sadly now I get the message: ORA-00054: resource busy and acquire with NOWAIT specified
    "insert/update" statement:
    Insert into TestTable (Testid,Value) values (2,1135);
    After that the execute commit.
    I don't know when the first session set the commit statement so I want that the DB the "Alter Table..." statement execute if it's possible.
    If it's possible I want to save a repeat loop with the "Alter Table..." statemtent.
    Thanks for ideas

    Well I want to walk in the rain without and umbrella and still stay dry, but it ain't gonna happen.
    You can't run a DDL statement against a table with transactions pending. Session 2 has to wait until session commits or rollbacks (or until the session is killed). That's just the way it is.
    This makes sense if you think about it. The data dictionary has to be consistent across all sessions. If session 2 was allowed to change the table structure whilst session 1 has a pending transaction then the database is in an inconsistent state. This is easier to see if you consider the reverse situation - the ALTER TABLE statement run by session 2 does a DROP COLUMN TESTID rather than adding a column: now what should happen to session 1's INSERT statement? You have retrospectively invalidated a statement that was perfectly legal when it was executed.
    If it's possible I want to save a repeat loop with the "Alter Table..." statemtent.Fnord.
    Cheers, APC

  • I updated Firefox and now it will not open at all. The hourglass shows that it's working but then nothing. I went to add/remove and removed mozilla and reinstalled it and still the same thing. It worked fine before I updated.

    I updated Firefox and now it will not open at all. The hourglass shows that it's working but then nothing. I went to add/remove and removed mozilla and reinstalled it and still the same thing. It worked fine before I updated. Now I can't even remove the program at all. Why is this happening?

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    Create a new profile as a test to check if your current profile is causing the problems.
    See "Basic Troubleshooting: Make a new profile":
    *https://support.mozilla.com/kb/Basic+Troubleshooting#w_8-make-a-new-profile
    There may be extensions and plugins installed by default in a new profile, so check that in "Tools > Add-ons > Extensions & Plugins" in case there are still problems.
    If that new profile works then you can transfer some files from the old profile to that new profile, but be careful not to copy corrupted files.
    See:
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox

  • I have 2 iphones syncing on one computer and on the same apple ID. Before i updatad my Itunes to the last available update and my Iphones to 5.01 i had no problem draging jpg. and mp3 files into my iphones DCIM folder (the picture folder that opens when c

    I have 2 iphones syncing on one computer and on the same apple ID.
    Before i updatad my Itunes to the last available update and my Iphones to 5.01
    i had no problem draging jpg. and mp3 files into my iphones DCIM folder (the picture folder that opens
    when conecting to Itunes). Since my updates Itune wont let me drag and drop any files' even pictures that
    were taken with my Iphone on 4.3.3.
    Please help as we have no itunes music in Israel, only apps and i cant copy any of my old music from my computer
    to my iphones.
    If it helps, i am using a pc with 32 bit windows 7.
    Other from the obove Itunes works fine and does sync pictures from my computer to my Iphone from "my pictures" folder.
    Thank you for your time
    Yoni Bliss
    [email protected]

    The title of my initial post is a bit misleading. I already took a chance deleting one of the iPhones, hoping if I deleted the wrong one, I can still reauthorize it (all with the same Apple ID acct, so not subject to 90-day waiting period, right?) The iTunes database just updated itself, and it says I have 4 "devices" "in the Cloud", but 5 "computers" associated w my account. How can I find out what computers are associated? Isn't there a list I can see? I dont have a clue what computers they might be. If I use the  "Deauthorize All" option, is it a pain to add them all back in. I assume I would have to log in from each computer to reauthorize each one. Would I have to be running the newest OS or version of iTunes to reauthorize? I think I have a PowerBook G4 Titanium with an older OS and iTunes. I'd like to keep that authorized, if possible.

  • I can't send emails from Mail. I have three different accounts set up and have the same problem with all. The mail just sits in my outbox. All worked fine until Yosemite upgrade. Recent update has not fixed problem.

    I can't send emails from Mail. I have three different accounts set up and have the same problem with all. The mail just sits in my outbox. All worked fine until Yosemite upgrade. Recent update has not fixed problem.

    I have been experiencing the same problem. My mail app won't even open on my Late 2011 Macbook Pro. It will show as open, but the app will never actually show up.

  • My iphone 6 connects to the car via bluetooth, the music works good, but the phone calles does not work.  It looks like it is working but doesn't.  I have tried in my Hyundai and a Dodge rent car and get the same results.  I updated the last 8.0.2.

    My iphone 6 connects to the car via bluetooth, the music works good, but the phone calls does not work.  It looks like it is working but doesn't.  I have tried in my Hyundai Sonata and a Dodge Dart rent car and get the same results.  I updated the last 8.0.2.  It worked the first day i had the phone, and then i updated to Ios 8.0.2 and it quit working.
    Now when i get in the car, it acts like it is connected and makes the same call it was on after syncing to bluetooth, but it really isn't on a call.  This is happening on both cars.
    Does anyone know if this is the phone and i need to take it to Apple or if there is an issue that Apple is working on getting a fix for?
    My son in law has the exact same phone as me, we both got the on 10/6, he had a Dodge Dart and his is working via bluetooth.
    Someone HELP please, as i consider this a safety issue by not having my calls go to bluetooth.

    We had the same problem, but figure out the solution.
    You MUST have at least 1 song added to your ITUNE!  After you add a free song, then everything else should work as normal!
    Hope this helps!

  • I keep getting an error when trying to update an app- cannot connect to store. I logged out from my account and tried to log back in and got the same error. I am doing all this from my phone since I no longer own a personal computer (only work)

    I keep getting an error when trying to update an app- cannot connect to store. I logged out from my account and tried to log back in and got the same error. I am doing all this from my phone since I no longer own a personal computer (only work) since I use iCloud and I tunes match

    YAY!!! Saved it in my Mac's Firefox Bookmarks for easy future access!
    Hope you are having a lovely afternoon today! I'm about ready to go bobo....I have an early meeting, and I don't want to oversleep! The nice part is that I work remotely, so I only have to wake up 15 minutes or so before the meeting.... I don't even use an alarm clock anymore (really, my iPhone alarm, which is much more pleasant), unless I have to get up at 6:30 or something....
    TMI?
    GB

  • Want to update a text file and reflect the same on iview immediately

    Dear friends,
    I have a text file in a repository path
    I could read each line and do some task.
    My query is for each line task, i would like to update a file (for me it is log file) and reflec the same on a iview in the same page
    sample code appreciated
    regards
    Kantha

    If the user backs up their device to either iCloud or Mac/PC, they can restore the app data from that backup.
    There's no need to do what you intend.

  • When i try installing photoshop from adobe creative cloud it says: fail on update, try again, i try again and says the same

    When i try installing photoshop from adobe creative cloud it says: fail on update, try again, i try again and says the same, any help?

    Try this link; follow the instructions carefully: Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6
    And also a troubleshooting page: https://helpx.adobe.com/creative-suite/kb/troubleshoot-install-logs-cs5-cs5.html
    Benjamin

  • HT201210 I am trying to update my iphone 5 to the newest version (7.4) but it says I do not have enough space on my computer to update, though I have 8GB. Shouldbnt this be more than enough space? I have tried every trouble shooting option and get the sam

    I am trying to update my iphone 5 to the newest version (7.4) but it says I do not have enough space on my computer to update, though I have 8GB. Shouldbnt this be more than enough space? I have tried every trouble shooting option and get the same pop up-

    Have you tried doing an over the air update on the iPhone instead?

  • HT1338 My Update for OS 10.8.4 is not updating. The update app keeps saying to update the same information and it never updates.  Help

    My Update for OS 10.8.4 is not updating. The update app keeps saying to update the same information and it never updates.  Help

    Exactly the same for me.  Have tried to update three times and my iMac has restarted (after apparently downloading the update) but the update has not been installed.
    My iMac is still at 10.8.3.

Maybe you are looking for

  • How to load the object library at run time from within the script.

    What i am trying to do from my library is that I wanted to load the object library file (.properties) file at run time through the script. I know that open script has a deprecated method "ft.loadObjectLibrary". Is there any other method other than th

  • Bridge will not start.

    Hi all, I have Adobe Bridge CS3, Windows Vista ultimate 32bit. When I start bridge from the desktop shortcut, or in the programs folder I get this error message "The procedure entry point sqlite3_prepare_v2 could not be located in the dynamiclink lib

  • How to get account expiry date for Oracle Directory Server?

    I need to get the account expiry date for Oracle Directory server. Which attribute stores this value? Please let me also know the attribute type and how to fetch it. Thanks, Subrat

  • What new features in Oracle 11g can Apps 11.5.10.2 benefit from ?

    hi there, we run Apps 11.5.10.2 on Solaris 10. I'm thinking of upgrading the RDBMS version from 10.2.0.4 --> 11.1.0.6 and I was wondering if anyone can reccomend some good features within the new 11g database to make use of. I'm aware of : - advanced

  • Problem in Parallel Processing

    Hi All, i had performed all the steps involved in parallel processing like creating Multiline Container Elements and creating Task. when i run my workflow all the workitems are created in workflow logs in completed state but in sbwp i can't find my w