Iterative query to fetch from one column and insert/update in another colum

i have a table with 5 columns as shown below
Devicedetails
userid ip deviceid makeby makedate
123 100.00.20.11 | 00002011 xyz 10/11/2009
456 102.03.21.12 | 02032112 def 11/12/2009
678 null 02032112 def 11/12/2009
896 111.22.33.44 02032112 def 11/12/2009
in the above example i need to pick the value from deviceid - 022032112 and brake it in ot 02.03.21.12 (. after every tow digits) and prefix 1 (number one) at the end
i am trying to write using cursor below not getting any idea
1) I need to get the deviceid and subsctring it and update if the ip is there else insert

SELECT REGEXP_REPLACE
          ('022032112',
           '([[:digit:]]{2})([[:digit:]]{2})([[:digit:]]{2})([[:digit:]]{2})([[:digit:]]{1})',
           '\1.\2.\3.\4.1\5'
          ) TEST
  FROM DUAL
WHERE LENGTH ('022032112') = 9;o/p
TEST
02.20.32.11.12
SELECT REGEXP_REPLACE
          ('02032112',
           '([[:digit:]]{2})([[:digit:]]{2})([[:digit:]]{2})([[:digit:]]{2})',
           '\1.\2.\3.1\4'
          ) TEST
  FROM DUAL
WHERE LENGTH ('02032112') = 8;Edited by: DeepakDevarapalli on Nov 11, 2009 10:57 AM

