Update a subst() with other substr() value from same row

Oracle 10.2.4.0
Given table MYTEST:
Name                                      Null?    Type
NAME_IND                                           VARCHAR2(15)
LOCAL_DATA                                         VARCHAR2(30)need to update every row, effectivley doing something like this:
update mytest
set substr(local_data,1,4) = substr(local_data,27,30)Obviously that code doesn't actually work, but at least implies what I need to do, and am having a hard time getting my head wrapped around exactly how to make it happen.
Expected input would be like:
NAME_IND        LOCAL_DATA                    
bert            12345678901234567890123456AAAA
bigbird         12345678901234567890123456BBBB
ernie           12345678901234567890123456CCCC and expected result would be
NAME_IND        LOCAL_DATA                    
bert            AAAA5678901234567890123456AAAA
bigbird         BBBB5678901234567890123456BBBB
ernie           CCCC5678901234567890123456CCCC

Frank Kulash wrote:
Hi,
In the SET clause of an UPDATE statement, the items to the left of the = signs must be columns in your table.
If you want to change local_data, in whole, or in part, then you say
SET  local_data = ...Now, what is the value to which you want to set it? If I understand correctly, it's the concatenation of two things
(1) The 4 characters starting a position 27 of the original local_data, and
(2) the part of the original local_data starting at position 5
The way to code that is
UPDATE  mytest
SET     local_data = SUBSTR (local_data, 27, 4)
            || SUBSTR (local_data, 5)Remember, the 3rd argument to SUBSTR is the length of the substring you want to extract, not the ending position.Right. Actually I had thought of that, but for some reason was thinking there would need to be a subselect, or even possibly an anonymous block of PL/SQL to get the value of the substr()'s for the 'current' row. After posting, shutting down, and heading home, my head cleared a bit and so was all set to give it a try, and it was exactly what I needed. Thanks for the lead.

