How I can do this update....merge ?

I have this query
select GORADID_ADID_CODE from GORADID a
where exists
(select * from goradid_cvt  b
where a.goradid_pidm = b.goradid_pidm
and a.GORADID_ADID_CODE <> b.goradid_adid_code  ) I need to do an update the GORADID_ADID_CODE on the table GORADID
needs to be update with the GORADID_ADID_CODE from the table goradid_cvt
I know a pl\sql precedure will do it , I know how to do it, but I just want to write a little code like merge, perhaps
The query can be change to
select GORADID_ADID_CODE from GORADID_cvt a
where exists
(select * from goradid   b
where a.goradid_pidm = b.goradid_pidm
and a.GORADID_ADID_CODE <> b.goradid_adid_code  )

Actually this does not work
I have in the table GORADID
GORADID_PIDM     GORADID_ADDITIONAL_ID     GORADID_ADID_CODE     GORADID_USER_ID     GORADID_ACTIVITY_DATE     GORADID_DATA_ORIGIN
1210136     United States     CTZ1                      Conversion                                                                      03/06/2012 16:25:12                     Recruitment Plus
1210136     United States     CTZ2                      James                                                                       03/07/2012 10:43:10     Jamesin the CVT table GORADID_cvt
GORADID_PIDM     CONVERT_PIDM     GORADID_ADDITIONAL_ID     CONVERT_ADDITIONAL_ID     GORADID_ADID_CODE     CONVERT_ADID_CODE     GORADID_USER_ID     CONVERT_USER_ID
1210136     B0020     United States     United States     CTZ2     CTZ2     James     James
1210136     B0020     Australia                        Australia                         CTZ1     CTZ1     James     JamesI need to ended with an update exactly as the one in the cvt table
This is the code
MERGE INTO    goradid        dst
USING   (
SELECT   goradid_pidm
        ,        SUBSTR(A.goradid_adid_code,1,4) 
       ,        INITCAP(a.GORADID_ADDITIONAL_ID) aDDITIONAL_ID
       ,a.GORADID_ACTIVITY_DATE
       ,A.GORADID_USER_ID
       ,a.GORADID_DATA_ORIGIN
        FROM     goradid_cvt    a
       WHERE A.GORADID_CVT_STATUS LIKE 'U%'
     AND   EXISTS (
                             SELECT  1
                FROM    goradid   b
                    WHERE    a.goradid_pidm         = b.goradid_pidm
                 AND b.GORADID_ADID_CODE like 'C%'
                AND A.GORADID_PIDM = 1210136
                AND    substr(a.goradid_adid_code,1,4) !=  substr(b.goradid_adid_code,1,4))
                )  SRC
              ON    (src.goradid_pidm = dst.goradid_pidm)
             WHEN MATCHED THEN UPDATE
               SET  dst.goradid_adid_code = dst.goradid_adid_code,
                       dst.goradid_user_id =    dst.GORADID_USER_ID,
                       dst.goradid_additional_id = dst.goradid_additional_id,
                        dst.goradid_activity_date = trunc(sysdate),
                       dst.goradid_data_origin =  'James1'
               SELECT COUNT(*) ,
                       GORADID_CVT_STATUS
                       FROM  GORADID_CVT
                       GROUP BY  GORADID_CVT_STATUS the select stament returns