Similar Messages

  • Select records from one database and insert it into another database

    Hi
    I need to write a statement to select records from one database which is on machine 1 and insert these records on a table in another database which is on machine 2. Following is what I did:
    1. I created the following script on machine 2
    sqlplus remedy_intf/test@sptd @load_hrdata.sql
    2. I created the following sql statements in file called load_hrdata.sql:
    rem This script will perform the following steps
    rem 1. Delete previous HR data/table to start w/ clean import tables
    rem 2. Create database link to HR database, and
    rem 3. Create User Data import table taking info from HR
    rem 4. Drop HRP link before exiting
    SET COPYCOMMIT 100
    delete from remedy.remedy_feed;
    commit;
    COPY FROM nav/donnelley@hrp -
    INSERT INTO remedy.remedy_feed -
    (EMPLID, FIRST_NAME, MI, LAST_NAME, BUSINESS_TITLE, WORK_PHONE, -
    RRD_INTRNT_EMAIL, LOCATION, RRD_OFFICE_MAIL, RRD_BUS_UNIT_DESCR) -
    USING SELECT EMPLID, FIRST_NAME, MI, LAST_NAME, BUSINESS_TITLE, WORK_PHONE, -
    RRD_INTRNT_EMAIL, LOCATION, RRD_OFFICE_MAIL, RRD_BUS_UNIT_DESCR -
    FROM ps_rrd_intf_medium -
    where empl_status IN ('A', 'L', 'P', 'S', 'X')
    COMMIT;
    EXIT;
    However, whenever I run the statement I keep getting the following error:
    SP2-0498: missing parenthetical column list or USING keyword
    Do you have any suggestions on how I can fix this or what am I doing wrong?
    Thanks
    Ali

    This doesn't seem to relate to Adobe Reader. Please let us know the product you are using so we may redirect you or refer to the list of forums at http://forums.adobe.com/

  • I have an extensive aperture library on my computer's hard drive and I want to break it up into separate smaller libraries on external hard drives.  How do I take projects from one library and add them to another one?

    I have an extensive aperture library on my computer's hard drive and I want to break it up into separate smaller libraries on external hard drives.  How do I take projects from one library and add them to another one?

    Coastal,
    Frank gave you the exact answer to your question. 
    However, I would like to ask if you are indeed asking the right question.  Do you really want different libraries?  The implications are that you have to "switch" libraries to see what's in the others, and so that your searches don't work across all of your pictures?  If so, then you asked the right question.  If not, you may be more interested in relocating your masters to multiple hard drives so your library gets smaller, instead of breaking up the library.
    nathan

  • How can you take a photo from one event and put it in another, without dragging to desktop and dragging back into iPhoto and moving it to the event folder I want it in.

    As the title says I need help on how to take a photo from one event and put it in another, without dragging to desktop and dragging back into iPhoto and moving it to the event folder I want it in. Right now when I want to move a picture from one event to another I drag it to my desktop then delete it from iPhoto then I drag it back into iPhoto and put where I want it.An example would be taking a photo from the Christmas event and add it to a specific person event.  Can I do that within the events section without all the dragging. Also is there anyway I can remove duplicates from iPhoto without going through each and every file. Any help would be greatly appreciated.

    Apple doesn't make it easy to do what you want.  However, here's how I do it. 
    Select the photo you want to move and create a new Event for it via the Event ➙ Create Event menu option.
    In the Event mode select the new Event with the one picture and drag it onto the Event you want to move the photo to.

  • Is there anyway to take a downloaded app from one computer and put it on another without rebuying it. I have a macbook that I bought the new iMovie and iPhoto on, but I would rather it be on my iMac. So is there anyway I can change it?

    Is there anyway to take a downloaded app from one computer and put it on another without rebuying it. I have a macbook that I bought the new iMovie and iPhoto on, but I would rather it be on my iMac. So is there anyway I can change it? I thought that if I bought it the apps on my macbook, they would be avaliable on my imac like the mobile devices operate. The macbook has 10.6.8 cause its a older model and I think lion would slow it down. Any help??

    Just redownload it on the other computer by logging into the App Store with the same Apple ID you used to purchase it.

  • Can you edit a person from one photo and add them to another photo?

    Can you edit a person out of one photo and add them to another photo?  Like if you need the head shot from one photo to replace closed eyes in the other photo?  Thanks.

    Thank you very much!  Does this require software to be purchased?  I'm new to Photoshop. 
    From: Bill Hunt <[email protected]>
    To: Kittie Gugenheim <[email protected]>
    Sent: Monday, April 25, 2011 11:46 AM
    Subject: Re: Can you edit a person from one photo and add them to another photo?
    Welcome to the forum.
    Yes, this is done often. You will need to create a Mask of that person, to separate them from the background of the original Image.
    I like to do this with a Layer Mask, as it offers control, and really does not alter the Image, so you can go back and make changes.
    Let's say that you have Image 01 w/ the head of your subject, and want to place it into Image 02. In Image 01, make a rough Selection. I would include a bit of extra background, as we will take care of that in a moment. With that Selection active, Copy the head shot. Go to Image 02, and Paste it. It will Paste in its own Layer. Ctrl+T (Free Transform) can be used to Scale and also position that Layer with the head. Once you have that Scaled and positioned about where you want it, create a Layer Mask. In QuickMask Mode, just paint in the additional Mask to remove all traces of the background that came in with the head shot. As you can paint OUT, and also paint IN the Mask, you can work on this, as many times as you wish - even next year.
    For getting that Layer Mask looking good, work slowly, also see this http://graphicssoft.about.com/od/photoshop/l/blrbps_5agirl.htm.
    I've got another tutorial, that addresses the hair area, and will post that, when I find my bookmark.
    Good luck,
    Hunt

  • How do i select a clip from one project and enter it into another?

    how do I select a clip from one project and enter it in another?

    This doesn't seem to relate to Adobe Reader. Please let us know the product you are using so we may redirect you or refer to the list of forums at http://forums.adobe.com/

  • What is the best way to remove elements 10 from one pc and install it on another?

    What steps need to be taken to remove Adobe Elements 10 from one pc and install it on another?

    Use back up and restore from the Organizer menu. You are permitted two activations so no real need to deactivate the old copy unless you have installed it previously on another machine.
    See these instructions for PSE6 and above.
    http://helpx.adobe.com/photoshop-elements/kb/backup-restore-move-catalog-photoshop.html

  • Looking for best apple software for image extraction i.e. select an image from one photo and place it on another photo

    looking for best apple software for image extraction i.e. select an image from one photo and place it on another phot

    Cannot guarantee it's the best, but it certainly is the least expensive:
    http://www.gimp.org/downloads/

  • Hi i want to take a sequence from one timeline and drop it in another timelien without having to reedit the sequence. how do i do this thanks

    hi i want to take a sequence from one timeline and drop it in another timelien without having to reedit the sequence. how do i do this thanks

    leeg
    Your new thread was a success.
    Our original discussions on transferring content from one Premiere Elements project to another can be found
    What am I missing?
    in posts 4, 5, 6, and 7 of the above link.
    Good choice in deciding to go with the export from project 1 into project 2.
    Thanks again for your follow up and good work.
    ATR

  • Can you cancel Adobe Photoshop CS6 from one computer and put it on another?

    Can you cancel Adobe Photoshop CS6 from one computer and put it on another computer?

    Yes. You have to deactivate it on one computer and then you can install it and activate it on another. Technically, your license allows you to have Photoshop CS6 installed and activated on two computers, you just can't use both at the same time.

  • How can I take an item from one image and move it to another image?

    How can I take an item from one image and add it to another image, and rotate it to fit?

    Carefully select the objects of interest in one image and then copy, scale and position them into the other image. Then touch up the composite.
    Have to Love Photoshop for Retouching Images!

  • Is it possible to clone an object from one image and paste it on another image?

    Is it possible to clone an object from one image and paste it on another image in Aperture?

    As Frank said,
    but Aperture has a nice clone tool - the drawback is, that it only works within one image.
    What I sometimes do - as a workaroud, when I want to use the clone brush, is to combine the image I want to clone from and the image I want to clone into, into one single image by printing them together to pdf as jpeg. Then I can clone from the second to the first, for example, to be able to add an fairy to a flower: Picking up the head of the fairy in the right image and brushing it into the left one. Occasionally I prefer the Aperture brush to the Photoshop lasso.

  • I want to cut out a head from a photo and insert it into another photo again. In the head hair flying in the wind and the blue sky can be seen between the hairs. This blue sky I want to remove, so I can only use the head with hair flying in another photo.

    I want to cut out a head from a photo and insert it into another photo again. In the head hair flying in the wind and the blue sky can be seen between the hairs. This blue sky I want to remove, so I can only use the head with hair flying in another photo. Is it possible to simply delete this blue color of the sky?

    Make your selection and then use Refine Edge.
    See this video tutorial from Bob Gager.
    https://www.youtube.com/watch?v=xrl3Qwg6zSc

  • Taking data from one column and spread it out into multiple columns

    I have a table that I wish to take the multiple values out of one column and stick each into its own column..
    The data looks like this:
    subscriber id benefit plan
    12345 Med
    12345 Drg
    98765 Med
    98765 Drg
    I want it to look like:
    subscriber_id pc_med
    12345
    select distinct subscriber_id,
    (select grp07_benefit_plan from martin_7265_anoc
    where grp07_benefit_plan_type = 'MEDICAL ') pc_med,
    (select grp07_benefit_plan from martin_7265_anoc
    where grp07_benefit_plan_type = 'DRUG ') pc_drg
    from martin_7265_anoc

    user12296489 wrote:
    I have a table that I wish to take the multiple values out of one column and stick each into its own column..Multiple values in a single column is a violation of relational design. Makes it very difficult to implement data integrity. And there is the inevitable complexity and performance knock when trying to extract distinct values from the single column.
    Thus your attempt at fixing it is hopefully a permanent solution and not a a hack trying to make a broken db design to work?
    As Daniel said, it is very hard to make any sense of the example you have posted. But this is not the first time here that a poster wants to extract multiple values from a string column - so the basic principles of how to do it, remains the same.
    You need to have a means to identify each distinct value. This is usually done by identifying the separator character used between values. Such as a space or a comma.
    If the values are fixed length, then you can use sub-strings with explicit positions and lengths to extract the values from the string.
    The typical case is the former, which means you need to tokenise (split) the string. There are a number of ways to do this. I posted an example in {message:id=1807978} that shows how to do it via a PL/SQL function. There are numerous other ways, such as using SQL only. If you search for a keywords like "+splitting string+", it should turn up these examples.

Maybe you are looking for