Similar Messages

  • How to replace the string of column value with other column value in same table

      
    I have a temp table  which contains 
    Id  Name CTC   Address                      Content
    1    Ross  $200   6th block                  Dear #Name your  CTC  is #CTC and your address is  #address
    2   Jhon   $300   1oth cross                 Dear #Name your  CTC  is #CTC and your address is  #address
    Now i want to  select content    so that it should get  replace with  the respective  columns  and final output should come like this 
     Dear Ross your  CTC  is 200 and your address is    6th block  
      Dear Jhon your  CTC  is 300 and your address is   10th cross  
    Kindly suggest

    I think RSingh suggestion is ok ... what do you mean by another way? ...maybe something more generic?
    maybe build a table whith the list of col you need to "replace" and dinamically build the replace query ...
    declare @colList table(colName varchar(100))
    insert into @colList
    select 'name'
    union all select 'ctc'
    union all select 'address'
    declare @cmd varchar(2000)
    select @cmd='select '+ (select 'replace(' from @colList for xml path('') +' content '+
    (select ',''#'+ colName +''', '+ colName +')' from @colList for xml path(''))
    +' from YOURTABLENAME '
    exec (@cmd)
    or your request was different ?

  • How I can stop the combo box with list of values from fireing validations

    Hi I'm using Jdeveloper 11.1.2.3.0
    Using Hr Schema employees table
    I Display employees data in af:table
    and I make List Of values on Department_id filed to easy change the employee department
    and another one on Job_id filed
    and Imake them UI Hints as ( combo box with list of values ) in the employeesVO
    the problem is when I Select a value from department or jobs ( combo box with list of values )
    fires the entire filed validations for mandatory atributes
    Note : the af:table Property ( contedelivery) is set to (immediate )
    How I can stop the combo box with list of values from fireing validations

    check it out.,
    http://andrejusb.blogspot.in/2012/09/what-to-do-when-adf-editable-table.html

  • How To Concatenate Column Values from Multiple Rows into a Single Column?

    How do I create a SQL query that will concatenate column values from multiple rows into a single column?
    Last First Code
    Lesand Danny 1
    Lesand Danny 2
    Lesand Danny 3
    Benedi Eric 7
    Benedi Eric 14
    Result should look like:
    Last First Codes
    Lesand Danny 1,2,3
    Benedi Eric 7,14
    Thanks,
    David Johnson

    Starting with Oracle 9i
    select last, first, substr(max(sys_connect_by_path(code,',')),2) codes
    from
    (select last, first, code, row_number() over(partition by last, first order by code) rn
    from a)
    connect by last = prior last and first = prior first and prior rn = rn -1
    start with rn = 1
    group by last, first
    LAST       FIRST      CODES                                                                                                                                                                                                  
    Lesand         Danny          1,2,3
    Benedi         Eric           7,14Regards
    Dmytro

  • Get values from selected row in a Table?

    Hello.
    I'm on VC 7.1 (the trial version downloaded from SDN).
    I'm trying to figure out a way to retrieve some values from the currently selected row in a Table element through the output connector.
    I have a web-service which returns results to the Table, and I want the user to be able to select one of the rows and then trigger another web-service call with some of the values from that row -- is this possible?
    Also, I can't find any documentation that lists what can and can't be done with each UI element, is there something like this some where? (the Modeler's guide doesn't help, and the Reference guide seems to focus on menu items and what the VC screen looks like)
    Thanks,
    Alon

    Hi Alon
    This is a very simple task.
    You just need drag the service which you want to execute, after select row, in model.
    Drag output connector from table to input connector of service. Then map the parameter.
    Regards
    Marcos

  • Does home sharing allow me to share my iTunes library with other users on the same imac

    Does home sharing allow me to share my iTunes library with other users on the same imac? 

    Apparently so (as long as each user operates out of a different Mac User account).
    After setting up home sharing in the various different user accounts on the Mac, you need to have iTunes open in the account that you want to Home Share from.
    Now use fast User Switching to get into the account that you want to Home Share to. Launch iTunes in there. The library in the other account should appear as shared for you.

  • How do I sink calendars with other users on the same computer

    How do I sink calender info with other users on the same computer?

    Hi there,
    First..I am new to this forum and find the information provided to be very helpful... I had followed the iTunes link above to enable sharing between users in the same computer but it appears to be working on partially. What setup am I looking for ?
    1. We have an iMac (Snow Leopard) with 1 Adult ID and 2 children IDs
    2. The iTunes music folder is stored in a Shared public folder where the Adult ID has read/write access and the 2 kids with read-only access (so that they don't accidently delete songs...:-)
    3. The iTunes on the Adult ID has the access to purchase songs. The kids have no acccess to buy songs
    4. All songs, podcasts to be visible to all users
    What has happened ?
    1. I am able to make the base of songs visible to all users
    2. However when a song is purchased by the adult account ..it is not visible to the kids account ..:-{
    3. The same thing occurs when a song is imported from a CD
    4. When a new playlist is created by the Adult account it is not visible to the kids account ..:-(
    How can I make changes made by the Adult be made visible to the kids without having the need to constant add music files or libraries for each kid..?
    Thanks in advance..

  • How do i share my itunes library with other users on the same mac

    I'm trying to share my itunes library with other users on the same mac.  I have tried moving my library to a public folder but when the other user logs in they can't see it in the public folder?

    Presuming you moved the entire iTunes folder to the shared folder the other users need to start their iTunes while holding down the option/alt key and select the iTunes Library.itl file in the shared folder.  Only once should be necessary.  Note that any changes anybody makes will be seen by everybody, so you have to trust each other a lot.
    If all you moved are media files each user will have to add those files to their iTunes library. 
    iTunes: How to share music between different accounts on a single computer - http://support.apple.com/kb/HT1203 - relocating iTunes' media folder to a shared area but leaving separate library files - extra tip at https://discussions.apple.com/message/17331189 Chris CA's instructions on sharing one iTunes music library between multiple user accounts - https://discussions.apple.com/message/8974074 - Multiple users using a single library file - similar post at: https://discussions.apple.com/thread/3753008 Suggestion by Turingtest for multiple users and one library - http://discussions.apple.com/message/9117622 - use smart playlists and tags to isolate groupings.

  • HT1527 I have windows 8.1 and cannot access itunes store even creating a new apple id. With other users on the same computer I can access itunes store. How can I solve this?

    I have windows 8.1 and cannot access itunes store even creating a new apple id. With other users on the same computer I can access itunes store. How can I solve this?

    i had the same problem before using a fresh install of Windows 8.1.  I have resolved this issue by running the program compatibility wizard.  This I did by right-clicking on the iTunes icon in the desktop, selecting Troubleshoot compatibility, waited for it to detect compatibility issues and when presented with the following options: 1.) Try recommended settings; 2.) Troubleshoot program, I chose the latter.  When asked what problems I noticed, I checked the following: "The program worked in earlier versions of Windows but won't install or run" and "The program requires additional permission"
    After that, it tired to resolve the issue, and provided the necessary settings to run iTunes.  Now it's running flawlessly.  I have Avast anti-virus installed though.
    HTH!

  • How to set Dropdown list in tablen whith others Dropdown values in each row

    how to set Dropdown list in tablen whith others Dropdown values in each row of the table

    hi ,
    You have to add the parent element before adding data to the child node ...you follow the below steps it will work
    1) Take ContextStructure as follows ...
    tabledata (valuenode)
        ddownbyindex( value node) --within the tabledata node
             value (attribute)
    2)Binding to your layout
      tabledata (node) ---bind this to the dataSource property of your  table
          ddownbyindex( node)
                Value (attribute)--bind to the texts property of you DDbyIndex
    3)In wdinit() method add the following code
         IPrivate<Your view name>.ITabledataElement tabledataElement =wdContext.createTabledataElement();
        wdContext.nodeTabledata().addElement(tabledataElement);
        for(int i=0;i<5;i++)
         IPrivate<Your viewname>.IDdownbyindexElement ddbyindexElement=wdContext.createDdownbyindexElement();
             ddbyindexElement.setValue("Value"+i);
             wdContext.nodeDdownbyindex().addElement(ddbyindexElement);
    And set the cardinality property of the table node as 0..n
    and dropdownbyinex node to 1..n
    You try it ...
    Regards
    Madhavi
    Edited by: madhavi kotra on Sep 2, 2008 6:00 PM

  • Many of the times my Iphone 5s shows "No Service" in the specific network area, but if the same sim card is used with other mobiles in the same network area, it shows good network.. i did restore but still not working.. please help me..

    My Iphone 5s shows "No Service" in the specific network area, but if the same sim card is used with other mobiles in the same network area, it shows good network.. i did restore,change sim card, reset all the settings but still not working... please help me..

    Please do not double post a subject. Iphone 5S  I answered your other thread.

  • Update field taking value from previous row

    I have a table TEST (ID int, name varchar(20), amount decimal(18,0)).
    First row of the table have correct value. I want to update amount column except first row by adding 10 with the previous row value without using cursor.
    id    Name    Amount
    1    abc    10
    2    def    15
    3    ghi    20
    4    jkl    22
    5    mno    25
    6    pqr    27
    7    stu    30
    8    vwx    33
    id    Name    Amount
    1    abc    10
    2    def    20
    3    ghi    30
    4    jkl    40
    5    mno    50
    6    pqr    60
    7    stu    70
    8    vwx    80
    please help me.
    thanks
    srimanta manna

    create table #t (id int, amount int)
    insert into #t values (1,10)
    insert into #t values (2,25)
    insert into #t values (3,46)
    insert into #t values (4,55)
    insert into #t values (5,160)
    insert into #t values (6,89)
    insert into #t values (7,100)
    with cte
    as
    select *,(select min(amount) from #t t where t.id=1) as a
    FROM #t 
    ) update #t set amount=(select sum(a) from cte c where c.id<=cte.id) 
     from cte where #t.id=cte.id
     select * from #t
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Interchange values from one row with another row

    Dear Oracle Guru's
    While Migrating data from legacy system, there was a confusion and data in two columns got jumbled
    Ex The data should be like this
    Custcode leaseno
    1034 A234
    1035 A235
    1036 A236
    whereas the table has data like this
    Custcode leaseno
    1034 A235
    1035 A234
    1036 A237
    1037 A236
    How do we swap values between two rows
    Kindly guide me on this
    With Warm Regards
    ssr

    >
    Ex The data should be like this
    Custcode leaseno
    1034 A234
    1035 A235
    1036 A236
    whereas the table has data like this
    Custcode leaseno
    1034 A235
    1035 A234
    1036 A237
    1037 A236
    How do we swap values between two rows And now, time for yet another guess... ;)
    My guess is that your migration program interchanged "leaseno" value in pairs from the top - the top being the least value of "custcode".
    So, the "leaseno" values of Row 1 and Row 2 were swapped.
    The "leaseno" values of Row 3 and Row 4 were swapped.
    And so on.
    Which also means that if the total number of rows in your table is even, then the swap would be "complete". Otherwise, the last row would be left out. I don't know what you want to do with that.
    test@XE>
    test@XE> select * from t;
      CUSTCODE LEAS
          1034 A235
          1035 A234  <= you want to swap A235 and A234
          1036 A237
          1037 A236  <= you want to swap A237 and A236
          1038 A238  <= let's leave it hanging there...
    5 rows selected.
    test@XE>
    test@XE> And of course, swapping from "top to bottom" means swapping from the least to highest value of "custcode".
    Here's the SELECT statement for that -
    test@XE>
    test@XE> -- show the records in the table t
    test@XE>
    test@XE> select * from t;
      CUSTCODE LEASENO
          1034 A235
          1035 A234
          1036 A237
          1037 A236
          1038 A238
    5 rows selected.
    test@XE>
    test@XE> -- the SELECT statement for swapping leaseno values
    test@XE>
    test@XE> @test7a
    test@XE> --
    test@XE> select custcode,
      2         leaseno,
      3         case
      4           when mod(row_number() over (order by custcode),2) = 1 and
      5                lead(leaseno) over (order by custcode) is null
      6           then leaseno
      7           when mod(row_number() over (order by custcode),2) = 1
      8           then lead(leaseno) over (order by custcode)
      9           else lag(leaseno) over (order by custcode)
    10         end as new_leaseno
    11  from t;
      CUSTCODE LEASENO NEW_LEASENO
          1034 A235    A234
          1035 A234    A235
          1036 A237    A236
          1037 A236    A237
          1038 A238    A238
    5 rows selected.
    test@XE>
    test@XE> And here's the update statement -
    test@XE>
    test@XE> -- the UPDATE statement for updating leaseno values in pairs from the top
    test@XE>
    test@XE> @test7b
    test@XE> --
    test@XE> update t t1
      2  set t1.leaseno = (
      3    select new_leaseno
      4    from (
      5      select custcode,
      6             leaseno,
      7             case
      8             when mod(row_number() over (order by custcode),2) = 1 and
      9                  lead(leaseno) over (order by custcode) is null
    10             then leaseno
    11             when mod(row_number() over (order by custcode),2) = 1
    12             then lead(leaseno) over (order by custcode)
    13             else lag(leaseno) over (order by custcode)
    14           end as new_leaseno
    15      from t
    16    ) t2
    17    where t2.custcode = t1.custcode
    18  );
    5 rows updated.
    test@XE>
    test@XE>
    test@XE> select * from t;
      CUSTCODE LEASENO
          1034 A234
          1035 A235
          1036 A236
          1037 A237
          1038 A238
    5 rows selected.
    test@XE>
    test@XE> HTH,
    isotope

  • .MSG files. Problem with getting requested values from crawled properites

    Hi
    I have a lot of msg files on my file server. I use SharePoint Enterprise Serach engine to crawl all these MSGs.
    I would like to get extra managed properties out of these files. I am most interested in getting Mail:5(text) / Mail:12(Date and Time) / Mail:53(Date and Time) from MAIL category in Managed Properties.
    This thread is very similar to one already posted by SpinnerUp:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/82d69df0-5cb2-4e51-a485-34209e111f4b/problem-with-crawling-msg-files-doesnt-seem-to-return-requested-values-from-crawled-property
    Please be aware that I do not use Public Folders. These MSGs are exproted from Outlook and are stored on File Server not Exchange.
    I tried to link Crawled Properties to new property however I cannot get any results back.
    Thank you for you help.
    Regards, Marcin (Please mark as helpful or answered if it helps)

    Thank you for your replay.
    However I am not keen to write custom connector at this stage.
    Is it possible to simply get "Subject", "Sent", "Received" info from msg file and then map it to managed properties.
    Does SharePoint create any crawled properties which contain information about let's say "Subject" which then can be used to create managed properties?
    I tried playing with "MAIL" properties however I cannot get them to work. I guess this is because the file is a msg file rather than mail which is stored in Exchange Public Folder.
    Regards, Marcin (Please mark as helpful or answered if it helps)

  • I need some syntax help with reading some values from a selected row in an Access form.

    My goal:  to extract the data from 4 fields in a datasheet row and place them in another form.
    My problem:  I can only get the field values from the first row of the datasheet.
    I have tried using the Form_Click event as the location for the code I've tried.  This seems to be the right place, but apparently referring to the desired fields by their names with Me. in front just references the first record in the datasheet, not
    the one I've selected.
    Should I just read the source form's recordset using the Currentrecord value somehow?  I could use some direction on that.
    Thank you.
    Marj Weir

    It's generally considered good forum etiquette to post back a description of the solution which you've reached.
    The normal control for a multi-valued field is a combo box rather than a text box, but unless it is necessary for you to use a  multi-valued field, i.e. your database is interfacing with SharePoint in the very limited context in which this feature is necessary,
    I'd advise that you model the many-to-many relationship type in the time-honoured way by means of a table which resolves the relationship type into two one-to-many relationship types, and use a subform to show the data.  You can alternatively use a multi-select
    list box or a text box which shows a value list.  You'll find examples of all three methods in StudentCourses.zip in my public databases folder at:
    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
    If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.
    Ken Sheridan, Stafford, England

Maybe you are looking for