How to get the first letter alone in Upper case?

SQL*Plus: Release 9.2.0.1.0 - Production on Thu Jan 15 11:13:44 2009
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options.
Hi all,
Sorry if i am posting this one as a clone. I want the first letter alone in UPPER case in the given data. Is there any specific SQL function to do it or can we do it in REGEXP?
I have tried with this below one query.
select Upper(substr('oracle code',1,1))||substr('oracle code',2) from dual;
Oracle code
Is anything better than this in performance wise? If so please help me.
Thanks,
Ram

Hi,
what if the string is like this
SELECT INITCAP(substr('oracle code Error ', 1, instr('oracle code Error ', ' '))) ||
       substr('oracle code Error', instr('oracle code Error ', ' '), length('oracle code error '))
FROM dual;

Similar Messages

  • First letter alone in Upper case?

    Oracle 10G Enterprise edition
    Hi all,
    I am trying out to make the first letter alone in Upper case. The following query makes my output .
    SELECT UPPER(SUBSTR('long string without upcase',1,1))||SUBSTR('long string without upcase',2) FROM DUAL
    Long string without upcase
    How can i replicate the same with Regular Expression? Which one is performance oriented?
    The above one or the one with regular expression.
    Help me out to get a clear idea.
    Thanks
    Ram

    Even with very simple regular expressions substr performs a tick faster ( on 10.2.0.4)
    SQL> select * from v$version where rownum < 2;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    SQL> declare
      2  l_start number;
      3  l_initcap varchar2(100);
      4  begin
      5  l_start:=dbms_utility.get_time;
      6  for i in 1..100000 loop
      7  select upper(substr(ename,1,1))||substr(ename,2) into l_initcap from emp where rownum=1;
      8  end loop;
      9  dbms_output.put_line('SUBSTR Time: '||(dbms_utility.get_time - l_start));
    10  l_start:=dbms_utility.get_time;
    11  for i in 1..100000 loop
    12  select initcap(REGEXP_SUBSTR(ename,'[^( )]+',1,1))||REGEXP_SUBSTR(ename,'[^( )]+',1,2)
    13  into l_initcap
    14  from emp
    15  where rownum=1;
    16  end loop;
    17  dbms_output.put_line('REGEXP Time: '||(dbms_utility.get_time - l_start));
    18  end;
    19  /
    SUBSTR Time: 314
    REGEXP Time: 423
    PL/SQL procedure successfully completed.I would however expect, with more complex regular expressions, the performance will decrease (but, of course, is only an assumption).
    Best regards
    Maxim

  • How to get the first letter in Name as INITAL

    I am trying to put the first letter of first name as INITIAL in a sp column but I am not able to get the exact result. Could anybody help me with that
    TIA

    Thanks for the reply
    But where do I find the LEFT in the formula field

  • How to Capitalize the first letter or an entire word using a shortcut on the keyboard just like in microsoft that uses shift+F3

    please how can one How to Capitalize the first letter or an entire word using a shortcut on the keyboard just like in microsoft that uses shift+F3

    What do you mean there was "no effect?" I'm not aware of any effects.
    It looks like that Service is also in the App Store. From their screen shots, the services are prefaced with WordService:
    You can see an example in the App Store for their app: App Store
    After installing, you should now have those text services in your Services menu. You can then add shortcuts in the Keyboard System Prefs.
    Most Apple apps have a Transformations menu in the Edit menu. You can Make upper, lower, and Initial caps with those. I would stick with Word Services, but you can make Application Shortcuts for the items in the Transformations menu.
    Again, in Keyboard System Prefs, Under Applications, Click the Add button on the right side pane.
    Set it for All Applications
    Enter the menu command exactly as they appear in the Transformation menu (separate entries for each),
    Make Upper Case
    Make Lower Case
    Capitalize
    Give them a shortcut.

  • How to get the first day in the month from a domain date ?

    Hi,
    I like to know how to get the first day in the month from a domain date?
    Thanks
    Stephen

    Hi Gokul...
    Instead of using the funtion module you can just write the 3 statements of code to get the first day of the week.
    Its similar to the above one but instead of writing case statement you can achive the following.
    data : w_res type i,
             w_data type d,
    w_res = w_date mod 7.
    w_date = w_date - w_res.
    write w_date.
    This works.
    Regards,
    Siddarth

  • How  to  get the FIRST DAY OF THE CURRENT MONTH

    how to get the FIRST DAY OF THE CURRENT MONTH in oracle 9i.
    plzzzzz send immedaily.advance thanks

    TEST@test SQL> select trunc(sysdate,'MON') from dual;
    TRUNC(SYS
    01-OCT-06
    TEST@test SQL>                                  

  • Apple Mail - how to get the first word in a sentence to auto-capitalize

    How to get the first word in a sentence to auto-capitalize
    Anwar

    something to look forward to then, because we get used not to use our shift button any more, since iPhone and iPad do it for us. entourage and other ms stuff do it. pages does it too now (put it on in the auto-correct in preferences). bizarre however some loose the capitalization when you copy the text. pages to stickies or mail does not. that's good !

  • How to get the first 4 chars form a var ?

    Hi guys,
    How to get the first 4 chars form a var ?
    i.e  temp type num20 value '00000000000012345678'.
    how to move the first 4 chars to another var?
    thx in advance.

    hi
    use OFFESTS..
    example:
    var1 = '12345678'.
    var2 = var1+0(4).
    now var2 conatins '1234'.
    thx
    pavan

  • How to capitalize the first letter of each  word in a sentence?

    Can anyone please explain how to split a sentence at a comma, or space or hyphen in to words and capitalize the first letter of each word. But I don't know how many words the sentence contains.

    HI,
    data : begin of itab occurs 0,
             words(40),
             end of itab.
    data : v_sentence(1000).
    data : lv_firstchar.
    split v_sentence at ',' into table itab.
    loop at itab.
    translate itab-words+0(1) to upper case.
    modify itab index sy-tabix.
    endloop.

  • How to Capitalize the first letter in a text field?

    I have a text field of first_name and one of last_name.  I want to make sure not matter what format the user inputs the the first letter is Capitalized and the rest is lower case.  Can someone tell me how this is done?  Thanks!

    Rick4209 wrote:
    I have a text field of first_name and one of last_name.  I want to make sure not matter what format the user inputs the the first letter is Capitalized and the rest is lower case.  Can someone tell me how this is done?  Thanks!
    It depends on what you want to do with the name. If this is for inserting the name in a database and you're using PHP, it's very simple:
    $name = 'DaVID';
    $formatted = ucfirst(strtolower($name));
    echo $formatted; // outputs 'David'
    This nests two functions: the inner function, strtolower(), converts everything to lowercase, and the outer function, ucfirst(), converts the first letter to uppercase.

  • How to get the first month of the year inputed by user manually

    Hi Expert,
    Just like the subject, I 'd like to get the first month of the year inputed by user manually, but don't know how to set the variable, please help.
    For example, user execute a query and input the value of variable Year = 2010, and what I want to get is 201001 into another variable, so that I can use this variable to setup another selection.
    Thank you.
    Andy

    Hi Andy,
    1) U will create a user input varaible for year and say it is ZYEAR.
    2)  U will create another variable  for calmonth  which has processing type : customer exit ..single value ...mandatory ....say ZCMONTH.
    This needs to be populated using the year( user inputted )  and calmonth '001'
    This code will fetch the user input value into ZYEAR and append '001' to the user input value and the value
    will be passed to the ZCMONTH varaible...
    Sample Code is....
    When 'ZCMONTH'.
    IF I_STEP = 2.
         READ TABLE I_T_VAR_RANGE WITH KEY VNAM = 'ZYEAR'.
         IF SY_SUBRC = 0.
                    L_S_RANGE-LOW  =  I_T_VAR_RANGE-LOW.
                   L_S_RANGE-LOW+4(3) = '001'.
                  L_S_RANGE-SIGN = 'I'.
                 L_S_RANGE-OPT  = 'EQ'.
                      APPEND L_S_RANGE TO E_T_RANGE.
        ENDIF.
    ENDIF.
    Regards
    vamsi

  • How to get the first friday of the MARCH and SEPTEMBER month of any year...

    Hello-
    How can we get the first FRIDAY of MARCH and SEPTEMBER month for any given year.
    Any help would be appreciate!
    Thanks,
    Nikhil

    Hi,
    Please use the following function to get first fiday of any month, we have to pass month,year as varchar2 as input to this function and it will return the
    date in char format, we can convert it to date.
    CREATE OR REPLACE FUNCTION find_fri
    (p_month VARCHAR2,
    p_year VARCHAR2)
    RETURN VARCHAR2 AS
    p_friday VARCHAR2(15);
    BEGIN
    SELECT (CASE triM(TO_CHAR(TO_DATE(p_month||'-'||p_year,'mm-yyyy'),'DAY')) WHEN 'MONDAY' THEN TO_CHAR(TO_DATE(p_month||'-'||p_year,'mm-yyyy')+4 ,'DD-MM-RRRR')
    WHEN 'TUESDAY' THEN TO_CHAR(TO_DATE(p_month||'-'||p_year,'mm-yyyy')+3 ,'DD-MM-RRRR')
    WHEN 'WEDNESDAY' THEN TO_CHAR(TO_DATE(p_month||'-'||p_year,'mm-yyyy')+2 ,'DD-MM-RRRR')
    WHEN 'THURSDAY' THEN TO_CHAR(TO_DATE(p_month||'-'||p_year,'mm-yyyy')+1 ,'DD-MM-RRRR')
                                                                          WHEN 'FRIDAY' THEN TO_CHAR(TO_DATE(p_month||'-'||p_year,'mm-yyyy'),'DD-MM-RRRR')
                                                                          WHEN 'SATURDAY' THEN TO_CHAR(TO_DATE(p_month||'-'||p_year,'mm-yyyy')+6,'DD-MM-RRRR')
    WHEN 'SUNDAY' THEN TO_CHAR(TO_DATE(p_month||'-'||p_year,'mm-yyyy')+5 ,'DD-MM-RRRR')
                                                                          ELSE 'OTHER'
                                                                          END) INTO p_friday FROM dual;
    RETURN p_friday;
    END;

  • How to get the first and the last record of every month within a time range in sql

    I am trying to get the first record and the last record of each and every month in a given date range using sql. I have a sample code
    where i have just selected everything within the date range now i have to extract the first and the last records of each and every month.
    SELECT PurOrderNum,
    OrderDate
    FROM Purchasing.PurOrder
    WHERE OrderDate >= '2013-02-28'
    AND OrderDate <= '2014-12-29'

    SELECT PurOrderNum,
    OrderDate
    FROM
    SELECT PurOrderNum,
    OrderDate,
    MAX(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MaxDate,
    MIN(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MinDate
    FROM Purchasing.PurOrder
    WHERE OrderDate >= '2013-02-28'
    AND OrderDate <= '2014-12-29'
    )t
    WHERE OrderDate = MaxDate
    OR OrderDate = MinDate
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to Capitalize the First Letter in Every Word in Mysql

    Hi,
    I have been trying to tidy up a massive database where visitors have been sloppy when entering text. The main thing I want to do is to Capitalize The First Letter In Every Word In Mysql.
    I have found the code below in PHP but it keeps finding an error on the WHILE line:
    <?php ini_set('display_errors', '1'); ?>
    <?php require_once('Connections/maison_connection.php'); ?>
    <?php
    $result = mysql_query ("SELECT column, id FROM table");
    while ($row = mysql_fetch_array($result)) {
    $id = $row["id"];
    $column2 = ucwords($row["column"]);
    $query2 = "UPDATE table SET column = '$column2′ WHERE id = '$id'";
    mysql_query($query2);
    ?>
    My table is called MailingList and the Column is called Name, so I have altered the script to this: but it still shows the same WHILE error:
    <?php ini_set('display_errors', '1'); ?>
    <?php require_once('Connections/maison_connection.php'); ?>
    <?php
    $result = mysql_query ("SELECT Name, id FROM MailingList");
    while ($row = mysql_fetch_array($result)) {
    $id = $row["id"];
    $Name2 = ucwords($row["Name"]);
    $query2 = "UPDATE MailingList SET Name = '$Name2′ WHERE id = '$id'";
    mysql_query($query2);
    ?>
    Any ideas??

    I got it to work this way in SQL: I am SURE there is an abbreviated way to do it, but at least it works
    UPDATE MailingList SET Name = replace(Name," a"," A");
    UPDATE MailingList SET Name = replace(Name," b"," B");
    UPDATE MailingList SET Name = replace(Name," c"," C");
    UPDATE MailingList SET Name = replace(Name," d"," D");
    UPDATE MailingList SET Name = replace(Name," e"," E");
    UPDATE MailingList SET Name = replace(Name," f"," F");
    UPDATE MailingList SET Name = replace(Name," g"," G");
    UPDATE MailingList SET Name = replace(Name," h"," H");
    UPDATE MailingList SET Name = replace(Name," i"," I");
    UPDATE MailingList SET Name = replace(Name," j"," J");
    UPDATE MailingList SET Name = replace(Name," k"," K");
    UPDATE MailingList SET Name = replace(Name," l"," L");
    UPDATE MailingList SET Name = replace(Name," m"," M");
    UPDATE MailingList SET Name = replace(Name," n"," N");
    UPDATE MailingList SET Name = replace(Name," o"," O");
    UPDATE MailingList SET Name = replace(Name," p"," P");
    UPDATE MailingList SET Name = replace(Name," q"," Q");
    UPDATE MailingList SET Name = replace(Name," r"," R");
    UPDATE MailingList SET Name = replace(Name," s"," S");
    UPDATE MailingList SET Name = replace(Name," t"," T");
    UPDATE MailingList SET Name = replace(Name," u"," U");
    UPDATE MailingList SET Name = replace(Name," v"," V");
    UPDATE MailingList SET Name = replace(Name," w"," W");
    UPDATE MailingList SET Name = replace(Name," x"," X");
    UPDATE MailingList SET Name = replace(Name," y"," Y");
    UPDATE MailingList SET Name = replace(Name," z"," Z");

  • How to get the first day of current month

    hi guys,
    i am trying to get the first day of current month which get from the date i input at the selection screen. my method is not so good, so i was wondering if there is better way to get the this,
    thanks.

    Try this .
    data : DAYNR LIKE  HRVSCHED-DAYNR,
         DAYTXT LIKE  HRVSCHED-DAYTXT.
    data langu like sy-langu value 'EN'.
    Parameters PDATE LIKE SY-DATUM.
    PDATE+6(02) = '01'.
    CALL FUNCTION 'RH_GET_DATE_DAYNAME'
      EXPORTING
        LANGU                     = LANGU
        DATE                      = PDATE
      CALID                     =
    IMPORTING
       DAYNR                     = DAYNR
       DAYTXT                    = DAYTXT
      DAYFREE                   =
    EXCEPTIONS
      NO_LANGU                  = 1
      NO_DATE                   = 2
      NO_DAYTXT_FOR_LANGU       = 3
      INVALID_DATE              = 4
      OTHERS                    = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    WRITE :/ PDATE, DAYNR, DAYTXT.
    Cheers

Maybe you are looking for