Query to split the field value

Hi all
    In employees table I am having employee_name column data as follows
          Aaron, Mrs. Jamie (Jamie)
          Aaron, Mrs. Jenette (Jenette)
          Abbott, Ms. Rachel (Rachel)
          Breton, Mr. Jean
          Britz, Mrs. Sarie (Sarie)
--> Now, I want to display the employee name like "Mrs. Jamie" (with out Surname and with out bracket included text),
--> How to achieve this by SQL query. Help me out plz
Thanks in Advance
Jagadeesh

Need more sample cases:
One way (without regexp).
WITH t AS
        (SELECT 'Aaron, Mrs. Jamie (Jamie)' str FROM DUAL
         UNION ALL
         SELECT 'Aaron, Mrs. Jenette (Jenette)' FROM DUAL
         UNION ALL
         SELECT 'Abbott, Ms. Rachel (Rachel)' FROM DUAL
         UNION ALL
         SELECT 'Breton, Mr. Jean' FROM DUAL
         UNION ALL
         SELECT 'Britz, Mrs. Sarie (Sarie)' FROM DUAL)
SELECT CASE
          WHEN INSTR (str, '(') > 0 THEN
             SUBSTR (str,
                     INSTR (str, ',') + 2,
                     INSTR (str, '.') - INSTR (str, ',') - 1)
             || ' '
             || SUBSTR (str,
                        INSTR (str, '(') + 1,
                        LENGTH (str) - INSTR (str, '(') - 1)
          ELSE
             SUBSTR (str, INSTR (str, ',') + 2)
       END
          str
  FROM t;
Output:
STR
Mrs. Jamie
Mrs. Jenette
Ms. Rachel
Mr. Jean
Mrs. Sarie
Cheers,
Manik

