Alternate without using regexp_replace function

SELECT
  REGEXP_REPLACE(phone_number,
                 '([[:digit:]]{3})\.([[:digit:]]{3})\.([[:digit:]]{4})',
                 '(\1) \2-\3') "REGEXP_REPLACE"
                 FROM employees;
is there any alternate without using regexp_replace function.........

Another way
(eliminating instr function.. as your problem focusses on a fixed length)
WITH t AS (SELECT '112.345.6789' str FROM DUAL),
     tt AS (SELECT REPLACE (str, '.') str FROM t)
SELECT    '('
       || SUBSTR (str, 1, 3)
       || ') '
       || SUBSTR (str, 4, 3)
       || '-'
       || SUBSTR (str, 7)
  FROM tt;
Cheers,
Manik.

Similar Messages

  • I want single update query without use the function.

    I want to update sells_table selling_code field with max date product_code from product table.
    In product table there is multiple product_code date wise.
    I have been done it with below quey with the use of function but can we do it in only one update query
    without use the function.
    UPDATE sells_table
    SET selling_code = MAXDATEPRODUCT(ctd_vpk_product_code)
    WHERE NVL(update_product_flag,0) = 0 ;
    CREATE OR REPLACE FUNCTION HVL.maxdateproduct (p_product IN VARCHAR2) RETURN NUMBER
    IS
    max_date_product VARCHAR2 (100);
    BEGIN
    BEGIN
    SELECT NVL (TRIM (product_code), 0)
    INTO max_date_product
    FROM (SELECT product_code, xref_end_dt
    FROM product
    WHERE TO_NUMBER (p_product) = pr.item_id
    ORDER BY xref_end_dt DESC)
    WHERE ROWNUM = 1; -- It will return only one row - max date product code
    EXCEPTION
    WHEN OTHERS
    THEN
    RETURN 0;
    END;
    RETURN max_date_product;
    END maxdateproduct;
    Thanks in Advance.

    Hi,
    Something like this.
    update setlls_table st
            set selling_code =(select nvl(trim(product_code)) from 
                                  (select product_code
                                          , rank() over (partition by item_id order by xref_end_dt DESC) rn
                                       from product
                                   ) pr
                                   where rn =1
                                         and pr.item_id = st.ctd_vpk_product_code
                               ) where NVL(update_product_flag,0) = 0 ;As such not tested due to lack of input sample.
    Regards
    Anurag Tibrewal.

  • Max value without using max() function

    Hi
    Is there any way to get the max value from a table without using MAX() function
    Thanks

    well if you think about it i'm sure you'll find a solution
    what does max(field) means, it simply is the value of the field where no other value of the same field that is > than this value exists.
    consider the following :
    table TAB(
    fld NUMBER(5));
    translate the logic and you'll have
    select a.fld from TAB a where NOT EXISTS(select b.fld from TAB b where b.fld>a.fld) and rownum=1;
    of course there are better ways i'm sure, you'll just have to figure'em out.

  • Need to take rownum highest value without using grouping functions

    Hi
    I want to display highest value in the rownum column and customer details without using grouping functions like max or count
    this below query gives me all rownum values and customer details
    SELECT ROWNUM ROWNUM_1, CUSTOMER_NO, CUSTOMER_NAME, CUSTOMER_DOJ, CUSTOMER_MOBILENO FROM CUSTOMER;
    can any one help me.

    The above query won't work as it's missing "from" cluase in the inner select statement.
    And even if corrected it willl print rownum values thrice: value "1",max_rownum, max_rownum followed by customer details.
    Below is the simple query to retrieve max row_num along with the corresponding customer details.
    select * from (SELECT ROWNUM ROWNUM_1, CUSTOMER_NO, CUSTOMER_NAME, CUSTOMER_DOJ, CUSTOMER_MOBILENO FROM CUSTOMER order by rownum_1 desc) where rownum<=1 ;

  • Print a DayName without using Date functions

    Hi,
    I have an assignment like without using any date functions i should print a calendar.
    Below is the code without using any datefunctions like dateadd, datediff, datename a calendar has been generated for month and year entered. I want a week name for the dates like sunday ... monday etc. 
    I can take any date from calendar as reference  and calculate based on that date.
    ex: today is 2/20/2014 thursday . Next 7days again will be thursday, same way before 7days will be thursday.
    I need to loop in below procedure and get weekname. 
    Plz help in the code,
    I am using SQL server 2008
    IF OBJECT_ID ('dbo.Calendar1') IS NOT NULL
         DROP PROCEDURE dbo.Calendar1
    GO
    CREATE  PROCEDURE [dbo].Calendar1 --4,1991
       @month int,
       @Year  int
     AS  
     BEGIN
     declare 
     @startdateofMonthYear date,
     @EnddateofMonthYear Date
    Set @startdateofMonthYear=(Select cast(@Year as varchar(4)) +'-'+Right('00'+Cast(@month as varchar(2)),2) +'-'+'01')
    Set @EnddateofMonthYear = (SELECT case when @month IN (1,3,5,7,8,10,12) then cast(@Year as varchar(4)) +'-'+Right('00'+Cast(@month as varchar(2)),2) +'-'+'31'
    when @month IN(4,6,9,11) then cast(@Year as varchar(4)) +'-'+Right('00'+Cast(@month as varchar(2)),2) +'-'+'30'
    else  cast(@Year as varchar(4)) +'-'+Right('00'+Cast(@month as varchar(2)),2) +'-'+(CASE WHEN (@YEAR % 4 = 0 AND @YEAR % 100 <> 0) OR @YEAR % 400 = 0 THEN '29' else '28' End) 
    End) 
    ;WITH CTE_DatesTable
    AS
    Select 1 daysint, Cast(SUBSTRING(cast(@startdateofMonthYear as varchar(20)),1,7) + '-'+CAST(1 as varchar(2)) as DATE) Calendardates
    UNION ALL
    SELECT   daysint+1,Cast(SUBSTRING(cast(@startdateofMonthYear as varchar(20)),1,7) + '-'+CAST(daysint+1 as varchar(2)) as DATE) Calendardates
    FROM CTE_DatesTable
    WHERE  daysint<= 
    (SELECT case when @month IN (1,3,5,7,8,10,12) then 31
    when @month IN(4,6,9,11) then 30
    else  (CASE WHEN (@YEAR % 4 = 0 AND @YEAR % 100 <> 0) OR @YEAR % 400 = 0 THEN 29 else 28 End) 
    End)-1
    Select 
    [DWDateKey]=Calendardates,
    [DayDate]=daysint,
    [MonthNumber]=@Month,
    [MonthName]=Case when @month = 1 then 'January'
     when @month  = 2 then 'February'
     when @month  = 3 then 'March'
     when @month  = 4 then 'April'
     when @month  = 5 then 'May'
     when @month  = 6 then 'June'
     when @month  = 7 then 'July'
     when @month  = 8 then 'August'
     when @month  = 9 then 'September'
     when @month  = 10 then 'October'
     when @month  = 11 then 'November'
     when @month  = 12 then 'December' 
    End,
    [Year]=@Year
    From CTE_DatesTable
    END
    bhavana

    In the above code, where do i pass the year and month?
    (Select 2000 YearID
    Union All
    Select YearID +1 From cte where YearID <2100
     In above condition from 2000 year its displaying.
    If i want in 90's year , Day name will not be correct.
    Deepa

  • Count the no.of rows without using count function

    Hi,
    How to count the no.of rows without using the count function?
    Thanks,

    they won't be 100% accurate. You're correct, Bluefrog, but the same goes for doing a count(*) (depending on the size of the table, ofcourse):
    the table being queried might be under DML (deletes/inserts), and the next count(*) might give different results.
    Both approaches will never be 100% accurate.
    But simply selecting num_rows will be much much faster than doing a count(*).
    Counting the number of rows always reminds me of this ongoing discussion, by the way:
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:127412348064#14136093079164 ;)
    Usually knowing the number of records by approximatly is sufficient, imo. 1000000 or 1000007 records: I don't care, don't need to know that.
    I've never needed to know the exact number of records in a table in my code, or been given a requirement that forced me to.

  • Can I rewrite the following query without using Row_number() function ??!!

    Hello every one, can I rewrite the following query without using the 'ROW_NUMBER() OVER ' part.
    The query is supposed to pull out the records whose CODE is not NULL and has most
    recent date for UPDATE_DATE . The reason I wanted to do this is, When I embed this query
    in between many other queries along with JOINs, My oracle server is unable to execute. So, I thought
    its better to supplant 'ROW_NUMBER() OVER ' logic with something else and try it. .
    SELECT a.* FROM
    (SELECT b.*, ROW_NUMBER() OVER (PARTITION BY b.PIDM
    ORDER BY b.UPDATE_DATE DESC) AS Rno
    FROM
    SELECT *
    FROM SHYNCRO WHERE CODE IS NOT NULL
    )b
    )a
    WHERE a.Rno = 1

    Hi,
    You didn't write over 150 lines of code and then start testing it, did you?
    Don't.
    Take baby steps. Write as little as pssiblem test that. Debug and test again until you have something that does exactly what you want it to do.
    When you have somehting that works perfectly, take one baby step. Add a tiny amount of code, maybe 1 or 2 lines more, and test again.
    When you do get an error, or wrong results, you'll have a much better idea of where the problem is. also, you won't be building code on a flimsy foundation.
    If you need help, post the last working version and the new version with the error. Explain what you're trying to do in the new version.
    The error message indicates line 133. It looks like line 133 of your code is blank. Does your front end allow completely blank lines in the middle of a query? SQL*Plus doesn't by default; you have to say
    SET  SQLBLANKLINES  ONto have a completely blank line in SQL*Plus. (However, lines containing nothing but at commnet are always allowed.)
    You may have noticed that this site normally doesn't display multiple spaces in a row.
    Whenever you post formatted text (such as indented code) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    The 4 people who posted small code fragments for you to read all did this.  It would be so much easier for people to read your humongeous query if it were formatted.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Using ip-helper without using DHCP functionality

    Hello,
    I am fairly new to Cisco, and am after a bit of help.
    My scenario:
    We have a new domain setup on a new VLAN (3), seperate from our current infrastructure VLAN (2).
    The new domain controllers provide DHCP for our new servers, and I would also like them to handle DHCP for wireless clients.
    We have one DHCP scope 10.0.0.0 255.255.0.0, and I would like to assign all wireless clients an IP in the 10.0.6.0 range.
    My thinking on the best way to do this, is with a DHCP policy, that looks at the relay agent information.
    I would then set the ip-helper address, on the port the wireless access point is connected to on the Cisco, to point to the DHCP server.
    Then for that same port, I would seb a subscriber id in the relay agent information, and use this string to set the IP assigned to that device.
    Looking into doing this, it seems the Ciscos DHCP functionality has to be turned on in order to use ip-helper.
    In my config, I cannot tell if DHCP is enabled or not, I can see neither "service dhcp", nor "no service dhcp" in the config.
    Assuming I were to turn it on using "service dhcp", can I then leave the actual functionality turned off? i.e. turn on the DHCP service, but not have it assign IP addresses?
    Also, does turning it on cause any downtime or disruption?
    I think I have to run these commands:
    conf t
    service dhcp
    interface GigabitEthernet2/40
    Ip helper-address 10.0.0.1
    Ip dhcp relay information option-insert
    Ip dhcp relay information option subscriber-id “wireless”
    I know these are probably simple questions, so please forgive my ignorance.
    James

    Ok here goes.
    On my domain controller/DHCP server, I have a scope setup of 10.0.0.0 255.255.0.0, and is set with an IP range of 10.0.0.1 - 10.0.6.253
    I have various reservations in place, and a working policy to assign thin clients an IP of 10.0.2.X based on their MAC address.
    I have then created a second policy, that should be assigning IPs in the 10.0.6.0 range, based on relay agent information, subscriber ID. This is a HEX value, so whatever string I enter on the Cisco, has to be converted to HEX.
    This DHCP server is on the same VLAN 3. The VLAN interface on the Cisco has IP of 10.0.0.254 255.255.0.0
    The wireless clients are getting IP addresses, but not within the range specified by the policy, so they are getting any address between 10.0.0.1 and 10.0.6.253 that is not already in use.
    Image 1 shows the vlan interface, where I have set the helper address, relay information option-insert, and subscriber id of "wireless".
    Image 2 shows the config on the port that my access point is connected to.
    Image 3 shows the value of the policy on the DHCP server, based on subscriber ID
    Image 4 shows the string "wireless" converted to HEX
    Image 5 shows the IP range that the policy should be using
    Image 6 shows "Edss-iPhone" as have an IP not within the correct range
    Hopefully that helps.

  • How to check for locks on a material - without using Enqueue function

    Hi
        We have a requirement in which - we need to check the lock ( exclusive ) on a material before we call the BAPI to update the material.
    I don't want to actually lock the material before calling the BAPI - the BAPI itself acquires the lock as a part of its processing. All I want to do is to check whether lock on a material exists before calling the BAPI - thus avoiding any lock related issues on the material in the BAPI call.
    How do we just merely check whether material is locked - any standard function module /SAP tables where in material lock is stored that we use/interrogate ?
    Correct answers will be promptly rewarded.

    Hi ,
          There is standard function enqueue_read ,based on material number .
    Pass the material number to FM ENQUEUE_READ if sy-subrc = 0 then material is locked otherwise not .
    Please reward if useful.

  • Help in using  regexp_replace function.

    Hi everyone,
    i have a string something like this..
    varchar2(100) := 'SUBF1.AAAAAAAAAAAAA.SUBF1.BBBBBBBBBB.SUBF1'
    i want to replace the FIRST OCCURANCE of SUBF1 with some other string.
    EX:
    For the above string if i replace the FIRST OCCURANCE of SUBF1 with 'Hi' the output gonna be like this
    OUTPUT : 'Hi.AAAAAAAAAAAAA.SUBF1.BBBBBBBBBB.SUBF1'
    Sorry if this question had asked previously in this FORUM.
    Thanks in advance..
    phani

    test@ora>
    test@ora>
    test@ora> --
    test@ora> with t as (
      2    select 'SUBF1.AAAAAAAAAAAAA.SUBF1.BBBBBBBBBB.SUBF1' as x from dual)
      3  --
      4  select x,
      5         regexp_replace(x,'SUBF1','Hi',1,1) as modx
      6  from t;
    X                                          MODX
    SUBF1.AAAAAAAAAAAAA.SUBF1.BBBBBBBBBB.SUBF1 Hi.AAAAAAAAAAAAA.SUBF1.BBBBBBBBBB.SUBF1
    1 row selected.
    test@ora>
    test@ora>isotope

  • How do I import Firefox user settings from old computer to new computer without using sync function?

    the motherboard on my old Mac G4 powerbook died but i have access to its hard drive contents, including the files located in Application Support>Firefox. I want to import these profile settings into my new Firefox on my new iMac 2011. Which files do I move over so that my new Firefox has the settings/bookmarks/add-ons as my old Firefox?

    Install FEBE from Add Ons in FF on old computer. Back up entire profile. Also install FEBE in FF on new computer. Copy FEBE backup folder to new computer. "Restore" from FEBE. All of your settings, including cookies, passwords, etc. will be "restored." Note that on the new computer, you'll need to create two profiles: the default one you'll use on a regular basis and one to use for the restore.

  • How to translate translate 'i' to 'İ' without using translate function?

    My database is "Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit".
    is there any other solution than this one;
    create or replace function tr_upper(str varchar2) return varchar2 is
    begin
    return upper(translate(str,'i','&#304;')) ;
    end;
    select tr_upper('izmir') from dual;
    my NLS_SESSION_PARAMETERS are;
    PARAMETER VALUE
    NLS_LANGUAGE TURKISH
    NLS_TERRITORY TURKEY
    NLS_CURRENCY TL
    NLS_ISO_CURRENCY TURKEY
    NLS_NUMERIC_CHARACTERS ,.
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD/MM/RRRR
    NLS_DATE_LANGUAGE TURKISH
    NLS_SORT TURKISH
    NLS_TIME_FORMAT HH24:MI:SSXFF
    NLS_TIMESTAMP_FORMAT DD/MM/RRRR HH24:MI:SSXFF
    NLS_TIME_TZ_FORMAT HH24:MI:SSXFF TZR
    NLS_TIMESTAMP_TZ_FORMAT DD/MM/RRRR HH24:MI:SSXFF TZR
    NLS_DUAL_CURRENCY YTL
    NLS_COMP BINARY
    NLS_LENGTH_SEMANTICS BYTE
    NLS_NCHAR_CONV_EXCP FALSE
    17 rows selected
    here is the output for the upper/lower functions;
    SELECT upper('i'),
    lower('&#304;'),
    upper(lower('&#304;')),
    lower(upper('i')),
    upper('&#305;'),
    lower('I'),
    upper(lower('I')),
    lower(upper('&#305;'))
    FROM dual ;
    UPPER('I') LOWER('&#304;') UPPER(LOWER('&#304;')) LOWER(UPPER('I')) UPPER('I') LOWER('I') UPPER(LOWER('I')) LOWER(UPPER('I'))
    I i I i I i I i
    Thank you,
    Kind regards.
    Tonguç

    maybe
    select nls_upper('i','NLS_SORT=turkish') from dual;      or
    select nls_upper('i','NLS_SORT=xturkish') from dual;but I am not sure and do not have the right characterset to test

  • WITHOUT USING ROW_NUMBER FUNCTIONS IN T-SQL

    INPUT:-
    CUST_ID
    GIFT_ID
    100
    10
    100
    20
    100
    30
    200
    10
    200
    20
    200
    30
    300
    20
    OUTPUT:-
    CUST_ID
    GIFT_ID
    SEQ
    100
    10
    1
    100
    20
    2
    100
    30
    3
    200
    10
    1
    200
    20
    2
    200
    30
    3
    300
    20
    1
    santoshbangalore

    THANK YOU SO MUCH FOR YOUR ANS? BUT MY INPUT TABLE A CONTAIN ONLY TWO COLUMN'S 
    CUST_ID,GIFT_ID
    AND IN OUT PUT I NEED THE ABOVE OUTPUT WITH 
    CUST_ID,GIFT_ID,ROW_NUMBER AS SHOWN ABOVE?
    santoshbangalore

  • Manually config printer to print to printer from anywhere without using email function

    I have a LaserJet Pro CM1415fnw color MFP. I want to config my lap top that has windows 7 to print through the internet directly to my printer. I had an HP printer before that allowed me to do that. On this printer I cannot find a IP address. I don't like the email attachment option. I need to be abale to print just one page instead of the entire document and so forth.
    Thanks

    Hello @jrjvcj,
    Welcome to the HP Forums!
    I understand you would like to setup this Laserjet CM1415fnw. I will do my best to assist you! If cannot find the IP address on your printer, then please follow this HP document on The Printer is Not Found During Network Installation.
    If you were referring to ePrint in your post from your previous printer, then this printer doesn't support ePrint. I will provide the manual for your printer here.
    Please post your results, as I will be looking forward to hearing from you. Have a great night!
    I worked on behalf of HP.

  • I can't print without using the function print as image since i updated my adobe to the latest version online, will this continue is there any solution please help

    It is a real headache , i can't print any file , i see the message no pages selected to print , i have the latest version of adobe 11 thanks

    Hi Tamer,
    Please try repairing Acrobat from the 'Help' menu and check.
    Regards,
    Rave

