How to split and sort names in PL/SQL

I have a table with a Customer_Name field that holds data like:
John, Jones T, JR, MD
James, Doe M, MD
Jane, Dee, MD
I need to insert this date into a new table with three fields that hold Full Name, Fname, and Lname and sort this data by last name. Some rows have middle initial, others has prifix initial and some have no middle at all. All have the MD at the end.
I am only interested with the FullName, Fname and LName.
Example
FullName, Fname LName
John, Jones T, JR, MD John Jones
Any ideas how to do this using PL/SQL?
Edited by: user13086849 on Jul 7, 2010 1:18 PM

user13086849 wrote:
I wanted my final inserted table to look las the following.
FullName should contain all the names John, Jones T, JR, MD
Fnam only Fast name John
Lname only Last name Jones
FullName
John, Jones T, JR, MD
Fname
John
LName
Jones
Any ideas how to do this using PL/SQL?
Edited by: user13086849 on Jul 7, 2010 1:21 PM
select
   some_string,
   regexp_substr(some_string, '[^,| ]+', 1, 1) as first_name,
   regexp_substr(some_string, '[^,| ]+', 1, 2) as last_name
from
   select 'John, Jones T, JR, MD'   as some_string from dual union all
   select 'James, Doe M, MD'        as some_string from dual union all
   select 'Jane, Dee, MD'           as some_string from dual
SOME_STRING           FIRST_NAME           LAST_NAME
John, Jones T, JR, MD John                 Jones
James, Doe M, MD      James                Doe
Jane, Dee, MD         Jane                 Dee
3 rows selected.
Elapsed: 00:00:00.97
TUBBY_TUBBZ?

