Update duplicate records in pl/sql with each different name

this is my table newemp
  EMPNO ENAME      JOB
   7000 ELLISON    OWNER
   7369 SMITH      CLERK
   7499 ALLEN      SALESMAN
   7521 WARD       SALESMAN
   7566 JONES      MANAGER
   7654 MARTIN     SALESMAN
   7698 BLAKE      MANAGER
   7782 CLARK      MANAGER
   7788 SCOTT      ANALYST
   7839 KING       PRESIDENT
   7844 TURNER     SALESMAN
  EMPNO ENAME      JOB
   7876 ADAMS      CLERK
   7900 JAMES      CLERK
   7902 FORD       ANALYST
   7934 MILLER     CLERKI WANT TO UPDATE ALL THOSE REPEATING JOBS
E.G IF THERE ARE FOUR SALESMAN IT SHOULD BE LIKE DIS SALE4,SALE5,SALE6,SALE7,SALE8. AND 2 ANALYST = ANA2,ANA3
AND IF THE RECORD IS ONLY ONCE THN NO CHANGE.
I DID THIS BY USING STORED PROCEDURE FOR EACH DISTINCT SALE BUT I WANT TO DO IN A SINGLE PROCEDURE
THE STORED PROCEDURE THAT I HAVE DEVELOPED ID LIKE THIS:-
create or replace procedure sp_duptest
is
x number(20);
y number(3);
j Number := 0;
cursor z is select empno from  newemp where job = 'CLERK';
begin
select empno
    into x
  from newemp where job = 'CLERK' ;
exception
when no_data_found then
null;
when too_many_rows then
begin
select count(job) into y from newemp where  job='CLERK';
y := y-1;
for i in z
loop
y := y+ 1;
if y>1 then
update newemp
    set job = 'CLE'||y
    where empno = i.empno;
else
update newemp set job ='clerk';
end loop;
commit;
end;
end;Edited by: BluShadow on 02-Aug-2011 10:48
added {noformat}{noformat} tags.  Please read {message:id=9360002} to learn to do this yourself.
Edited by: Aviral on Aug 2, 2011 2:50 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Something like this perhaps?
SQL> create table emp2 as select * from emp;
Table created.
SQL> ed
Wrote file afiedt.buf
  1  update emp2 set job = (select job
  2                         from (select empno
  3                                     ,substr(job,1,5)||to_char(row_number() over (partition by job order by empno),'fm09') as job
  4                               from emp2) t
  5*                        where t.empno = emp2.empno)
SQL> /
14 rows updated.
SQL> select * from emp2;
     EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
      7369 SMITH      CLERK01         7902 17-DEC-1980 00:00:00        800                    20
      7499 ALLEN      SALES01         7698 20-FEB-1981 00:00:00       1600        300         30
      7521 WARD       SALES02         7698 22-FEB-1981 00:00:00       1250        500         30
      7566 JONES      MANAG01         7839 02-APR-1981 00:00:00       2975                    20
      7654 MARTIN     SALES03         7698 28-SEP-1981 00:00:00       1250       1400         30
      7698 BLAKE      MANAG02         7839 01-MAY-1981 00:00:00       2850                    30
      7782 CLARK      MANAG03         7839 09-JUN-1981 00:00:00       2450                    10
      7788 SCOTT      ANALY01         7566 19-APR-1987 00:00:00       3000                    20
      7839 KING       PRESI01              17-NOV-1981 00:00:00       5000                    10
      7844 TURNER     SALES04         7698 08-SEP-1981 00:00:00       1500          0         30
      7876 ADAMS      CLERK02         7788 23-MAY-1987 00:00:00       1100                    20
      7900 JAMES      CLERK03         7698 03-DEC-1981 00:00:00        950                    30
      7902 FORD       ANALY02         7566 03-DEC-1981 00:00:00       3000                    20
      7934 MILLER     CLERK04         7782 23-JAN-1982 00:00:00       1300                    10
14 rows selected.
SQL>