Maybe you are looking for

  • Null Values from a Data Source

    This is more of an implementation question than a troubleshooting question. Also, since I've been unable to find any documentation on this I was wondering if anyone has come across this behavior or found a bug with it. Yesterday I was working on an a

  • Multiple iTunes Accounts on One Mac

    For years my kids have shared our family iTunes account.  However, they are getting to the point where I want to give them their own iTunes gift cards as presents for purchases, as well as giving my wife her own card to purchase items.  If I buy one

  • Changes made in BOM are not reflected in Configurator.

    Hi all, When i update minimum and maximum quantities in BOM, the new values are not reflected in the configurator. I have found a patch (patch# 4410573) for this issue in metalink and applying that patch did not resolve the issue. I have logged an SR

  • My iphone 3gs crashes once or twice per week.

    as i mentioned, my phone comes dead every week, despite wiz full battery life or on charge, it crashes or when i woke up in the morning, i find it off. i have restore it once and updated the software to 3.0.1 but it is still crashing weekly. this is

  • ECC6.0 upgrade and BW steps for mapping the new ECC6.0 source system

    Hello gurus We are upgrading from R3 4.6C to ECC6.0. We use BW 7.0 SP 18. We will create the new ECC6.0 source system in BW, replicate metadata and everything. The question is how do we copy or reassign the existing objects pointing to our current 4.