More redundant data removal!

Sorry to ask another question so fast, but the answer to my previous question was so triumphantly well, I thought I might give this one a go!

I have a string: "power, station, power plant, generator, power plant.
Who turns in "power plant, generator, power plant.

The rules of this transformation are:

1 splits the string into units of Word separated by comma (I have a function to do).
2. test each word to see if it contains spaces.
3. If she has no seats, it is an expression. If it isn't, it's a stand-alone Word.
4. divide a phrase in its component words (so divided 'powerhouse' in 'power' and 'station', for example)
5. If one of the component words appear in the independent origin as words string, then the stand-alone Word fell, and only the expression is preserved.

So here's another example, if the string was 'red, hamster, food, Hutch, hamster in a red Hutch, water, the bottle', then the output should be "food, hamster in a red Hutch, water, the bottle". The words stand alone 'Reds', 'hamster' and 'hutch' are eliminated because they appear in the expression "hamster in a red Hutch.

There may be any number of words in a string. The string can contain a number of words in an order any. Would be nice if the output could be in alphabetical order. And I want a function to do this, by which I enter the string exactly as shown in my examples above, and the correct output is returned as a string.

I have a code that can do steps 1 through 4, but I can't nail the ILO to eliminate independent words of the original string while maintaining intact expression. And my code in any case plods still with nested for/next loops and a lot of if... then tests. Judging by the results of my previous question here, I'm sure there are better ways to do it. Can certain Wizard SQL direct me to magic, please?

A start...
(Tested for data)

SQL> create type var_table as table of varchar2(100);
  2  /

Type created.

SQL> create or replace function fn(p_str varchar2) return varchar is
  2      tok varchar2(100) := ' ';
  3      str varchar2(4000) ;
  4      i number := 0;
  5      t var_table := var_table();
  6     begin
  7      while tok is not null
  8      loop
  9       i := i+1;
 10      tok := ltrim(rtrim(regexp_substr(p_str,'[^,]+',1,i)));
 11      if instr(tok,' ') = 0 then
 12       if instr(p_str,tok||' ') = 0 and instr(p_str,' '||tok) = 0 then
 13        t.extend;
 14        t(t.count) := tok;
 15       end if;
 16      else
 17       t.extend;
 18      t(t.count) := tok;
 19      end if;
 20     end loop;
 21     for rec in (select column_value from table(t) order by column_value) loop
 22      str := str||','||rec.column_value;
 23     end loop;
 24     return ltrim(rtrim(str,','),',');
 25    end;
 26  /

Function created.

SQL>  select fn('red,hamster,food,hutch,hamster in a red hutch,water,bottle') str  from dual;

STR
--------------------------------------------------------------------------------
bottle,food,hamster in a red hutch,water

SQL>  select fn('power, station, power plant, power generator, power station') str  from dual;

STR
--------------------------------------------------------------------------------
power generator,power plant,power station

Published by: JAC on April 9, 2009 11:09

Areas of attack and trasiling managed

Tags: Database