SELECT   goradid_pidm
        ,        SUBSTR(A.goradid_adid_code,1,4) 
       ,        INITCAP(a.GORADID_ADDITIONAL_ID) aDDITIONAL_ID
       ,a.GORADID_ACTIVITY_DATE
       ,A.GORADID_USER_ID
       ,a.GORADID_DATA_ORIGIN
        FROM     goradid_cvt    a
       WHERE A.GORADID_CVT_STATUS LIKE 'U%'
     AND   EXISTS (
                             SELECT  1
                FROM    goradid   b
                    WHERE    a.goradid_pidm         = b.goradid_pidm
                 AND b.GORADID_ADID_CODE like 'C%'
                AND A.GORADID_PIDM = 1210136
                AND    substr(a.goradid_adid_code,1,4) !=  substr(b.goradid_adid_code,1,4))
                )  SRC
{code)
returns1210136     CTZ1     Australia      3/7/2012     James     James
when I run the merge updates the two records, I nned to ended upating the  
I need to update the table GORADID like this GORADID_PIDM     CONVERT_PIDM     GORADID_ADDITIONAL_ID     CONVERT_ADDITIONAL_ID     GORADID_ADID_CODE     CONVERT_ADID_CODE     GORADID_USER_ID     CONVERT_USER_ID
1210136     B0020     United States     United States     CTZ2     CTZ2     James     James
1210136     B0020     Australia      Australia      CTZ1     CTZ1     James     James
Edited by: 893973 on Mar 7, 2012 8:55 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • How I can do this update, when I have two records (one primary key, no seq)

    How I can do this update in pl\sql
    Here is the table with some data
    CREATE TABLE INSERT_TE
    PIDM        VARCHAR2(8),
    FORM_ID     VARCHAR2(2),
    TEACHER     VARCHAR2(30)
    INSERT into INSERT_TE
    PIDM,
    FORM_ID,
    TEACHER
    SELECT
    '1106651',
    'TE',
    'Teacher, Alber Howard'
    from dualcommit;
    INSERT into INSERT_TE
    PIDM,
    FORM_ID,
    TEACHER
    SELECT
    '1106651',
    'TE',
    'Teacher, Alber2 '
    from dualcommit;
    INSERT into INSERT_TE
    PIDM,
    FORM_ID,
    TEACHER
    SELECT
    '2321241',
    'TE',
    'Teacher, Silly Billy '
    from dualcommit
    You are going to ended with something like this: In a cursor..
    PIDM     FORM_ID     TEACHER
    1106651     TE     Teacher, Alber Howard
    1106651     TE     Teacher, Alber2
    2321241     TE     Teacher, Silly Billythen I need to update a table
    if the there is only one record like this one 2321241 TE Teacher, Silly Billy
    not problem I do this
    UPDATE   saturn.sarchkl
             SET
             sarchkl_receive_date = SYSDATE,
             sarchkl_activity_date = SYSDATE,
             sarchkl_source = 'U',
             sarchkl_source_date = SYSDATE
             WHERE
              sarchkl_pidm = v_pidm3
              AND sarchkl_receive_date IS NULL
              AND sarchkl_term_code_entry = p_term
              AND sarchkl_admr_code = 'REC1'But if there is a PIDM (pk) with two records
    PIDM FORM_ID TEACHER
    1106651 TE Teacher, Alber Howard
    1106651 TE Teacher, Alber2 I need to do 2 updates (notice the AND sarchkl_admr_code rec1 for the firs and rec2 for the second
    The first record should update the table when the condition is sarchkl_admr_code = 'REC1' and the second record with the
    condition is sarchkl_admr_code = 'REC2'
    UPDATE   saturn.sarchkl
             SET
             sarchkl_receive_date = SYSDATE,
             sarchkl_activity_date = SYSDATE,
             sarchkl_source = 'U',
             sarchkl_source_date = SYSDATE
             WHERE
              sarchkl_pidm = v_pidm3
              AND sarchkl_receive_date IS NULL
              AND sarchkl_term_code_entry = p_term
              AND sarchkl_admr_code = 'REC1'and
    UPDATE   saturn.sarchkl
             SET
             sarchkl_receive_date = SYSDATE,
             sarchkl_activity_date = SYSDATE,
             sarchkl_source = 'U',
             sarchkl_source_date = SYSDATE
             WHERE
              sarchkl_pidm = v_pidm3
              AND sarchkl_receive_date IS NULL
              AND sarchkl_term_code_entry = p_term
              AND sarchkl_admr_code = 'REC2'I am doing this in pl\sql, I don't have a sequence in the table INSERT_TE, how I know that the first record in
    1106651 TE Teacher, Alber Howard
    1106651 TE Teacher, Alber2 update a rec1 and the second updates when sarchkl_admr_code = 'REC2',
    I guess I can create a sequence, but I am inserting a table from a select satement, I am getting the error
    ORA-02287: sequence number not allowed here, when I try to do the following:
    INSERT INTO SYTEACH
    SYTEACH_PIDM,
    SYTEACH_ID,
    SYTEACH_TEACHER,
    SYTEACH_SEQ
    SELECT  
          DISTINCT
          spriden_pidm,
          sarchkl_admr_code,
          szsform_form_id,
          szsform_schl_off_type||', '||szsform_schl_off_firstname||' '||szsform_schl_off_lasttname teacher,
           SZSFORM_SEQ.NEXTVAL
            FROM   saturn_midd.szsform, saturn.spriden, saturn.sarchkl
           WHERE       spriden_ntyp_code = 'CAPP'
                   AND szsform_common_app_id = spriden_id
                   AND spriden_pidm = sarchkl_pidm
                   AND sarchkl_admr_code = 'REC1'
                   AND szsform_form_id = 'TE'
    What is the simple way of doing this update..

    Hi,
    you said:
    >
    But if there is a PIDM (pk) with two records
    PIDM FORM_ID TEACHER
    1106651 TE Teacher, Alber Howard
    1106651 TE Teacher, Alber2
    >
    No! pks are unique! (otherwise we don't call them pk)
    For your table you could define a unique like this:
    PIDM column + a sequence. (new column):
    ALTER TABLE INSERT_TE ADD(TEACH_SEQ NUMBER)
    UPDATE INSERT_TE x
       SET TEACH_SEQ =
              (SELECT n
               FROM   (SELECT ROWID rid,
                              ROW_NUMBER() OVER(PARTITION BY pidm ORDER BY TEACHER) n
                       FROM   INSERT_TE t) s
               WHERE  s.rid = x.ROWID)
    PIDM     FORM_ID     TEACHER     TEACH_SEQ
    1106651     TE     Teacher, Alber Howard      1
    1106651     TE     Teacher, Alber2       2
    2321241     TE     Teacher, Silly Billy      1I need to do 2 updates (notice the AND sarchkl_admr_code rec1 for the firs and rec2 for the second
    The first record should update the table when the condition is sarchkl_admr_code = 'REC1' and the second record with the condition is sarchkl_admr_code = 'REC2'
    >
    normally no.
    but you can (now) do
    select PIDM, FORM_ID, TEACHER, 'REC'||TEACH_SEQ TEACH_SEQ from INSERT_TE
    PIDM     FORM_ID     TEACHER     TEACH_SEQ
    1106651     TE     Teacher, Alber Howard     REC1
    1106651     TE     Teacher, Alber2      REC2
    2321241     TE     Teacher, Silly Billy      REC1and use the last column for you update ...
    Edited by: user11268895 on Aug 20, 2010 2:01 PM

  • My iPod touch is not connecting to iCloud account, under iCloud settings has old email account and username that I have since updated and are working correctly on my iPad, any idea how I can reset this?

    My iPod touch is not connecting to my iCloud account, under iCloud settings it  has my old email account and username that I have since updated and are working correctly on my iPad, any idea how I can reset this on the iPod or otherwise? This old account info keeps coming back on my iPod and messing up access to my apple account and now the icloud. last time a system restore needed to be done to fix it....

    It won't give me the option to sign out of the old account, it's that light grey color that you can't click on. And since it has the old email address that it's telling me to go into to verify the account, I can't actually change it... I'm stuck

  • When ı update firefox 7 to 8 I can not enter the facebook site, when I try it, it says Uyumsuz bir internet tarayıcısı kullanıyorsun. ( it means in english : you are using an unsuportted web browser) how I can solve this problem?

    when ı update firefox 7 to 8 I can not enter the facebook site, when I try it, it says Uyumsuz bir internet tarayıcısı kullanıyorsun. ( it means in english : you are using an unsuportted web browser) how I can solve this problem?

    Step by step, how did you arrive at seeing this agreement?

  • In Pages 09 we can do Mail Merge and Import Styles from a document. Can someone please explain how we can do this with the new version of Pages 5.1. Even Apple solutions are only valid for Pages Version 09. What a DOWN GRADE!

    In Pages 09 we can do Mail Merge and Import Styles from a document. Can someone please explain how we can do this with the new version of Pages 5.1. Even Apple solutions are only valid for Pages Version 09. What a DOWN GRADE! Thank god Pages 09 is still there.

    …and the other 98 missing features.
    Just use Pages '09, which should be in your Applications/iWork folder.
    Rate/review Pages 5 in the App Store.
    Peter

  • While updating iphone, itune gave me error of 1015 which tells that my iphone is much better than from which that i am updating. But now my iphone is still in restoring mode how i can resolve this problem.please tell me

    while updating iphone, itune gave me error of 1015 which tells that my iphone is much better than from which that i am updating. But now my iphone is still in restoring mode how i can resolve this problem.please tell me

    I just had the same problem with my iphone, only thing i could do was completely restore factory settings, lost a bunch of pics and contacts in the process... hope you have better luck than me

  • I have a problem .. I can not download and update some applications from App Store as it asked me for apple ID I don't know this email.. How I can solve thi problem

    I have a problem .. I can not download and update some applications from App Store as it asked me for apple ID I don't know this email.. How I can solve thi problem

    All content from iTunes is tied to the account that downloaded it, so the id that shows when trying to download updates should be the account that 'owns' that app. Do you recognise the id that is showing e.g. has anybody else downloaded or synced content to your iPad ?

  • Trying to update adobe flash, keep getting 'quit dashboard client'.  Everytime I try to, it pops back up.  Even after going to activity monitor and force quitting.  What is it and how can I quit it so I can install this update??

    Trying to update adobe flash, keep getting 'quit dashboard client'.  Everytime I try to, it pops back up.  Even after going to activity monitor and force quitting.  What is it and how can I quit it so I can install this update??

    Restart the computer from Apple menu.
    When restart dialog box appears, uncheck the box beside
    "Reopen windows when logging back in".

  • HT1414 i keep getting a message saying 'the iphone software update server could not be contacted' when trying to restore my iphone. Any ideas on how I can rectify this? Thank you

    i keep getting a message saying 'the iphone software update server could not be contacted' when trying to restore my iphone. Any ideas on how I can rectify this? Thank you

    Thank you. No my phone hasnt been jailbroke, therefore I'll keep trying.

  • Updating iphone 4 to iOS 5 - while doing the Backup I receive an error message no 402636788 - backup has failed. Can anybody tell me what this means or how I can fix this?

    Updating iphone 4 to iOS 5 - while doing the Backup I receive an error message no 402636788 - backup has failed. Can anybody tell me what this means or how I can fix this?
    I am working on a Win 7 Machine and I have disabled all Firewall and Antivirus Tasks as this caused problems on an other update.

    Well - I synced before - that was successful - but I am a bit scared to ignore this error and just to continue? You think I should ignore that?

  • Keep getting a mail pop up "enter password for account "SBC." ATT says I need to update my Mac mail server program. Anyone know how I can do this?

    I keep getting an annoying pop up for mail "Enter password for account "SBC."  I enter my password but it still pops up. But I can still get my mail when I click on "Get mail."  I called ATT and they said they are aware of the problem with Mac users and that I have to update my Mac Mail server program. Anyone know how I can do this? They want to charge me.

    RE: "Mail, Contacts and Calendars preferences can't connect to the Yahoo account "bellsouth.net".
    I recently changed my ATT U-Verse password…and Mail quit working… it wouldn't send or receive, Safari worked fine.  I tried to send an email and a warning message popped up, "Mail, Contacts and Calendars preferences can't connect to the Yahoo account "bellsouth.net". In smaller type the next sentence read, "Enter the password for user [email protected]". The Password box was highlighted in blue so I just typed in my new password and my email message was immediately sent…but… I still couldn't receive messages AND the above "can't connect" warning message kept popping up on the screen at random.
    Here's the Fix that worked for me. (The problem is that the new password was changed/updated on the keychains "smpt.att.yahoo.com" name-but- the name "pop.att.yahoo.com" didn't update to my new password).
    Go to your Utility windows and select Keychain Access. Under Category select Passwords. Now check your password for your current (newest dated) name, "smpt.att.yahoo.com". Now check the password under, "pop.att.yahoo.com". Mine wasn't the same as my newest password found in my
    "smpt.att.yahoo.com" window so I deleted my old password in the "pop.att.yahoo.com" window and typed in my new password, then selected "Save Changes". MY MAIL NOW WORKED…and no more warning messages cropped up. Problem was fixed.

  • Since updating my 4s with the new 7.0.2 my front camera is not working, all I see is blurred colors. Anyone know how I can fix this?

    since updating my 4s with the new 7.0.2 my front camera is not working, all I see is blurred colors. Anyone know how I can fix this?

    Yes... remove your finger from the camera lense.

  • When I updated my Iphone my naviogon app was erased, and I can't figure which one I had purchased. Does anyone have any ideals how I can figure this out.

    When I updated my Iphone my naviogon app was erased, and I can't figure which one I had purchased. Does anyone have any ideals how I can figure this out.

    App Store > Updates > Purchased > Not On This iPhone.
    Should be in the list.
    tt2

  • I am having a issue installing Adobe Acrobat XI.  I am running Windows 8.1. When  go to install it gets an error.  The error is with transform in registry and will not install product. I am looking at how I can fix this registry problem.

    I am having a issue installing Adobe Acrobat XI.  I am running Windows 8.1. When  go to install it gets an error.  The error is with transform in registry and will not install product. I am looking at how I can fix this registry problem.
    I have tried to uninstall all Abode Acrobat installations but one file remains and refuses to be uninstalled. It gives me this error : Error applying Transforms . Verify that specified paths are valid. It was installed on Sept 18 2014.  I have downloaded a Transform update but it tells I do not have a Adobe Acrobat product installed. 

    Hi all,
    Sylonious, did you manage to sort this problem out? I have been experiencing similar problems. I think my problem was because I had many different versions of JDKs. I have done a complete re-install. I would be really grateful to you (and anyone else) for help with this problem.
    I have re-installed JSDK1.4.2_03, set the "path" variable to "C:\JSDK1.4.2_03".
    When I compile using "javac" I get an error saying "javac" is not recognised.
    When I compile using "C:\j2sdk1.4.2_03\bin\javac Freq.java" no error is thrown.
    Every time I try to run a java file, I always get the NoClassDefFound error. When run with the -verbose option, files are loaded from C:\Program Files\Java\j2re1.4.2_03\bin - is this correct?
    I have removed all previous references to java in the registry editor.
    Please help !
    Regards,
    Vipul

  • When I close my iPhone and I want to open it to use it again, the opening process takes more than an hour, I regretted to buy the iPhone because of this problem that you do not suffer at all with Nokia,how I can solve this problem?

    When I close my iPhone and I want to open it to use it again, the opening process takes more than an hour, I regretted to buy the iPhone because of this problem that you do not suffer at all with Nokia,how I can solve this problem?

    mostafa182 wrote:
    ... how I can solve this problem?
    The Basic Troubleshooting Steps are:
    Restart... Reset... Restore from Backup...  Restore as New...
    Restart / Reset
    http://support.apple.com/kb/ht1430
    Backing up, Updating and Restoring
    http://support.apple.com/kb/HT1414
    If you try all these steps and you still have issues... Then a Visit to an Apple Store or AASP (Authorized Apple Service Provider) is the Next Step...
    Be sure to make an appointment first...

Maybe you are looking for