Similar Messages

  • Report query not returning the field value from external table

    hi
    I have an issue regarding reports. I have a query having 4 fields from external table and remaining from db tables. the report query returns all the fields from the db tables and only 2 fields from external table. but the same query if I tried in plsql developer it returns all the fields values.
    Can anyone please help me in this issue.
    Thanks and Regards
    kk

    Duplicate post?
    value not displaying in report whereas it returns in plsql developer
    value not displaying in report whereas it returns in plsql developer
    Please log a SR if you do not get any reply to your thread instead of creating new one.
    Thanks,
    Hussein

  • Creating an SQL Query for Project Custom Fields Values

    Hello:
    I'm currently trying to create an SQL Query to show all of the server's Project Custom Fields Values, along with the modification date.
    So far, I've managed to display correctly all of the data for all of the Projects' text value Custom Fields (those not based on a LookUp Table) with this query:
    SELECT
    MSP_PROJECTS.PROJ_NAME,
    MSP_CUSTOM_FIELDS.MD_PROP_NAME,
    MSP_PROJ_CUSTOM_FIELD_VALUES.CODE_VALUE,
    MSP_PROJ_CUSTOM_FIELD_VALUES.TEXT_VALUE,
    MSP_PROJ_CUSTOM_FIELD_VALUES.MOD_DATE
    FROM
    MSP_PROJ_CUSTOM_FIELD_VALUES
    INNER JOIN
    MSP_CUSTOM_FIELDS
    ON MSP_CUSTOM_FIELDS.MD_PROP_UID = MSP_PROJ_CUSTOM_FIELD_VALUES.MD_PROP_UID
    INNER JOIN
    MSP_PROJECTS
    ON MSP_PROJECTS.PROJ_UID = MSP_PROJ_CUSTOM_FIELD_VALUES.PROJ_UID
    WHERE
    MSP_PROJ_CUSTOM_FIELD_VALUES.CODE_VALUE IS NULL
    ORDER BY
    MSP_PROJ_CUSTOM_FIELD_VALUES.PROJ_UID,
    MSP_PROJ_CUSTOM_FIELD_VALUES.MD_PROP_UID
    However, when I try a new Query to obtain the actual values for the Projects Custom Fields that do use a LookUp Table, I can't seem to find what table in the model I'm supposed to link to the MSP_PROJ_CUSTOM_FIELD_VALUES.CODE_VALUE field (the TEXT_VALUE
    field has NULL value when CODE_VALUE field isn't NULL)
    Any suggestions on how to obtain the actual Projects' custom fields values instead of the Code Value, for Metadata that do use a LookUp Table?
    Also, I'm able to run this query only in the Published Database, since the MSP_CUSTOM_FIELDS table is empy in the Draft Database. Why is that?
    Awaiting your kind reply,
    Sebastián Armas PMO Project Manager

    Hi Sebastián, rather than directly accessing the database it would be better to use the PSI to get this data.  Take a look at the ProjTool sample in the SDK whcih gets this data.
    Best regards,
    Brian.
    Blog |
    Facebook | Twitter | Posting is provided "AS IS" with no warranties, and confers no rights.
    Project Server TechCenter |
    Project Developer Center |
    Project Server Help | Project Product Page

  • I need query to split the string

    I need query to split the input string into comma seperated triplets values.
    Input String: Database
    Output : Dat, ata,tab,aba,bas,ase

    SQL> with t
      2  as
      3  (
      4  select 'Database' str
      5    from dual
      6  )
      7  select substr(str, level, 3) str
      8    from t
      9   where length(substr(str, level, 3)) = 3
    10  connect by level <= length(str);
    STR
    Dat
    ata
    tab
    aba
    bas
    ase
    6 rows selected.
    And if you want it as a single string then..
    SQL> with t
      2  as
      3  (
      4  select 'Database' str
      5    from dual
      6  )
      7  select ltrim(sys_connect_by_path(str, ','), ',') str
      8    from (
      9            select row_number() over(order by level) rno
    10                 , substr(str, level, 3) str
    11              from t
    12             where length(substr(str, level, 3)) = 3
    13            connect by level <= length(str)
    14         )
    15   where connect_by_isleaf = 1
    16   start with rno = 1
    17  connect by rno = prior rno + 1;
    STR
    Dat,ata,tab,aba,bas,ase

  • How to get the Output File Name as One of the Field Value From Payload

    Hi All,
    I want to get the Output file name as one of the Field value from payload.
    Example:
    Source XML
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_TEST xmlns:ns0="http://sample.com">
    - <Header>
      <NAME>Bopanna</NAME>
      </Header>
      </ns0:MT_TEST>
    I want to get the Output file name as " Bopanna.xml"
    Please suggest me on this.
    Regards
    Bopanna

    Hi,
    There are couple of links already available for this. Just for info see the below details,
    The Output file name could be used from the field value of payload. For this you need to use the UDF DynamicFile name with below code,
    //       Description: Function to create dynamic Filename
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File" , "FileName");
    conf.put(key,a);
    return "";
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File" , "FileName");
    conf.put(key,a);
    return "";
    With this udf map it with the MessageType as
    (File Name field from Payload) > DynamicFileConfiguration>MTReceiver
    Thanks
    Swarup

  • Create Excel file in application server but the field value is incorrect

    Hi Experts,
    i am facing a problem when create excel file in application server using OPEN DATASET command.
    the internal table have 4 field and one of those field contains 19 digit number --> ICCID.
    the code running well, successfully create EXCELfile in application server but the problem is SAP only copy exactly first 15 digit numeric only and the rest became zero 0
    Example :
    the field value in internal table is 8962118800000447654 but when i opened in the excel file the value became 8962118800000440000.
    and if i add alphabet like a8962118800000447654 then it is correct.
    is there is anything wrong with my code?
    here is my code
    CONSTANTS: c_tab TYPE abap_char1 VALUE cl_abap_char_utilities=>horizontal_tab. "Tab Char
    Data : begin of lt_zdsdmmdt00005 occurs 0,
             SERNR (18) type c,
             MSISDNl(20) type c,
             BOX1 (20) type c,
             ICCID(30) type c,
           end of lt_zdsdmmdt00005.
    data : ld_temp(100) type c.
    i_file = '/usr/sap/DM/test_excel.xls'.
    open dataset i_file for output in legacy text mode.
      loop at lt_zdsdmmdt00005.
        move lt_zdsdmmdt00005-ICCID to ld_iccid .
        concatenate lt_zdsdmmdt00005-sernr  lt_zdsdmmdt00005-MSISDN  lt_zdsdmmdt00005-BOX1 ld_iccid
        into ld_temp separated by c_tab.
        transfer ld_temp to i_file.
      endloop.
      close dataset i_file.
    Best Regard,
    Akbar.

    Hi Naveen,
    thanks for your reply,
    i already tried and the result still the same. any idea?
    Best Regard,
    Akbar.

  • UDF for Checking the field value

    Hi
    I want to check the whether the fiels conatins any value or not in mapping ... if not i want to raise the exception using the UDF
    DO any one have sample code for writing the UDF
    SV

    Hi SV
    what is your requirement first that should br clear.
    i am giving you two UDF
    1) i have written this uDF for string and comparing the field value XYZ
    2) i am entering a string and its returning aa string which starts from the index of your input fixed length
    int len = a.length();
    String res = "";
    String temp = "";
    if ( len >= 10)
    temp = a.substring(0,10);
    if ( temp.equals("XYZ"))
    res = temp;
    else
    res = "";
    return res;
    =======================================
    String fixed = "ABCD";
    String res = "";
    int index = -1;
    index = a.indexOf(fixed);
    if (index == -1)
    res = "NO INDEX FOUND";// or if u wanna set it as null res = "";
    else
    res = b.substring(index4,index12);
    return res;
    ===
    hope these may solve your problem
    Thanks
    Sandeep sharma
    If helpful reward points

  • About give from one query to other the same value of a variable

    Hi Gurus,
    my problem is About give from one query to other the same value of a variable, i have a wad with a view, and this wad has some bottoms in javascript to go to anothers wad with charts, the problem is when i ran the query one, i put a value = calyear:2008 (Obligatory Variable), but when i click the bottom to go to the other query with the same variable, he ask me again a value,
    i want write a value just one time, and the others wad can recieve the first value that i put when the wad opened.
    i really need it , thanks !

    Hello Jorge,
    What you need here is Replacement path variable. Check out this link for more details:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/bd/589b3c494d8e15e10000000a114084/content.htm
    In the second query where you need the value (calyear:2008 from first query) create a Variable for calyear of type Replacement path, in Replacement tab you can select either query or variable by which it has to replaced. In your case, it has to be variable from the first query.
    Do let me know if this works. If this does not work I suggest you to use Web APIs to replace the variable values using Web APIs. Check out the details:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/29/4d15422ecce02ce10000000a1550b0/frameset.htm
    Hope this helps.
    Regards,
    Srini

  • Excluding the alpha charactes in the field value

    Hi All,
    I have a requirement where I need to delete all the character values in a field..
    Ex: If the field value of ABC123a....then i need to delete the 'ABC' and i shuld retain wid 123a.
    Please do the need ful.
    Thanks,
    Shiva

    Hi Shiv,
    take a variable of type n and move this into thatvariable.
    Data:
    w_char(20) type c  value 'ABC123a',
    w_num(20) type n.
    w_num = w_char.
    w_num will have 123.
    or
    Data:
    w_str(20) type strin value 'ABC123a',
    w_num(20) type c,
    w_len type i.
    w_len = strlen( w_str ).
    do w_len times.
      if w_str+sy-index(1) ca '0123456789'.
        concatenate w_num w_str+sy-index(1) into w_num.
      endif. 
    enddo.

  • How to keep the field value in the forms for one week

    I have an application that when the user logs on to it , it shows all the documents that are in the current dept.
    the form has the following fields:
    document no
    sent date
    assigned to
    dep_LOV
    and a check box
    if a user clicks the check box and assignes the document to another dept by cliking the LOv then the assigned to field should be populated with the new value and the sent date should be today's date(sysdate). the requirment is that once the user assignes the documnet to certain depts (for example sales dept) the assigned to field and the sent date should show up in the form for one week and the user should be able to see that data in the form the next time she /he logs onto the application. the one week time is to make sure the documcnt has reached the assigned dept. after one week from today's date the updated assigned_to field and the document no should not display on the form. During the one week if the user logs on to the form again that particular document and the assigned to and sent to fields shoould be grayed out and shhould not be updatable. I will greatly appreciate any suggetion as of what to do to solve this problem. it is urgent. Pleade help

    -> so you are saying that I should have a block level post_query trigger and put the where clause in it?
    No. Post-query trigger runs AFTER the query has been executed, and it runs once for each row fetched. It is for other purposes, NOT for setting a where clause.
    -> Plus i want to be able to gray out the field once populated with the sales dept.I have come up with the following code:
    Your Set_item_instance_property is almost correct. And THAT line would go into the Post-Query trigger. This is what you might use:
    <pre><font face = "Lucida Console, Courier New, Courier, Fixed" size = "1" color = "navy"> Set_item_instance_property ('docs.assigned_to',:system.trigger_record, Enabled,Property_False);</font></pre>
    Please watch your use of underscore, dashes, commas and parentheses: _ - , ( )
    The way to set your default where clause would be the following, and you should do it in the key-exeqry trigger, or someplace similar:
    <pre><font face = "Lucida Console, Courier New, Courier, Fixed" size = "1" color = "navy"> set_block_property('DOCS', default_where,
    'NVL(sent_date,sysdate) >= sysdate-7' );
    Go_block('DOCS');
    Execute_Query;</font></pre>
    I used the NVL function so your select will show rows where sent_date is null OR sent_date has a value that is within 7 days prior to the current date.
    What is the field :docs.assigned_to used for? If you want to include ONLY rows that are assigned to a particular person, then your where clause might be:
    <pre><font face = "Lucida Console, Courier New, Courier, Fixed" size = "1" color = "navy"> 'assigned_to = :ctrl.assigned_to and NVL(sent_date,sysdate) >= sysdate-7' </font></pre>
    and you should have a control block with the assigned_to field in it, where the user can enter a value before querying the DOCS block.

  • Accessing the field values in different fields for calculation

    Hi,
    I am creating a report in which I have used breaks for grouping the  customers by their category. I have used summary on the amount field to calculate the sum in the individual category and also for total amount.
    Now, I also want to add an column which could display the percentages of individual contributions.
    So, its like I have to write a query accessing the total percentage, categorized percentage and individual amount.
    My question: How can I access the various fields values in the query of some other field specifically sum and total sum( because it shows the sum([Amount]) for category sum and total sum both)
    -BOBJuser

    Hmmm, I assume you are talking about WebIntelligence here...
    Ok, so let's go: you can access every "object" in the report simply by it's name. Every cell contains either a constant value (e.g. some text) or a formula, the simplest one can be just the value of an "object" from the query.
    There is a formula bar on top which you can activate, where you can easily see the content of a specific cell and also copy/paste the formula from the cell, as well as access all the built-in functions.
    WebI has a built-in calculator which works very similar to a "micro" olap engine, so you can access every sort of aggregate (of a measure) via a correspondig formula, irrelevant in which cell you are using it.
    Nevertheless, there is a "computation context" which depends on the place where you put the formula, e.g. summary row, detail row, etc.
    for more info: see the manual )
    hth, Walter

  • Creating a dynamic query by choosing the field and getting the report

    Hi,
    Is there a way to create a report by allowing the user to choose a field from the table and design a query based on that field.
    Ex In a table students with fields
    (StudentNo, StudentName,Age,Qualification,Hobbies, PlaceofBirth)
    Is it possible to generate a query
    select * from students where Hobbies=programming;
    where the user can be given the option of selecting the field and the value (Hobbies, programming), the query is generated for that, then the report is designed for that query. How could the query be generated?
    Regards,
    Reshma

    You sure can ;)
    Here's an example.
    You can create a JComboBox and have the different categories of hobbies in there and then use ActionListener on the JcomboBox.
    The code will be something like this
    public void actionPerformed(ActionEvent ae)
      if(ae.getSource()==combo)    //assuming the JComboBox object is combo
        String query=new String("");
        String st = combo.getSelectedItem().toString();
        Connection connection=DriverManager.getConnection("jdbc:odbc:DSN","user","password");
        Statement stmt=connection.createStatement();
        String qry="SELECT * FROM tablename WHERE hobby=";
        String query=qry+st;
        ResultSet rs=stmt.execute(query);     //Then do whatever you want with the ResultSet object
    }

  • Modify the field value in itab1 using itab2

    Hi experts
    I need some help.
    My question is : I have ITAB1 contains IBLNO field it is a legacy value.
    I want to modify this field.
    Another internal table  ITAB2 contains sap, legacy value of IBLNO(Cross refrenced table).my requirement is  IBLNO of  ITAB1 is modified with corresponding sap IBLNO in ITAB2.
    plz help
    Durga Parsad

    Hi Durga,
    You want to get following results -
    1. You have ITAB1 containing IBLNO.
    2. ITAB2 has IBLNO.
    3. Modify ITAB1-IBLNO from ITAB2-IBLNO.
    4. There must be some common value between the two tables. It has to be there otherwise the two records won't match.
    Kindly find the following code for doing so -
    LOOP AT ITAB2 INTO WA_ITAB2.
    * Modify ITAB1 from workarea of ITAB2 for matching records
      MODIFY ITAB1 FROM WA_ITAB2     
        TRANSPORTING IBLNO                " Modify only IBLNO of ITAB1 for matching records
        WHERE FIELD1 = WA_ITAB2-FIELD1.   " Some common field between the ITAB1 & workarea of ITAB2  
      CLEAR WA_ITAB2.
    ENDLOOP.
    Hope this helps.
    PS If the answer solves your query, plz close the thread by rewarding each reply and marking it Solved.
    Regards

  • After Execute Query I cannot modify fields values.

    I enter in "enter-query", put some values and I enter in "execute-query", my forms return filled with database values, but I cannot modify the fields and update records, when I try to modify, exception raises: FRM-40200.
    What Can I do to solve this?
    Thanks for patience.

    Check in your form if the property is changed at runtime.
    Check for set_item_property(<item_name>,INSERT_ALLOWED,property_false);
    Check for set_item_property(<item_name>,UPDATE_ALLOWED,property_false);
    or
    Check for set_block_property(<block_name>,INSERT_ALLOWED,property_false);
    Check for set_block_property<block_name>,UPDATE_ALLOWED,property_false);
    Cheers
    AT

  • How to transfer the field values in MA form RFX

    Hi
    We have two  fields ( extended field of date type ) in Rfx page . Now client wants that this two field value will be transferred to Master Agreement page while creating MA form Rfx award .
    Is there any possible way to do this ?
    Regards
    Sudipta
    Edited by: Sudipta62 on Dec 20, 2011 10:38 AM

    Sudipta, Vikram,
    If names are the same, are the fields transferred automatically? Or do we still write code?
    Thanks,
    MP

Maybe you are looking for

  • 9iAS R2 Automatic Startup at Boot time on Windows

    How to successfully start the 9iAS R2 Application Server at boot time. Many of you are still struggling with the problem of 9iAS R2 not automatically starting up properly when your system is restarted. I've been fighting this issue for several weeks

  • Chinese trackpad input not working - won't insert characters

    Hi all, I've been trying to set up chinese character input for an hour already, and no luck yet. I've read tons of articles here but the solutions mentioned made no difference. I open TextEdit (or Chrome, Notes, Safari... any app, really) and hit ctr

  • Suddenly all my B&W filters are Lavender!

    using original CS. don't know how this happened. was playing with gradients somewhere, found this lovely lavender. thought i was just changing it on one filter one place one time for one layer. but now, every time and with every document i open/reope

  • How to add a printer to a mac ?

    I have a printer hooked up directly to a windows based pc which is connected to wifi how would i have my mac be connected to that printer at all times ?

  • Mail Repeatedly Crashes after Initialize and Restore 10.6.4

    After the suggestion by a Mac Specialist over the phone over a months time with issues about all of my iLife apps quitting. A initialize and restore was suggested. I did it and now I have a new a problem with MAIL. Now MAIL repeatedly crashes and qui