Similar Questions

  • OMB more change and remove modules and locations?

    Hi all

    First I want to thank you all of you in advance for your time and concern. I want to know how to change the location information to an ORACLE module, SQL SERVER module and module FILE plate using OMB and scripts.

    If you could provide some examples of scripts and ideas related to this topic, it will be highly appreciated.

    For example, what kind of script should I have to change the password or the name of the schema in place, attach it to the corresponding module and re - import new metadata (assuming that it points to a different schema)

    Thanks again for your help and concern!

    Kind regards

    Emrah

    I think you have this question in your other display.

    OMB more change and remove modules and locations?

    See you soon,.

    Emrah

  • Satellite M40-145 needs more start after removing the BT to start

    Hello people,

    I am wrinting this post because I think that this version of Bluetooth stack probably has an incompatibility with my toshiba m40 - 145 PSM40E - Windows Xp

    I always remove the Bluetooth Managment (TosBtMng.exe) windows Startup, and now if I do that, I have problems when I'm back from sleep mode. Sometimes, I need to wait more than a minute or two to access the windows. While wainting my monitor stays off and my hard drive is flashing.

    Because I still put TosBtMng.exe to start windows my recovery is ok...

    Do you think this is normal?

    Hey nokai

    Toshiba Bluetooth site and you'll find piles of BT to download
    http://APS.toshiba-tro.de/Bluetooth/

  • How can I save ALL my music on my phone so I don't need to listen to more cellular data or wifi?

    After the IOS Software Update 9.2, my iPhone 6 (64gigs), he held all the music that I wanted in the music app. All the songs were recorded in the phone and I don't have to be connected to wifi to listen to all the songs. Once I updated my phone, at 9.2, all songs were is more saved on my phone. All the songs are now need to be listened to, eat data or using data.  Issue consider how easily re-install my songs 1440 on my phone?

    Hi ishyaboi,

    Have you subscribed to Apple music or iTunes game on your iPhone?  If so, you need to download the songs of 1440 you have on your iPhone by selecting the option 'Make available offline'.  If you have not subscribed to one of these services, you can manually synchronize the songs you want from your iPhone to your iTunes library on the PC.  Click on the links below for more details.  I've highlighted some key here for you information.

    Add music catalog to Apple's music to your library on your iPhone, iPad, iPod touch, Mac or PC

    Apple music members have access to the entire catalog Apple Music, recommendations of experts and news directly from the artists. You can add these songs, albums and playlists of your own library on your iPhone, iPad, iPod touch, Mac or PC.

    To add songs, albums, and playlists of Apple's music in my music, make sure to turn on iCloud music library on your device.

    Download songs, albums and playlists to listen to offline

    You can download songs, albums, or playlists on your device so that you can listen to them when you are not connected to the Internet, you need to download tracks, albums or playlists on each device that you want to use for offline listening.

    * You can download music on up to 10 devices. These songs are only available during your membership of Apple's music.

    On your iPhone, iPad or iPod touch

    1. In the music application, find the element you want to download.
    2. Tap the More Options to the right of the name of the song, album, or playlist.
    3. Tap the icon download to the right of the article work. If you see a instead of the download icon, the question is not in your iCloud music library. Press on the to add the item to my music, then press on the download icon to download the agenda on your device.

    Songs and albums appear under my music > library. Playlists appear under my music > playlists.

    On your Mac or PC

    1. In iTunes, find the item that you want to download in the tab my music or playlists. You cannot download items to listen to offline on the iTunes Store.
    2. Click the icon to the right of the name of the song, on the album cover, or cloud to the right of the name of the playlist.

    Songs and albums appear under the music of my Playlists tab appear in the tab reading lists, under the Playlists of music from Apple in the sidebar.

    Simply display songs, albums and playlists that you downloaded on your device

    • iPhone, iPad and iPod touch: In the Music my tab, click library. Then press one of the different points of view (artists, Albums, etc.) and turn on only when the music offline. A message that says "not showing music on this [device]. Display all the music. "at the top of the screen. Tap view all music to see all of your music.
    • Windows: Press control and B on your keyboard to open the bar menu of iTunes. Choose View > music offline. A message that says "not showing music on this computer. Display all the music. "at the top of the screen. Click on 'Show all music' to see all your music.

    When you view an item that you have downloaded on your device, you will see a icon offline  near it but its exact location varies. For example:

    • If you download a whole album or playlist, offline icon appears when you look at the album or playlist in my music. You will also see an icon in offline mode when you view a compilation, but not when you view specific genres, composers or artists.
    • If you download a song, the offline icon to the right of each title of the song.
    • If you download songs from the album, but not whole album, offline icon appears to the right of the just the songs you downloaded.

    Move content from iTunes on your computer to your iPhone, iPad, or iPod touch

    If you are a member of Apple's music or that you have an iTunes game subscription, you have iCloud as lit library. When you have iCloud that music library is turned on, you cannot manually manage music. You can still manage the videos by following the steps below.

    Take care

  • one or more wells data void / vi

    I have a sub vi that opens to the main start of the vi.  The user enters data about the serial number of the product, the model of the product, ect., then press OK.

    The sub vi closes and disappears.  It works well, the thing that doesn't work is the outputs.  They are connected to the select inputs for some structures of the case, and I get an error, "this wire connects to one or more data dark but has no source.

    I don't think it makes sense since the indicators of the Sub vi are actually the source for case structures.

    Probably I'm missing something easy.

    Each Subvi itself used as a directional reference to its part of connector terminals.  If the serial number control is a sink (data go in the Subvi) and serial number 2 is a source (data leave the Subvi).

    Your Subvi includes only the entries = sinks (even if some of them are on the right side) and no output = sources.  Look at the picture to context-sensitive help: it shows all connections going to the left.

    Your loop should also have a small wait to avoid consuming all the resources of the CPU while it is running.  A structure of the event would be better.

    Lynn

  • If I have 1 CC account, can I download my apps on a PC, then on a MAC at a later date (remove them from the computer if necessary?)

    I think signing up CC, especially since it's a bit cheaper now. Are the apps downloaded on a single machine, or are they just apps that I can use it on any machine? I am currently working on my pc, but I know I'm going to work early next year that is all based Macs to come. If I've signed and applications downloaded on my pc, can I download them at a later date on my (when they) mac?

    See you soon.

    Hello

    You can have the creative cloud installed and signed in on two computers as long as you don't use it on one at a time. Download and install as you did on the first computer, sign in to your Adobe account on the Adobe using your Adobe ID website, download the desktop app from clouds, then download the software. Sign on a computer that should not be used: log in and log out of the desktop Adobe Creative Cloud application

    This link provides more information and step by step instructions, if you need: CC help | Download, install, update or uninstall applications

  • How to keep track of the lines that I add to a table so that I can update more later or remove them?

    A > the form has a set of field and text dropdown list entries.  After the user updates the data in a specific text, change field, I need to add their data to a table on the first time through.   There are many different games of entries that would each have their own line.

    B > later the user comes back and changes the data in a field.  I need to update this specific line with the new values.

    C > later the user returns and removes the data of one of the fields completely so I need to remove that specific table line.

    D > the user does not directly from the table.  The table summarizes the entries that are made in the text and drop-down list fields.  I need to be able to maintain the table in harmony with user input.

    I agree with the addition of rows in a table, but I do not know what's best for that lines are kept synchronized.   I've got a good amount of Java programming experience under my belt, but I have a few projects in LiveCycle.

    I'm quite willng to read if you have any reference material online for the management of dynamic arrays.  So far, the only information I have found is how to add and remove lines, but not how to keep track of them.

    Any help is greatly appreciated.

    Ah sorry missed that you do not use two tables.

    Do you use Extensible lines or is there a specific line for each set of data?

    You can just hardcode where data are intended - a data go into RowA. To the same output of the field, you would be just: table.rowA.rawValue = this.rawValue;

    You can use Global binding on the fields: the fields, take data entry have the same name as the fields in the table and then automatically updated data.

    For blank lines, you will need to check if there is data in the fields and if no data you can hide the line: RowA.presence = 'hidden ';

  • fnd_user_pkg. UpdateUser - End Date remove users

    Posted by mistake in the PL/SQL forum, until someone pointed out my mistake.

    As part of an upgrade, we need to close the vast majority of our users.

    I used the API fnd_user_pkg.updateuser to fill the end_date on the fnd_user table.

    However, when I came to test removing the end date, I can't do it. In the example below, the end_date remains populated.
    DECLARE
       CURSOR usercur
       IS
          SELECT fu.user_name
            FROM apps.fnd_user fu
           WHERE user_name = 'TEST_ACCOUNT';
    BEGIN
    
       FOR myuser IN usercur
       LOOP
          fnd_user_pkg.updateuser(
             x_user_name      => myuser.user_name
           , x_owner          => 'CUST'
           , x_end_date       => NULL
          );
       END LOOP;
    
    END;
    On the example on this post:
    http://apps2fusion.com/forums/viewtopic.php?f=99 & t = 108

    They took the final date via:

    x_end_date = > SYSDATE + 10000);

    However, this isn't really remove the end date, it's just assigning a lot of time in the future.

    I was wondering if I missed something obvious?

    Any advice much appreciated.

    Thank you

    You must pass to_date (' ' 2 ',' J ') as the end_date. It's 1/2/4712.
    If you pass this date, Oracle which deals as null. It will therefore remove the end_date in the table user.

    Hope that answers your question
    Sandeep Gandhi
    OMKAR Technologies Inc.
    Techno-Functional consultant
    513-325-9026.

  • LR showing more EXIF data?

    Hello

    I need to know if VR a (System of Nikon Vibration reduction) lens has been enabled or disabled for my photos. LR 3.2 does not show this, even if the information is stored in the EXIF data (EXIFTool shows - and much much more). The plug-in that lets me add this?

    Jeffrey 'metadata-Viewer Preset Editor' allows me to choose certain areas more EXIF and IPTC for Lr to show, but not these.

    Any help will be very appreciated! Including Adobe...

    The plug-in that lets me add this?

    http://www.robcole.com/Rob/ProductsAndServices/ExifMetaLrPlugin/index.cfm

  • get a more ancient date

    Hello
    I have a table with columns:

    employee_id
    function_id
    start_date
    End_date

    in this table, I have:

    1 1 20/06/2009-21/07/2009
    1 2 22/07/2009-29/07/2009
    1 3 30/07/2009 null

    2 5 20/07/2008 null

    I want to get the oldest start_date for each employee. I tried with
    select min(start_date) from angajat_functie where end_date is null and employee_id=2;
    So where employee_id = 2, it is the only record for this employee, so I returned the start_date.
    I want to employee_id = 1 also to return the earliest start date (only if a record for employee_id = 1 contains a null end_date). If all end_date for employee_id = 1 are null, so that it no longer works.
    in my case, how can I get the oldest date 20/06/2009 for eployee_id = 1?

    Kind regards

    Hello, try this:

    select employee_id, min(start_date)
      from angajat_functie a
     where exists (select 1
                  from angajat_functie b
                 where a.employee_id = b.employee_id
                   and b.end_date is null)
    group by employee_id
    

    Change Function removed id fiilter and corrected of subquery.

  • How can I get E Mails to organize in a more recent date

    I can't e-mail to align with the e-mail most recent on top. all on-site. What should I do?

    Hello

    You can click on the header Date to reverse the order, or you can go to > > Sort by and select Date and Crescent

  • I use a SanDisk Cruzer with U3 Launchpad. I had to stay with Firefox v3.6.26 because no more recent data does not have the U3 Launchpad working. Any suggestions?

    OS Win7. I used this USB key for some time as a secure method to contain passwords that I use often. When I have been updated for Firefox v3 - regardless of the version which was at the time - a v4 the U3 Launchpad failed. I tried all autour work, I could find on the Internet. Nothing has been successful. I know that this software is no longer supported. If it is supported should set if it works. I think it is an unacceptable excuse. I support is no longer my daughter, but it still works. She is a much more complicated machine than a PC and a piece of software.

    Sorry, U3 versions of Firefox were not made by Mozilla. This version is a modified version of Firefox made by a 3rd party and this 3rd party is responsible for its "support. I've never used and cannot help you with it.

    Have you thought about switch to Firefox Portable, which is made by the crew while in the Portable Apps?

    http://PortableApps.com/apps/Internet/firefox_portable

    Portable Apps existed for much longer that the U3 Launchpad was and is still operating and growing with the number of applications available.

  • All hard drive data removal/cleaning

    I just bought Windows7 Recocery hp discs. The hard drive should be cleaned of all data etc. before installing recovery disks. Computer is a HP PAVILION dv7-3160us ENTERTAINMENT NOTEBOOK

    Hello

    Do not wipe the hard disk, unless you want your recovery disks will perform a quick format of the HARD drive before installing the OS, etc.

    Kind regards

    DP - K

  • Have we no more option to remove this validation message (pass the error)

    Hi all

    There is demand from the user to remove (pass the error) validation, for example, if they do not select any specific filed and press button Save, then we are launching this validation message. Can possible to delete the message (pass of the error).

    Apex 4.2 version.

    Kind regards

    Sruthitamiri

    Just enter a blank space.

  • Why not delete commonly used Mount Options - no Expand more or add/remove tracks?

    Where is the ability to expand/collapse and add/remove video and audio tracks in the first Pro CC mounting Panel?

    Why they were withdrawn in the convenient context menu?

    Hover your mouse over the track header and scroll the mouse wheel.

Maybe you are looking for