Similar Messages

  • Script for generate randomize administrator password which make log file to recorded new administrator password with associated computer name on it

    Hi
    I Need VDS script in order to change domain client local administrator password in my domain ,and put this script in startup script via group policy, but for security purpose  I want to randomize local administrator password and log new password
    set for each computer on a text file, I want to over write the old password of eachcomputer in log file with new one in order to have the update log file ,my support team some times need administrator password for troubleshooting.
    I need a script for generate randomize administrator password  which make log file to recorded new administrator password with associated computer name on it and each time new administrator password set it over write the old record on
    the log file and update the content of log file automatically.
    Regards

    Hi
    I need a script for generate randomize administrator password  which record new password on a  log file with associated computer name  and each time new administrator password set for a computer it  over write the old record
    on the log file and update the content of log file automatically.
    Regards

  • App Store error: "This update is for an app downloaded with a different apple id"

    When trying to update PopClip, I get the following two errors:
    "This update is for an app downloaded with a different Apple ID. Sign in with that Apple ID and try again"
    After clicking OK, I receive the next error:
    "There was an error in the App Store. Please try again later. (100)"
    This app was not downloaded using a different Apple ID. I have been able to update other apps successfully.
    Any ideas?

    I keep getting error 100 when trying to download 1password4 updates

  • HT1727 I am trying to sync my iPhone/iPad and I am getting a message "This update is for an app download with a different Apple ID.  Sign in with that ID and try again."  I have tried everthing including resetting my apple ID and password.  Ideas?

    I am trying to SYNC my iPhone and mine iPad and I am getting the message "
    This update is for an app download with a different Apple ID.  Sign in with that Apple ID and try again."  I do not have another apple ID.  I have tried everything including resetting my password.  Everything I can think of.  Ideas?

    Hi julia151,
    I would first use this article to make sure any extra Apple IDs were not accidentally created when signing up for one of Apple's services:
    Apple ID: Finding your Apple ID
    http://support.apple.com/kb/HT5625
    If you can't locate one, try using this article to delete and redownload your app:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    http://support.apple.com/kb/ht2519
    Cheers!
    - Ari

  • Error: This update is for an app downloaded with a different Apple ID. Sign in with that Apple ID and try again.

    I am trying to update iphoto but I have been receiving the error message "This update is for an app downloaded with a different Apple ID. Sign in with that Apple ID and try again." All other IDs I have had NO LONGER work or aren't activated. I deleted the current verison of iphoto, but it still won't work, so now I have no iphoto whatsoever...any ideas? my current ID is my ONLY ID I have.

    Apple Closed all other accounts and the logins DO NOT WORK!
    Apple would only have closed an account if you called Apple and formally requested that be done. Otherwise, the account is still there.
    I was able to delete my old apps and redownload them onto my computer which switch the Apple ID it was under, but I am not having the same luck with iPhoto.
    Those would have been free apps that you "bought" again using your new Apple ID. iPhoto is a paid app and Apple will not transfer it to a different Apple ID.

  • How do I set up my second ipad with a different name?

    My second iPad keeps automatically starting up with my previous iPad's name. I don't want that to happen. I want to set this one up with a different name. How do I do that?

    Settings>General>About>Name. You can type any name that you like in there.

  • Have a new computer with a different name.  New computer does not reconize the ipod classic device?

    Have a new computer with a different name.  New computer does not recognize the ipod classic device? How can I remody this problem

    Add '''DOZEN''S''''' of giggs of ram, switch from hard disk to SSD or add inline SSC.
    Consult some free experts about potential malware infestation: BleepingComputer.com
    In windows control panel is an option to rate performance of your computer. What number does the applet rate your computer?
    http://windows.microsoft.com/en-US/windows7/What-is-the-Windows-Experience-Index

  • Deploying a copy of existing database with a different name on the same server

    I am a developer(an inexperienced one) trying to understand what is the best way to deploy a brand new database with
    the exact same schema as an existing DB on the same server, but with a different name. I want to preserve the data in all reference tables which I can do by having the relevant post-deployment scripts run after the deployment. 
    What I can't understand is how the project should be set up to deploy database Customer_2 if database Customer_1 exists on
    this server - the Visual Studio project contains DB Customer and I need to find a way to be able to deploy Customer_N (but without creating N identical DB's in the project). I checked a ton of articles and blogs, and feel dumb asking this question but haven't
    been able to understand it yet. Any help would be appreciated.

    Hello,
    Maybe the TargetDatabase and the DeployToDatabase properties can help you.
    http://www.asp.net/web-forms/tutorials/deployment/web-deployment-in-the-enterprise/deploying-database-projects
    You can deploy multiples databases from one project if you want, as explained on the following
    post:
    http://stackoverflow.com/questions/1544966/gdr-deploying-multiple-database-targets-with-one-project
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • Updating vs. Deleting Folder files with the same name

    Hello all,
    Bear with me as I try to explain this.
    First off, I'm a long time Windows user who just happily converted to Mac. I'm loving my mac so far, but I've run into a snag that I hope to get clarification on.
    Let me set up a scenario on how this works with Windows.
    Let's say I have two folders/root directories labeled as today's date "20100729" with image files in them. Each folder has different picture file names. In other words, the files in each of folders are different. The only thing that is the same is the Folder/Directory name, which in this case is "20100729".
    So, in a windows environment let's say that each of these folders (with the same name) are located on 2 hard drives (A & B). If I take the folder from drive "A" and drop it in drive "B", windows seamlessly combines the files from both folders into one.
    On the flip side, when doing the same thing on my Mac, the entire folder contents from drive B gets replaced from drive A, even though the file names are all different. Which is very annoying.
    If you understand what I'm saying and know of a way for this to work the "Windows" way please let me know.
    Thanks in advance for your help. Let me know if you need further clarification.
    Cheers,
    - Jeff

    Use the ditto command in the Terminal, which is in the /Applications/Utilities/ folder; for instructions on its use, enter 'man ditto' without the quote marks into the Terminal prompt.
    (53065)

  • HT201079 Buy app with acct X, then setup acct Y as shared and swithc a device to use acct Y. No you cannot update app because it was "purchased with a different account" even though they are shared

    Prior to Family Share we had devices sharing a common account for purchases
    We setup Family share an switch the App Store account on some devices to those shared accounts
    Now when we try to update existing apps it refuses stating that they were purchased with a different account
    Well yes they were, but it is a shared account.
    Do we really need to un-install all apps, loosing any data, then reinstall using the shared account ?
    If so I think Family share is a non-starter.

    How to turn your computer into a Virtual (Personal)Router.
    Our hotel the Grand Oasis Cancun provided internet for only 36 hours and you could only use it on one device which comes to my next option as using your Laptop as a Personal Router to broadcast WiFi to any devices near your computer. Our room was on the Second level of the Pyramid at Grand Oasis and I was able to access it while at the VIP lounge below our room. Before our supposedly free internet service ended.
    I attempted using the hotel next door since I was getting a good signal from the Omni Hotel. They offered complimentary 24hr internet access using your browser as a way to track your use. Once you find the signal of the Omni it will open your browser I used Google Chrome, after it opens you go threw a few simple steps and your ready.
    I learned that after the 24 hours are up all you have to do is disconnect from their network, just run Ccleaner(free program) then find the Signal of the hotel and you will be given another 24 hours. What Ccleaner(<--download there) does is clears anything attached to your browser ie cookies temp files etc. it cleans your browser history giving you a way of not paying for the hotel fee of internet and giving you free WiFi. this is only if you are next to the Omni hotel :).
    What you need to download to turn your computer into a hotspot need to say is this little easy to use program Virtual Router. Once it has download test at your home to make sure it works with you devices. This will work with Tablets, Phones and other computers that cant find the Omni WiFi signal. Your welcome. To use it, is simple. Open program>make a password>select WiFi and start VR.

  • Error updating Process Form: Same Column exist with a different variant

    Hi All,
    I have a process form of a resource with following fields :
    Name VariantType Length FieldLabel FieldType Order
    UD_EDIR_BWUSER   boolean       1          BWUser    Checkbox      25
    UD_EDIR_ISUUser    boolean       1          ISUUser    Checkbox      26
    Now, I have to changes these field from boolean to string. For that, I created a new process form version and update like this:
    1. Delete these fields first.
    2. Add two new fields:
    UD_EDIR_BWUSER String 4 BWUser Textfield 25
    UD_EDIR_ISUUser String 4 ISUUser Textfield 26
    Now, when I tried saving the form, I got following error
    Same Column exist with a different variant in current or previous form.
    I also tried creating again a new version of process form and tried updating these field instead of re-creating them but I was able to update the FieldType only ( not able to update the Variant type and length).
    If anyone know how to resolve this issue, please reply.
    Cheers,
    Sunny

    Hi Rajiv,
    Thanks for the reply. I re-created these field in a new version but gave a different name this time like this:
    UD_EDIR_SAP_BW_USER String 4 SAPBWUser TextField 25
    UD_EDIR_SAP_ISU_USER String 4 SAPISUUser TextField 26
    and it worked for me.
    Cheers,
    Sunny

  • How do you update an apps on iPad when it says "this update is for an app downloaded with a different Apple ID.  I have tried both mine and my husbands ID and it still won't work?

    I have tried to update an apps on my mini iPad but it says this update is for an app downloaded with a diffrent Apple ID.  Sign in with that Apple ID and try again.  I have tried both mine and my husbands ID and it still does not work.

    We'll you can either do as Niel suggested, delete it and download it again with one of the two Apple ID's, or if you want to be sure that one of the two you actually bought the app, look in the purchased tab of the App Store when you are signed into your ID and see if the app shows up in there and if not, then sign into your husband's ID and see if the app shows up with his ID.
    After you you figure out who actually bought the app, use that ID to update it. If it still doesn't work, try signing out of that ID, restart the iPad, sign in again and try to update again.

  • How do updates work if you download Apps with 2 different itunes accounts?

    I am wondering what will happen when Apps need to be updated and they have been purchased on the same iPad but with two different iTunes accounts?
    One person is signed in and purchases Apps and then signs out. The other person signs in and make purchases with another account.
    When updates are available, you are asked to put in a password. Does it matter which password is used??
    Will this be workable?
    Thanks,
    Prea

    Your purchases are linked to your own iTunes account so in order to update you would have to log in with the one account to update the apps purchased from that account, sign out, then sign in with the second account in order to update those apps purchased with the second account.
    Yes it matters which password you use. Separate accounts will require separate passwords in order to sign in and update apps.
    Message was edited by: Demo

  • "This update is for an app downloaded with a different Apple ID. Sign in with that Apple ID and try again." But i've only ever had one apple i.d ever .... HELP!

    I bought this computer brand new from the Apple Store and when i brought it home a few apps needed to be updated. when i tried it kept telling me that another Apple I.d was used. Ive only had one Apple I.d EVER.

    What are the apps that needed updating? What app is asking for a different Apple ID?
    SInce it's new, I would return it. It's starting to sound used.
    BTW, your MBP isn't running on iOS 7.

  • How to keep same database with two different names in SharePoint 2013 for two different applications

    Hi All,
    I have very strange situation.
    I had SP2010 production database(wss_content_contoso) migrated to SP13 few months back to migrate one site collection only while I have 15 site collections stored in this database and created a site contoso.com
    Now, I want to migrate same(wss_content_contoso) SP2010 database to SP13 and want to create contoso2.com.
    I changed database name from wss_content_contoso to wss_content_contoso2 and assigned newID during mount process.
    After this exercise, I don't see any site for contoso2.com and issue seems to be the same database. 
    My question is!!!!
    How I can keep both databases(actually same database with different names) and run both application simultaneously?
    Any help appreciated!!
    Thank you,
    AM
    AM Senior SharePoint Consultant

    You need to run Backup-SPSite/Restore-SPSite on each Site Collection you want to 'duplicate'. You cannot restore the same Content Database to the same farm as the Site Collections have the same GUID, which is stored globally for the farm.
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

Maybe you are looking for