Change a string into a different format

How do I convert this
CN=zeeeComputerName,OU=cars,OU=sales,OU=employees,OU=Desktop,DC=carplace,DC=com
to this
carplace.com/desktop/employees/sales/cars/zeeeComputerName

See the complete illustration
--variable to hold your string
declare @str varchar(100)
set @str= 'CN=zeeeComputerName,OU=cars,OU=sales,OU=employees,OU=Desktop,DC=carplace,DC=com'
--Actual solution
;With CTE
AS
select LEFT(Val,CHARINDEX('=',Val)-1) AS Grp, SUBSTRING(Val,CHARINDEX('=',Val)+1,LEN(Val)) AS Val,
ROW_NUMBER() OVER (PARTITION BY LEFT(Val,CHARINDEX('=',Val)-1) ORDER BY CASE WHEN LEFT(Val,CHARINDEX('=',Val)-1) = 'OU'THEN ID ELSE -ID END DESC) AS Seq
from dbo.ParseValues(@str,',')
SELECT STUFF((SELECT '.' + Val FROM CTE WHERE Grp = 'DC' ORDER BY Seq FOR XML PATH('')),1,1,'')
+ '/' + STUFF((SELECT '/' + Val FROM CTE WHERE Grp = 'OU' ORDER BY Seq FOR XML PATH('')),1,1,'')
+ '/' + STUFF((SELECT '.' + Val FROM CTE WHERE Grp = 'CN' ORDER BY Seq FOR XML PATH('')),1,1,'')
FROM (SELECT 1 AS n) t
ParseValues UDF can be found here
http://visakhm.blogspot.in/2010/02/parsing-delimited-string.html
if string is coming from a table make query as below
--Actual solution
;With CTE
AS
select t.ColumnName,
LEFT(Val,CHARINDEX('=',Val)-1) AS Grp, SUBSTRING(Val,CHARINDEX('=',Val)+1,LEN(Val)) AS Val,
ROW_NUMBER() OVER (PARTITION BY LEFT(Val,CHARINDEX('=',Val)-1) ORDER BY CASE WHEN LEFT(Val,CHARINDEX('=',Val)-1) = 'OU'THEN ID ELSE -ID END DESC) AS Seq
from YourTableName t
CROSS APPLY dbo.ParseValues(t.ColumnName,',')
SELECT STUFF((SELECT '.' + Val FROM CTE WHERE Grp = 'DC'
AND ColumnName = t.ColumnName ORDER BY Seq FOR XML PATH('')),1,1,'')
+ '/' + STUFF((SELECT '/' + Val FROM CTE WHERE Grp = 'OU' AND ColumnName = t.ColumnName ORDER BY Seq FOR XML PATH('')),1,1,'')
+ '/' + STUFF((SELECT '.' + Val FROM CTE WHERE Grp = 'CN' AND ColumnName = t.ColumnName ORDER BY Seq FOR XML PATH('')),1,1,'')
FROM (SELECT DISTINCT ColumnName FROM CTE) t
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • Convert XML string into an abap format date and time

    Hi,
    Does anyone know of a method or a function module in ABAP which converts XML string into an abap format date and time.
    Here is a part of the xml that I want to convert.
    <ns2:EventDateTime>2009-07-02T10:13:45+10:00</ns2:EventDateTime>
    <ns2:EventMessageTransmissionDateTime>2009-07-02T10:13:45.987+10:00</ns2:EventMessageTransmissionDateTime>
    Currently EventDateTime and EventMessageTransmissionDateTime are type XSDDATETIME_Z and these are converted to proper dates and times. We will be changing these fields to a STRING instead of XSDDATETIME_Z. The reason for this is to make the field more versatile. The customer would be receiving dates with Zulu (2009-09-23T12:00:00Z), with offsets (2009-09-23T12:00:00+10:00/-10:00) and just local timestamp (2009-09-23T12:00:00). With this, we need to make the date fields as string
    to be able to accept the various date formats (esp. the local timestamp).
    I am looking for a standard function module or method that will convert the xml string to a proper date and time abap format.
    Would appreciate anyone's help!
    Thanks.
    Edited by: eunice ocson on Jul 13, 2009 1:49 AM
    Edited by: eunice ocson on Jul 13, 2009 1:50 AM
    Edited by: eunice ocson on Jul 13, 2009 1:51 AM
    Edited by: eunice ocson on Jul 13, 2009 1:51 AM

    Hi Eunice
    Use the FM 'SMUM_XML_PARSE'
    for more info
    [Convert XML string to ABAP|XML String to ABAP or GUI]
    hope it helps you.
    Thanks!!

  • Converting a string into mySQL date format

    I have a bit of code that collects data values from a bean and I want it to then insert this into a mySQL database. My string is in the format "23/12/1983", how can i put this into a date field in my database? The bit of code I have got so far looks like this...
    String month = formHandler.month + "/";
    String day = formHandler.day + "/";
    String year = formHandler.year ;
    StringBuffer sb = new StringBuffer();
    sb.append(day);
    sb.append(month);
    sb.append(year);
    String myDate = sb.toString();myDate is the value that I want to go into the database

    Limo2kz,
    The key to inserting a date into a database is to convert the date string into an SQL friendly format. i.e. yyyy-MM-dd.
    One way of doing this is as follows:
    SimpleDateFormat NICE_DATE_FORMAT =
    new SimpleDateFormat("dd/MM/yyyy");
    SimpleDateFormat SQL_DATE_FORMAT =
    new SimpleDateFormat("yyyy-MM-dd");
    Date date = new Date();
    try {
    date = NICE_DATE_FORMAT.parse(dateString);
    } catch (ParseException pe) {
    pe.printStackTrace();
    String sqlDate = SQL_DATE_FORMAT.format(date);
    Now it is just a matter of creating the insert statement like normal, and making sure that the date string is in quotes.
    I hope that helps.
    Damian Sutton

  • How to convert a string into orcle date format

    i need some information about converting string into date format.i have string like '20-SEP-05' .so we have to convert into date formate like yy-mm-dd' (2005-09-20).how can we do it.

    Here's some code to help. I can't remember what method uses what format though
      public static java.sql.Date sqlDateValueOf( String dateString ) {
        String stringDate = null;
        if ( dateString == null || dateString.length() < 10 ) return null;
        String strDay = "";
        String strMonth = "";
        String strYear = "";
        if ( dateString.substring(4,5).equals( "-" ) ) {
          strDay = dateString.substring(8, 10);
          if ( strDay.length() < 2 ) strDay = "0" + strDay;
          strMonth = dateString.substring(5, 7);
          strMonth = dateString.valueOf(Integer.parseInt(strMonth) - 1);
          if ( strMonth.length() < 2 ) strMonth = "0" + strMonth;
          strYear = dateString.substring(0, 4);
          stringDate = strDay + "-" + strMonth + "-" + strYear;
        else if ( dateString.substring(2,3).equals( "-" ) ) {
          strDay = dateString.substring(0, 2);
          if ( strDay.length() < 2 ) strDay = "0" + strDay;
          strMonth = dateString.substring(3, 5);
          strMonth = String.valueOf(Integer.parseInt(strMonth) - 1);
          if ( strMonth.length() < 2 ) strMonth = "0" + strMonth;
          strYear = dateString.substring(6, 10);
          stringDate = strDay + "-" + strMonth + "-" + strYear;
        Calendar cal = Calendar.getInstance();
        cal.set( Calendar.YEAR, Integer.parseInt( strYear ) );
        cal.set( Calendar.MONTH, Integer.parseInt( strMonth ) );
        cal.set( Calendar.DAY_OF_MONTH, Integer.parseInt( strDay ) );
        java.sql.Date outDate = new java.sql.Date( cal.getTimeInMillis() );
        return outDate;
      public static String toDateString( java.util.Date date) {
        if ( date == null || date.toString().length() < 10 ) return null;
        String outDate = "";
        SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
        outDate = df.format( date );
        return outDate;
      public static String toDateString( java.sql.Date date) {
        if ( date == null || date.toString().length() < 10 ) return null;
        String outDate = "";
        SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
        outDate = df.format( date );
        return outDate;
      public static String toDateString( java.sql.Date date, String format) {
        if ( date == null || date.toString().length() < 10 ) return null;
        String outDate = "";
        SimpleDateFormat df = new SimpleDateFormat( format );
        outDate = df.format( date );
        return outDate;
      public static String toDateString( java.sql.Timestamp date) {
        if ( date == null || date.toString().length() < 10 ) return null;
        String outDate = "";
        SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
        outDate = df.format( date );
        return outDate;
      }

  • Change a string parameter for different session

    Hi Gurus,
    I would like to find out how can I change a string parameter for an existing different session?
    In DBMS_SYSTEM package there are two functions :
    - SET_INT_PARAM_IN_SESSION
    - SET_BOOL_PARAM_IN_SESSION
    which change values of parameters, but not string ones :(
    Is it possible and if not, is there an alternative for changing STATISTICS_LEVEL for different session to ALL?
    Thank you in advance,
    Ela

    Hi,
    >>Once again: how to change a string parameter for a DIFFERENT session?
    Once again I will repeat if I was not clear before: You cannot to do this. Just directly using ALTER SESSION against the session.
    * SET_INT_PARAM_IN_SESSION: Sets[u] integer-type init.ora parameters in any session
    * SET_BOOL_PARAM_IN_SESSION: Sets boolean-type init.ora parameters in any session
    Cheers
    Legatti

  • Can iTunes change DVD's into a .mov format ?

    So can iTunes change the format of a DVD into the format it needs to be put onto the video iPod cause this kid at my school says you can...But I put a DVD in and tried to import it and everything and nothing happened so am I doing something wrong or can iTunes convert DVD's to the iPod format?
    Thanks

    Yea I figured you couldnt but maybe so I asked...So just google it for what I already have 2 converters but one has a watermake that says "Trial Version" and the other one only converts 5min of the DVD and that Videora has to install online and keeps saying "Server Timed Out" and then I have to restart the installation process for it. So what should I google?

  • How to change in sql_text into normal readable format?

    hi all
    yesterday inour production environment the dev. did wrongly updated one query.
    they want to know who and when did the changes?
    i found some info from dba_audit_object,
    but in that table the column for sql_text is not showing the full query ,it shows the update table_name set column name=new row id where =old row id..
    by using this query i dont know how to trace the sql_query in norma readble format.
    pls help me to sort out this issue..
    Thanks
    M.Murali..

    Hi
    I am little confused with your question...
    >
    they want to know who and when did the changes?
    but in that table the column for sql_text is not showing the full query ,it shows the update table_name set column name=new row id where =old row id..
    by using this query i dont know how to trace the sql_query in norma readble format.
    >
    If you are getting back the update table_name set column name=new row id where =old row id.. statement then you can get back the values you want.so, what does by using this query i dont know how to trace the sql_query in norma readble format mean.The update statement is in readable format only.
    The answer for who and when changed it is
    select USERNAME,to_char(TIMESTAMP,'DD-MON-YY HH24:MI:SS'),USERHOST,TERMINAL,OWNER,OBJ_NAME,ACTION_NAME,SQL_TEXT from DBA_AUDIT_OBJECT;
    The username will be the database username who updated the column.Timestamp will tell you the time when it was done,terminal will give the terminal name of the PC,owner is the object's owner and sql_text is the update command fired by the username on the owner's table.
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    SQL> sho parameter audit
    NAME                                 TYPE        VALUE
    audit_file_dest                      string      C:\ORACLE\PRODUCT\10.2.0\ADMIN
                                                     \MATRIX\ADUMP
    audit_sys_operations                 boolean     FALSE
    audit_trail                          string      DB, EXTENDED
    DB,EXTENDED -- As db, but the SQL_BIND and SQL_TEXT columns are also populated.
    SQL> grant select,insert,update on scott.emp to lap;
    Grant succeeded.
    *FROM THE LAP SESSION DID*
    SQL> update scott.emp set MGR=7777 where MGR=7698;
    5 rows updated.
    SQL> commit;
    Commit complete.
    FROM THE OTHER SYS AS SYSDBA SESSION
    SQL> select count(1) from sys.aud$;
      COUNT(1)
             1
    SQL> select USERNAME,to_char(TIMESTAMP,'DD-MON-YY HH24:MI:SS'),OWNER,OBJ_NAME,ACTION_NAME,SQL_TEXT from DBA_AUDIT_OBJECT;
    USERNAME                       TO_CHAR(TIMESTAMP, OWNER
    OBJ_NAME
    ACTION_NAME
    SQL_TEXT
    LAP                            15-NOV-08 17:31:45 SCOTT
    EMP
    UPDATE
    update scott.emp set MGR=7777 where MGR=7698
    So i am getting the sql_text of the update done by LAP user on the SCOTT's  EMP table.HTH
    Anand

  • Changing QT movies  into  Media player format

    Hi
    On my web page, I have a number of QT movies that won't play on PC unless they get QT for PC (which seems to be a problem for some people). How can I transfer my QT movies into a Media Player format ?
    Thanks

    http://www.flip4mac.com/
    You can offer two versions or continue to use QuickTime.
    The "conversion" to Windows Media format should only be done from the original source files.
    I've found that a simple "explanation" page (that describes the value of QuickTime) works just as well. Knowledge is consumer power. H.264 video codec is making rapid inroads to our Web content.

  • My ipod nano 5th gen freezes when i try to play a certain song, and itunes gives me an error message when i try to convert it into a different format!! i just bought the song this morning, so i dont see why it wont work! any help would appreciated!!

    so yea, the title pretty much says it all. I bought a song called LOL Money by Jace Hall this morning, along with Sub-Zero VS Scorpion rap battle by Brysi. when i synched them to my ipod nano, the rap battle would play, but LOL Money would just freeze my ipod and i would have to reboot it. does anyone know why it is doing this??

    Does this problematic song play okay in iTunes?  Have you tried removing and resyncing it to your device via iTunes?
    B-rock

  • String into un readable format

    Hi all,
    i have filed of 120 characters, the data in the field is passed to bar code label. and i will print this barcode.
    Now i will read this bar code using scanner. at that time the data present in the label is displayed in text file, this is readable by all.
    but i dont wanrt this text in readable form.
    Is there any function module to make it un readable. and when i need this should be radable, how to achieve this.
    Rgds
    Ramesh

    Hi,
    If you are using BARONE for desining your barcode, it generates the printer codes in background. You can simply take the code and use it in your SAP Script as it is passing the parameters.
    OR Tcode SE73 - to define BARCODE fonts and use it in your form.
    Hope this solves your problem very easily.
    Regards,
    Gaurang

  • String into date format

    Hi
    I was wondering if anyone knew how to convert a string into different formats,
    to enable it to be stored in a mysql db.
    I was wondering anyone you knew how to convert:
    - String into the date format yyyy-mm--dd
    - String into time format 00:00:00
    - string to double
    Ive tried:
    c_date = java.sql.Date.valueOf(f_date);
    System.out.println("conversion data: " +c_date);
    c_time = java.sql.Time.valueOf(f_time);
    System.out.println(" time converted data: "+c_time);
    // string to double conversion
    c_change = java.lang.Double.valueOf(f_change);
    System.out.println(c_change);
    My class doesnt execute this at all?
    Also,
    SimpleDateFormat sdft = new SimpleDateFormat("yyyy-MM-dd");
    c_date = sdft.format(f_date);
    System.out.println(c_date);
    .. but this method returns the error incompatible types?
    Any suggestions would be helpful.. thanks in advance..

    Friends i've got similar kind of problem...can you help me
    here is my code. When i try to print the user entered date (dd/MM/yyyy)(which i am storing in a string) the program dispalys nothing. and everey time i enter a valid date it displas "invalid From date entered ". I need to store the user entered date into a string because i need that for further use. All my intesion is to get two dates from user in dd/MM/yyyy. Strore them in certain variable. Check if they are valid or not. and make sure todate is either equal or greater than fromdate. Please help me to solve this problem.
    public class EDTDateValidation extends JFrame implements ActionListener{
    private JLabel fromlabel;
    private JLabel tolabel;
    private JTextField fromtxt;
    private JTextField totxt;
    private String fmt ="dd/MM/yyyy";
    private java.lang.String fromdate;
    private java.lang.String todate;
    private JButton buttonOK;
    private JButton buttonCancel;
    private Date theDate;
    private Date date1;
    private Date date2;
    private JPanel mainPanel;
    SimpleDateFormat dtformat = new SimpleDateFormat(fmt);
    public EDTDateValidation(){
    super("Date Validation");
    dtformat.setLenient(false);
    mainPanel=new JPanel();
    mainPanel.setLayout(null);
    fromlabel = new JLabel("From Date");
    tolabel = new JLabel("To Date");
    buttonOK = new JButton("OK");
    buttonCancel = new JButton("Cancel");
    fromdate = new String();
    todate = new String();
    fromtxt = new JTextField(10);
    totxt = new JTextField(10);
    fromdate = fromtxt.getText();
    todate = totxt.getText();
    mainPanel.add(fromlabel);
    fromlabel.setBounds(20,20,50,15);
    mainPanel.add(tolabel);
    tolabel.setBounds(20,50,50,15);
    mainPanel.add(fromtxt);
    fromtxt.setBounds(90,20,130,20);
    mainPanel.add(totxt);
    totxt. setBounds(90,50,130,20);
    mainPanel.add(buttonOK);
    buttonOK.setBounds(70,80,71,23);
    mainPanel.add(buttonCancel);
    buttonCancel.setBounds(150,80,71,23);
    buttonOK.addActionListener(this);
    buttonCancel.addActionListener(this);
    setContentPane(mainPanel);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(247,140);
    setResizable(false);
    //pack();
    public static void main(String args[]) {
    try {
    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    catch(Exception e) {
    System.err.println("Could not load Look and Feel" + e);
    EDTDateValidation edtDateVal = new EDTDateValidation();
    edtDateVal.setVisible(true);
    public void actionPerformed(ActionEvent e) {
    if(e.getSource() == buttonOK){
    System.out.println(fromtxt.getText());
    System.out.println(fromdate); //THIS PRINTS BLANK
    System.out.println(todate); //THIS ASWELL
    try {
    Date date = null;
    date = dtformat.parse(fromdate);
    System.out.println("valid From date entered!");
    catch(Exception f) {
    System.out.println("Invalid From date entered!");
    // textField1.setText("");
    return;
    try {
    Date date = null;
    date = dtformat.parse(todate);
    System.out.println("valid TO date entered!");
    catch(Exception f) {
    System.out.println("Invalid To date entered!");
    // textField1.setText("");
    return;
    }

  • How do you change iTunes songs into AAC format?

    Is there a way to change iTunes songs into the AAC format. I need to be able to do this so I can download the songs into my cell phone with an MP3 player. I keep on getting a message saying that the songs are protected and cannot be changed to that format. I dont understand why since I have payed for them and they are my songs. PLEASE HELP!
    Toshiba Satellite   Windows XP  

    Store purchases are already in protected AAC format.
    Do you mean that you need to change them to mp3 to
    be compatible with you phone?
    It says that it needs to be in MP3,AAC,or AAC+ Format. Whatever its in now it is not working and im very unsure of what to do. Thankyou for trying to help.

  • Compatibility icon not showing up when I "share" my file (want to save in different format)

    I'm trying to save my file as "avi", but I can't find any way for me to do that. I searched up how to export it into a different format and saw that there is a compatibility icon. However, when I tried to do that, it wasn't there. I also downloaded video converting apps and I just wanted to see if there is an easier way to convert it, especially if I end up having a big file.
    I have iMovie Version 10.0.4.
    Any ideas on how I can export it as a different format?
    Thank you!

    Hello Veronica.
    Although possibly not related to your problem, I will remind you that the version of Firefox you are using at the moment has been discontinued and is no longer supported. Furthermore, it has known bugs and security problems. I urge you to update to the latest version of Firefox, for maximum stability, performance, security and usability. You can get it for free, as always, at [http://www.getfirefox.com getfirefox.com].
    As for your question, hopefully this support article is what you need:
    If you access your history, you can see that it is sorted by date (you can sort it by other criteria, if you want). Maybe that is the source of the confusion?

  • Using scan from string to convert a string into a number

    I wanted to use scan from string to change a string into a decimal number, but when the string is, for example, 9.14123E-2 it just returns 10. How can I get it to return .00914 or 9.14E-2(as a number not a string). Would there be something easier than scan from string? I'm using labview 5.1. Thank you!

    Hello,
    May be you can checkout the attached example.
    Perkash Mohan Lal
    Institute of Semiconductor Technology
    Technical University Braunschweig
    Attachments:
    string_conversion_1.vi ‏44 KB

  • Using an IDOC sending the same message in two different format

    i have a message which i have to be sending from one SAP system to another, but the message should be split into 2 different formats using mapping and send to one receiver where the 2 messages are segregated using some ID number. here we will be using IDOC for sender.
    kalyan.

    Hi,
    I think you can go for the  multimapping(1:2) and not exactly splitting the message but mapping it one source to two different targets that need to be sent to one receiver...
    Just see these blogs on that..
    /people/jin.shin/blog/2006/02/07/multi-mapping-without-bpm--yes-it146s-possible
    /people/venkataramanan.parameswaran/blog/2006/03/17/illustration-of-enhanced-receiver-determination--sp16
    You need to go for enhanced interface determination.
    Thanks,
    Vijaya.

Maybe you are looking for

  • SAP CRM - no confidence in UI by SAP?

    After reading this blog and looking at the article attached to the blog.  I had an interesting question: Can Rich Internet Applications finally be accepted as a credible application development platform for SAP? Does SAP have any confidence in its ow

  • QS41_Code are not getting displayed

    Dear Experts, Scenario is, 1.     T-Code QS41 2.     Under code groups (of any catalogue) certain codes have been created. 3.     The same entries can be viewed through tables QPCT and QPCD. 4.     Unfortunately we could not see the codes in transact

  • Can I get some help for a really weird problem? Song always skips to beginning.

    I have a song on my iPod that always plays the beginning part of the song, no matter where I am in the song. If the song is 3 minutes long and I go to 1:50 on the time meter it will still play the beginning part of the song, even though the time mete

  • Recording BBC iPlayer on DVD

    I have now obtained a Samsung WriteMaster S084C, and have found that I can use iTunes to burn DVDs (so that is the answer to my otherwise unanswered post in this subforum). I now want to burn a recording from BBC iPlayer on to a DVD. Do I need to use

  • How to add adf faces in component pallete of jdeveloper 11g?

    how to add adf faces in component pallete of jdeveloper 11g?