Similar Messages

  • I have a huge file which is in GB and I want to split the video into clip and export each clip individually. Can you please help me how to split and export the videos to computer? It will be of great help!!

    I have a huge file which is in GB and I want to split the video into clip and export each clip individually. Can you please help me how to split and export the videos to computer? It will be of great help!!

    video
    What version of Premiere Elements do you have and on what computer operating system is it running?
    Please review the following workflow.
    ATR Premiere Elements Troubleshooting: PE11: Project Assets Organization for Scene and Highlight Grabs from Collection o…
    But please also determine if your project goal is supported by
    a. format of your source
    and
    b. computer resources
    More later based on details that you will post.
    ATR

  • Just found Ipad Nano in Big Island Hawaii. Trying to find the owner to return it back. Tell me what is the color, how many songs and your name(its personalize with a name).

    Just found Ipad Nano in Big Island Hawaii. Trying to find the owner to return it back. Tell me what is the color, how many songs and your name(its personalize with a name).

    I only wish that when I called Apple, they would match the serial number with the owner and give me the contact
    Hopefully you left Apple your contact info (name phone #, email address).
    Apple would simply pass your contact to the last registered owner. It would be up to the owner to contact you. As Dave mentioned, Apple will not give you any info (except may to tell you it was or was not registered, but not to who). Turn it on once in a while and maybe they have activated FindMyiPad and a message will pop up (don't need to be logged onto the iPad to a message).

  • How to split the string by datetime in sql

    Hi,
    How to split the string by datetime in sql, I've a table with comments column stores comments by datetime, while selecting I want to split and show as in rows by each jobref.
    can anyone help me in this please.
    Thanks,

    declare @callcentre table (comments varchar(max),lbiref varchar(200))
    insert into @callcentre
    select '(28/10/2014 14:56:14) xyz ..... call  logged   (28/10/2014 14:56:58) xyz ..... call updated   (28/10/2014 14:57:41)xyz ..... call updated','Vi2910201'
    insert into @callcentre
    select '(29/10/2014 14:56:14) xyz ..... call  logged   (29/10/2014 14:56:58) xyz ..... call updated   (29/10/2014 14:57:41)xyz ..... call updated','Vi2910202'
    insert into @callcentre
    select '(30/10/2014 14:56:14) xyz ..... call  logged   (30/10/2014 14:56:58) xyz ..... call updated  
    output:
    1) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call  logged ,'Vi2910201'
     2) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910201'
    3) 28/10/2014 14:57:41,  (28/10/2014 14:57:41)xyz ..... call updated,'Vi2910201'
    4) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call  logged ,'Vi2910202'
     5) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910202'
    6) 28/10/2014 14:57:41,  (28/10/2014 14:57:41)xyz ..... call updated,'Vi2910202'
    7) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call  logged ,'Vi2910203'
     8) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910203'
    Thanks,
    See this illustration
    declare @callcentre table (comments varchar(max),lbiref varchar(200))
    insert into @callcentre
    select '(28/10/2014 14:56:14) xyz ..... call logged (28/10/2014 14:56:58) xyz ..... call updated (28/10/2014 14:57:41)xyz ..... call updated','Vi2910201'
    insert into @callcentre
    select '(29/10/2014 14:56:14) xyz ..... call logged (29/10/2014 14:56:58) xyz ..... call updated (29/10/2014 14:57:41)xyz ..... call updated','Vi2910202'
    insert into @callcentre
    select '(30/10/2014 14:56:14) xyz ..... call logged (30/10/2014 14:56:58) xyz ..... call updated','Vi2910203'
    SELECT LEFT(p.u.value('.[1]','varchar(max)'),CHARINDEX(')',p.u.value('.[1]','varchar(max)'))-1) AS [Date],
    '(' + p.u.value('.[1]','varchar(max)') AS comments,
    lbiref
    FROM
    SELECT lbiref,CAST('<Root>' + STUFF(REPLACE(comments,'(','</Data><Data>'),1,7,'') + '</Data></Root>' AS XML) AS x
    FROM @callcentre c
    )t
    CROSS APPLY x.nodes('/Root/Data')p(u)
    and the output
    Date comments lbiref
    28/10/2014 14:56:14 (28/10/2014 14:56:14) xyz ..... call logged Vi2910201
    28/10/2014 14:56:58 (28/10/2014 14:56:58) xyz ..... call updated Vi2910201
    28/10/2014 14:57:41 (28/10/2014 14:57:41)xyz ..... call updated Vi2910201
    29/10/2014 14:56:14 (29/10/2014 14:56:14) xyz ..... call logged Vi2910202
    29/10/2014 14:56:58 (29/10/2014 14:56:58) xyz ..... call updated Vi2910202
    29/10/2014 14:57:41 (29/10/2014 14:57:41)xyz ..... call updated Vi2910202
    30/10/2014 14:56:14 (30/10/2014 14:56:14) xyz ..... call logged Vi2910203
    30/10/2014 14:56:58 (30/10/2014 14:56:58) xyz ..... call updated Vi2910203
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How can I include "sort name" column when burning a playlist to disc?

    I noticed the "sort name" info is missing in the burnt disc. How can I preserve the info? I spent some times in correcting some sorting order in my library and I want that info to be in my backup too.

    The sort fields should be getting stored in the files' tags, assuming they have tags. When buring an audio disc this information will be lost. It ought to be preserved when using the iTunes backup function, however you may be better off using a 3rd party backup tool to backup the entire iTunes folder.
    N.b. You've posted in the Using iTunes for Windows forum but your sig says you're a Mac User, otherwise I'd recommned SyncToy 2.0 for your backup. I'm not familiar enough with Mac to suggest a suitable replacement.
    tt2

  • How to subtotal and sort in ABAL webdynrp ALV?

    Hi Experts,
       In my ALV table I have CARRID and PRICE.
       I want to sort the data by CARRID and then group the data based on CARRID and get price subtotal of it.
       I also want a grand total of the price.
       How to programatically subtotal and sort in ABAL webdynrp ALV?
       Please provide sample code snippet if possible.
    Thanks
    Gopal
    Edited by: gopalkrishna baliga on Oct 26, 2010 1:30 PM

    Hi Gopal,
    Didn't you get solution with your earlier post?
    How to show Subtotal in webdynpro ALV(ABAP)? Kindly help!
    Regards,
    Vikram

  • Created date for JPGs used in FCE - how to view and sort by

    In FCE I need to view and sort by the date created not date modified on JPG images. How do I do that?

    Why would the developers prevent users from using information about when they TOOK the pictures rather than when they edited them? Seems like a real deficiency in the program to me.
    I make movies using 100s of images from a variety of photographers and put them in chronological order. Having to go to Finder on every one is impractical.

  • Large XML files, how to split and read them in PI

    Hi,
    For a specific requirement, we have a 60 MB-90 MB XML file being generated by a legacy application.
    This file has to be processed by PI 7.31 Sender File Adapter and should be posted as a ABAP proxy to SAP ECC system.
    To address any performance issues, we are planning to read the files in chunks.
    Is there a way by which we can configure the file adapter to pick a fixed no.of records to limit the size.
    In inputs in this regard will be appreciated.
    regards,
    Younus

    Hi Younus,
    First of all if you are using PI 7.31, then you should be quite able to process XML file of about 100MB scale. Performance issue shall occur in ECC side instead as it can not handle such high volume.
    My suggestion will be to pick the whole XML file at one go and do necessary mapping. However on receiver side use SOAP Adapter instead of XI for making proxy calls to ECC.
    In SOAP adapter (using HTTP as Transport and XI 3.0 as Message protocol) there's an option as 'XI Packaging' which can be used to send data in packets.
    Refer below help doc on it.
    Configuring the Receiver SOAP Adapter - Advanced Adapter Engine - SAP Library
    Thanks
    Bibek

  • How to bind a column name in PL/SQL

    i have this code in a transaction report.
    DECLARE
    q VARCHAR2 (1000);
    t VARCHAR2 (15);
    BEGIN
    t := '11110000';
    q := q || 'select STARTDATE, PHONESOURCE, PHONETO, DURATION ';
    q := q || 'from TRANSACTION ';
    q := q || 'where TRANS_ID = ' ||t|| 'and STARTDATE between :P3_DATE_FROM and :P3_DATE_TO ';
    q := q || 'and PHONESOURCE = :P3_FILTER_BY_TEXT';
    RETURN q;
    END;
    I have a combo box item which suppose to select between 2 different columns (PHONESOURCE & PHONEDEST) lets call this combo box: P3_FILTER_BY.
    I need to replace 'PHONESOURCE' (marked) with this combo box in order to set the query dynamically. the question is: is it possible? and if so how?
    i tried few variaton of replacing it, but it wouldn't work.

    thank u for your answer,
    However, i've thought about it and tried it before. but it gave me this error when applying the edit page:
    "LS-00103: Encountered the symbol "&" when expecting one of the following..."
    even when i checked the "Use Generic Column Names (parse query at runtime only)" check box it gave me this error in runtime.
    so, what should i do ??

  • How to use concatenated sequence name in pl/sql

    how can we have a sequence concatenated with another sequence
    name eg
    select ab.nextvalue into var1 from dual;
    where a is a sequence and b is another sequence
    null

    Try this Puneet:
    TO_NUMBER(TO_CHAR(a.nextvalue)

  • How to use get column name.vi in SQL toolkit 2.0?

    Due to the vi "get column name.vi" paremeters,no table name has connected to the vi. So, I want to ask how to use this vi for gain one column name of a table. Maybe there are some other ways to solve column name getting.
    Thanks.

    Thanks!
    Error 4101 Description:
    Execute SQL - The connection, statement, or query handle you provided is not valid.
    I don't just used the toolkit in a while,now, I am developing a irrigation system. For the table field names defined by users,column names must be known before any select operations. Do you have any other good idea about drawing out the columnname parameters?
    As you know, a valid DSN and table have been also available. The database I used is Access. The bad thing to me is that there is no any text information gotten. And I think, it may be some problems in connection way which I don't find out.
    Really appreciated by your reply.
    Could you give me some example in the aspect?
    Thank you again.

  • How to pass and work with a PL/SQL or Temp table in a Procedure?

    My problem is that I have a query that involves about 10 tables or so, but everything starts from one base table. I am trying to split the base table so that the query actually finishes.
    Problem Query:
    with base_table as
    select * from table_a
    , t1 as
      select * from table_b
    -- There are some manipulation in the SQL, but not listing it here.
    , t2 as
      select * from table_c INNER JOIN t1 on t1.id = table_c.id
    ) What I want to do is limit base table and thus create a procedure such that it evalutes a temporary table and the temporary table will be limited by 1000 rows or so.
    Thanks for your help.

    Currently I am using:
    DECLARE
       l_start                       NUMBER;
       l_increment                   NUMBER;
       l_max                         NUMBER;
    BEGIN
       l_start := 1;
       l_increment := 100;
       SELECT COUNT(*) AS the_count
         INTO l_max
         FROM table_a;
       LOOP
       INSERT INTO new_table
         WITH base_table AS
         (SELECT p.*
            FROM (SELECT DENSE_RANK () OVER (ORDER BY alpha_id) rnum, a.*
                    FROM table_a a) p
           WHERE rnum BETWEEN l_start AND l_start + l_increment - 1)
       , t1 AS
         (SELECT *
            FROM table_b
    -- There are some manipulation in the SQL, but not listing it here.
       , t2 AS
         (SELECT *
            FROM table_c INNER JOIN t1 ON t1.ID = table_c.ID
    SELECT *
      FROM t2, temp_base;
    COMMIT;
          l_start := l_start + l_increment;
          EXIT WHEN l_start > l_max;
       END LOOP;Is it better to create a Temporary table or pass the data as a cursor:
    SELECT DENSE_RANK () OVER (ORDER BY alpha_id) rnum, a.*
    FROM table_a a
    Thanks.

  • How to connect and export specific schemas in SQL plus

    Hello,
    Wanted to clarify on a few things.
    - Can an Oracle 10g Release 10.2 client be used to connect to a oracle 10.1 database?
    - Is there an option to "connect" (not refer) to a specific schema, say "SchemaA" in SQL plus in order to run a specific sql code on this schema alone?
    - How can we export a specific schema as a dump file in SQL plus-what is the syntax? Assuming username=U;password = PW; Database=DB and schema = Sch
    Thanks a lot.

    - Can an Oracle 10g Release 10.2 client be used to connect to a oracle 10.1 database?
    Yes. O10gR2 client can be used to connect all version of Oracle instance.
    - Is there an option to "connect" (not refer) to a specific schema, say "SchemaA" in SQL plus in order to run a specific sql code on this schema alone?
    connect ShcemaA/pwd@hoststring.
    for e.g.
    connect scott/tiger@oradev
    conn scott/tiger@oradev
    - How can we export a specific schema as a dump file in SQL plus-what is the syntax? Assuming username=U;password = PW; Database=DB and schema = Sch
    Export can be done on Command promt not on SQLPLUS prompt.
    try the following to know all the parameters and usage of exp command.
    c:\> exp help=y
    exp scott/tiger FILE=scott.dmp OWNER=scott GRANTS=y ROWS=y COMPRESS=y

  • How to read and store data from an SQL resultset

    I'm writing a program to create testing scripts. I have a working version of the program that takes data from a specific input file, processes it and then outputs it as a test file that is readable by this other system. That's all fine and dandy, but now I wish to extend my program so that it doesn't need the input file, it shoud run an SQL query on the database itself and output this, with some other data to the output file, I have been experimenting with some code below:
              ResultSet rset;
              rset = sql.sqlweight();
              while (rset.next()!= false)
                   System.out.println("I'm getting to this loop");
                   scanCode = rset.getString(1);
                   System.out.println(scanCode);
                   rset.next();
              }And method sqlweight looks like this:
         public static ResultSet sqlweight() throws SQLException
              Connection connectiona = DriverManager.getConnection(//hiding connection details);
              Statement stmtW = connectiona.createStatement();
              String sqlW = "Select distinct (selc_code) from selling_code, prod_orgu_link where selling_code.prod_id = prod_orgu_link.prod_id and prod_orgu_link.prou_prod_handling = 20";
              ResultSet rset = stmtW.executeQuery(sqlW);
              while (rset.next())
                   //System.out.println(rset.getString(1));
              //rset.close();
              //stmtW.close();
              //connectiona.close();
              return rset;
         }Code is a bit messy at the moment as I am constantly changing and adding things so excuse the formatting. I can't get it to enter the loop (hence the testing line I put in it). I am wondering what the best way would be to get the data held in the results set into my String variable scanCode. Thanks for any help or advice.

    I haven't thrown it away, it just looks like this now:
         public static ResultSet sqlweight() throws SQLException
              Connection connectiona = DriverManager.getConnection(//hiding connection details);
              Statement stmtW = connectiona.createStatement();
              String sqlW = "Select distinct (selc_code) from selling_code, prod_orgu_link where selling_code.prod_id = prod_orgu_link.prod_id and prod_orgu_link.prou_prod_handling = 20";
              ResultSet rset = stmtW.executeQuery(sqlW);
              return rset;     
         }

  • Split and Merge Paragraphs

    When I split and merge a paragraph a line break is inserted.  Does anyone know a way around this. (Simply deleting the last character seems inelegant and, more importantly, prone to failure).  Here's the code:
    var textFlow:TextFlow = TextConverter.importToFlow(
                        "Hello World",
                        TextConverter.PLAIN_TEXT_FORMAT);
    textFlow.interactionManager = new EditManager();
    var textFlow2:TextFlow = textFlow.splitAtPosition(5) as TextFlow;
    textFlow2.interactionManager = new EditManager();
    textFlow.mxmlChildren = textFlow.mxmlChildren.concat(textFlow2.mxmlChildren);
    trace(textFlow.getText()); // returns "Hello\n World"
    - Daniel Freiman

    If you are asking how to split and merge a paragraph this works.
                var textFlow:TextFlow = TextConverter.importToFlow("Hello World",TextConverter.PLAIN_TEXT_FORMAT);
                // find the paragraph
                var para:ParagraphElement = textFlow.findLeaf(5).getParagraph();    // same as textFlow.getChildAt(0)
                // split paragraph at position five
                var newPara:ParagraphElement = para.splitAtPosition(5) as ParagraphElement;
                trace(textFlow.getText());
                // now the merge
                // remove newPara its being discarded
                newPara.parent.removeChild(newPara);
                // move the children
                while(newPara.numChildren)
                    para.addChild(newPara.getChildAt(0));
                trace(textFlow.getText());
    This is using pure model level calls.  In your original code you added an EditManager- it can be done that way too.  TLF is layered - the EditManager manipulates the model with model level calls.  It provides APIs connected to events that create operations do to that.
    Hope that helps,
    Richard

Maybe you are looking for

  • Any idea what this errorr means? the data type of the reference does not match the data type of the variable

    I am using Veristand 2014, Scan Engine and EtherCat Custom Device.  I have not had this error before, but I was trying to deploy my System Definition File (run) to the Target (cRio 9024 with 6 modules) and it failed. It wouldn't even try to communica

  • File isnt opening in photoshop 6

    files aren't opening in photoshop 6, but different palettes, like layers, characters, for a file do open. Tried reinstalling photoshop software from original disk. Still doesnt work. Anyone know how to fix what's wrong

  • IMAP email not appearing in Mail

    Background: I have an IMAP email account that's over a decade old.  It's going away soon so I'm trying to figure out how to get a complete local copy of all that email.  There are a total of around 100 folders with anywhere from 5 to over 2000 emails

  • Reinstalling os x lion

    I just added a new hard drive to my Macbook and I am trying to reinstall OS X Lion. I'm curious at seeing how long it should take to dowload?

  • Photoshop x64 in CS5 Cannot Open Any File

    When I open a JPG or RAW file in PS x64, it will show a box "stop running" and if I click OK, PS quits. Can anyone tell me what should I do? I updated CS5 to the latest version already.