replace only the last 3 characters within a string

Hi all
I have the string "abcdef_01". How can I replace the last 3 characters with "000"? in this string, for example "_01" should be replaced by '000'. Any way to do it, without the concatenation of the original string with the last 3 characters replaced by "000"?
Thank you

Edited by: Roger22 the 18.10.2011 09:29

Yes, you can...

SELECT rpad(substr('abcdef_01',1,length('abcdef_01')-3),length('abcdef_01'),chr(dbms_random.value(32,64))
                                                                         || chr(dbms_random.value(32,64))
                                                                         || chr(dbms_random.value(32,64)))
FROM dual;

RPAD/lpad may use a third parameter that is longer than 1 character and - if the duration of param 1 + length of parameter 3 is longer that parameter 2 - truncates the result to fit the length of parameter 2.

HTH

Tags: Database

Similar Questions

  • How to get the last 50 characters in a string

    Hi, I need to get 50 last characters in a piece of 25 characters each in two columns if the column notes less than 50 characters ex: 43 then I need to last 25 one column and left (18 characters) in the second column.     I tried using substr and the first column of length functions fine, but the second column has a problem: select substr ("ABCDEF GHIJ', length('ABCDEF GHIJ')-25, 25) of double; Thanks, Kiran

    Hello

    what I understand: if I call 'x' the length of the string:

    IF x > is 50 THEN result1 is 25 tanks, result2 = 25 characters

    IF 25< x=""><  50 ="" then="" result1="25" chars,="" result2="(" 25="" -="" x="" )="">

    IF x<= 25 ="" then="" result1="x" chars,="" result2="">

    Note that SUBSTR (x, n) selects the n last characters:

    SELECT SUBSTR ("ABCDEFGH",-3) FROM dual-> ANUS

    For example AS

    (SELECT "AAAAABBBBBCCCCCDDDDD" double str

    UNION ALL SELECT 'AAAAABBBBBCCCCCDDDDDEEEEEFFFFFGGGGG' FROM dual

    UNION ALL SELECT 'this_is_exactly_25__chars' FROM dual

    UNION ALL SELECT 'This___is___exactly___fifty___characters' FROM dual

    UNION ALL SELECT 'AAAAABBBBBCCCCCDDDDDEEEEEFFFFFGGGGGHHHHHIIIIIJJJJJKKKK' FROM dual

    )

    SELECT str

    LENGTH WHEN CARTER (str)<>

    THEN str

    WHEN LENGTH (str)<>

    THEN SUBSTR (str, 1, 25)

    Of OTHER SUBSTR (str, LENGTH (str) - 49: 25)

    END performance(1)

    , LENGTH WHEN CARTER (str) > = 50

    THEN SUBSTR (str,-25)

    WHEN LENGTH (str) > 25

    THEN SUBSTR (str, 25 - LENGTH (str))

    ANOTHER NULL

    End result2

    SAMPLE

    ;

    STR                                                    RESULT1                   RESULT2

    ------------------------------------------------------ ------------------------- -------------------------

    AAAAABBBBBCCCCCDDDDD AAAAABBBBBCCCCCDDDDD

    AAAAABBBBBCCCCCDDDDDEEEEEFFFFFGGGGG AAAAABBBBBCCCCCDDDDDEEEEE FFFFFGGGGG

    this_is_exactly_25__chars this_is_exactly_25__chars

    This___is___exactly___fifty___characters This___is___exactly_ ___fifty___characters

    AAAAABBBBBCCCCCDDDDDEEEEEFFFFFGGGGGHHHHHIIIIIJJJJJKKKK ABBBBBCCCCCDDDDDEEEEEFFFF FGGGGGHHHHHIIIIIJJJJJKKKK

    Best regards

    Bruno Vroman.

  • last 3 characters of a string

    How to get the last 3 characters of a string occuring after a character / alphabet  without using REGEXP_SUBSTR ? 
    
    Ex: 10000A001 is the string.
    
    Note: -  I want to use it in Oracle reports 6i, therefore i cannot use the statement REGEXP_SUBSTR 
    
    Sanjay

    Hello

    substr('10000A001',-3)
    
  • I can see only the last fax received in my PC and not all of them using an Officejet Pro 8600 Plus

    I create a file in my office where received faxes can be saved. Indeed, I can see the fax received, but if I get one more, it replaces the previous one. So, I see only the last received fax. How do I see all of them and does not replace another?

    The problem was that I didn't set the time on the machine of the printer.   I just put the date and time and the problem solved. I get faxes pdf correctly.  Be it, thanks for the help!

  • Will be able to choose only the last the last row in a window/desktop icon in Windows 7

    I use my laptop with Windows. Recently I could not open the icons/files you want in the Office of a window.

    I may be able to choose only the last the last row in a window/desktop icon in Windows 7.
    Although double-clicking on an icon only the last icon in the window opens. Pls help me...

    Hi Peter,.

    1 when was the last time that the desktop icons worked?

    2. you have any security program installed on the computer?

    3. don't you face any performance issues on the computer?

    4 did you a recent software or changes to the material on the computer?

    Method 1:

    I would say allowing you to run the FIXIT from the link provided and check.

    Difficulty of broken desktop shortcuts and common system maintenance tasks

    http://support.Microsoft.com/mats/system_maintenance_for_windows/en-us

    Method 2:

    If the problem persists, you can also run the Scanner security Microsoft and check all infections.

    http://www.Microsoft.com/security/scanner/en-us/default.aspx

    Note: there is a risk of data loss if all the files are infected and which can be removed in the cleaning process.

    Method 3:

    I also suggest to try to run the System File Checker scan on the computer. The scan will replace all the Windows files corrupted with new ones.

    Click on the link mentioned below for further guidance on the scanning of the file system Checker

    http://support.Microsoft.com/kb/929833

    Hope this helps and let us know if you need more assistance. We will be happy to help you.

  • Match the last 2 characters of field of 1 to 2 characters of another field

    Hi, I was looking for assistance with regard to get output when the last 2 characters of 1 on the ground of the last 2 characters of another field of a particular job, i.e. repair or the new job. Here's an example of my 2 tables and insert queries.

    [code]

    CREATE TABLE 'SITES '.

    (

    'CODE' VARCHAR2 (7 CHAR),

    VARCHAR2 (27 CHAR) "NAME."

    'SITE_NAME' VARCHAR2 (32 CHAR)

    )

    Insert in SITES (CODE, NAME, SITE_NAME) values ('CAFC', 'Central', 'Birmingham');

    Insert in SITES (CODE, NAME, SITE_NAME) values ('MRCE', 'Central','Manchester ");

    Insert in SITES (CODE, NAME, SITE_NAME) values ('LVCE', 'Central', 'Liverpool');

    Insert in SITES (CODE, NAME, SITE_NAME) values ("WSCE", 'Central',' West of Central Scotland ");

    CREATE TABLE 'JOBS '.

    (

    VARCHAR2 (20 BYTE) "JOB_REF."

    'JOB_TYPE' VARCHAR2 (20 BYTE)

    )

    Insert into JOBS (JOB_REF, JOB_TYPE) values ('FFR53CM', 'Repair');

    [/ code]

    So I would take the first 2 characters 'CM' of the Sites Table and at last the match 2 characters of the job Table if the Type of job is the repair and then display the value of the Site name. The reason why I need to filter on the Type of employment is because when a new job is connected so I need to use the first 2 characters rather than the last 2, but I thought I would break it down in order to get the work of part 1.

    Unfortunately I do not know how I can display it, also do not know whether to use a case statement, but still don't know how to write it.

    If someone could please advise, really appreciate it.

    Thanks in advance.

    976439 wrote:

    How I guarantee that it is only for the repair of Type of work?

    You know the SQL language don't you?

    What is the problem with everything by adding:

    where job_type = 'repair '.

    to the query.

    Blimey! I don't think I would be hand-holding today.

  • How to set up the multimedia keys (only the last 3 buttons)

    Hello

    How to set up the multimedia keys (only the last 3 buttons)? The first button works, you open the browser and the other open WMP.
    But the last 3 buttons (play/pause, Stop, forw/rewd) aren´t work with WMP. How can I fix?

    Thank you

    Hello

    Can you please tell us what model of laptop Satellite A do you have?

  • a table of images only the last image shows the index

    Hello world

    I try to index a table of images and all, but the last item gives me the error: "not an image."

    Here is a picture of the vi. The first loop load images and stores them in an indexed auto tunnel. Each diagnosis that I fell on this loop showed that all is well. The second loop must display the image stored in the tunnel sequence indexed auto, but it does not work. Instead, I got the error message that the 0 to n - 1 elements are not images, and only the last image is displayed.

    What I am doing wrong?

    Thanks for your help.

    and vi:

    Hello

    This VI has worked well for me with a contribution of 5 bmp files. You can check your input files?

  • v$ fixed_view_definition where and ' GV$ SESSION "= only the first 4000 characters

    Hi all

    I need to get the defeintion of the opinion GV$ SESSION.

    I get only the first 4000 characters.

    Select * from v$ fixed_view_definition where view_name = "GV$ SESSION;

    Could you please help me?

    Thank you

    Cherif.

    Cherif bh wrote:

    Hi Martin,

    Thanks for your help. I use 11.2.0.3 and is EXPAND_SQL_TEXT added 12 c.

    I try to get the definition of a problem of performance on gv$ session; I need a list of the tables and columns and add the best predicates and access them using indices

    You should be able to get the same thing on 11.2.0.3 too:

    https://jonathanlewis.WordPress.com/2012/07/10/expanding-SQL/

    The package is called DBMS_SQL2 it.

    Randolf

  • replace only the first and the second comma by TAB in the apex using using jquery

    All,

    I'm generating models of string in the text box in my apex as page == > 23232,445454, «454545,7878,988978, 3r3e»
    and I want to replace only the first and the second comma with TABS so I get like == > 23232 445454 «454545,7878,988978, 3r3e»

    It should run with the jquery code when I click my button?

    any help on this please?

    Thank you.

    How does this update function:

    function replaceUpToN(original, search, replaceWith, maxOccurence){
    
        var NEW_LINE = '\n';
    
        var lines = original.split(NEW_LINE);
    
        $.each(lines, function(index, value){
            var idx = 0;
            lines[index] = value.replace(search, function(match, pos, original){
                idx++;
                return idx <= maxOccurence ? replaceWith : match;
            });
    
        });
    
        return lines.join(NEW_LINE);
    
    }
    
  • How can I make a long list of search - replace only the master

    Hello world

    I had this script:

    //---------------------------------------------------------------------------------------- -------------------------------

    myDocuments var = app.documents.everyItem ();
    var myLayers = myDocuments.layers.everyItem ();

    Locked text on master blocks spreads are not affected.
    If you want to unblock, please add something like this:

    Unlock all elements of each document page on is spreading and Captain spreads (optional):
    myDocuments.pageItems.everyItem (.locked = false);

    var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem ().pageItems.everyItem ();

    Unlock the layers (optional)
    myLayers.locked = false;

    Lock all elements of page level first on normal spreads
    This leaves the elements on the page on unlocked master spreads:
    myPageItemsOnNormalSpreads.locked = true;

    Now for the GREP part:
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findGrepPreferences = changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "\\b20\\d+\\b";

    Research on "all open document" level
    Which returns an array of arrays:
    var myTarget = myDocuments.findGrep ();

    Flattening of myTarget Bay:
    var flattenedFoundArray = [];

    for (var n = 0; n < myTarget.length; n ++) {}
    flattenedFoundArray = flattenedFoundArray.concat (myTarget [n]);
    };

    Change the content of the texts found in flat table:
    for (var n = flattenedFoundArray.length - 1; n > = 0; n-) {}
    flattenedFoundArray [n] .silence = String (Number(flattenedFoundArray[n].contents) + 1);
    };

    Unlock all objects on normal spreads:
    myPageItemsOnNormalSpreads.locked = false;

    Reset search GREP and edit the prefs:
    app.findGrepPreferences = changeGrepPreferences = null;

    //---------------------------------------------------------------------------------------- -------------------------------

    made by Uwe

    I change in this, to make a multi elements of search - replace only the master

    //==============================================================================

    myDocuments var = app.documents.everyItem ();
    var myLayers = myDocuments.layers.everyItem ();

    Locked text spreads masters frameworks are not affected.
    If you want to unblock, please add something like this:

    Unlock all items page of each document of spreads and master spreads (optional):
    myDocuments.pageItems.everyItem (.locked = false);

    var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem ().pageItems.everyItem ();

    Unlock the layers (optional)
    myLayers.locked = false;

    Lock all elements of page level first on normal spreads
    This leaves the elements on the page on unlocked master spreads:
    myPageItemsOnNormalSpreads.locked = true;

    Now for the GREP part:
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findGrepPreferences = changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "USA";

    Research on "all open document" level
    Which returns an array of arrays:
    var myTarget = myDocuments.findGrep ();

    Flattening of myTarget Bay:
    var flattenedFoundArray = [];

    for (var n = 0; n < myTarget.length; n ++) {}
    flattenedFoundArray = flattenedFoundArray.concat (myTarget [n]);
    };

    Change the content of the texts found in flat table:
    for (var n = flattenedFoundArray.length - 1; n > = 0; n-) {}
    flattenedFoundArray [n] .silence = "CHINA";
    };

    Unlock all objects on normal spreads:
    myPageItemsOnNormalSpreads.locked = false;

    Reset search GREP and edit the prefs:
    app.findGrepPreferences = changeGrepPreferences = null;


    //---------------------------------------------------------------------------------------- -------------------------------

    myDocuments var = app.documents.everyItem ();
    var myLayers = myDocuments.layers.everyItem ();

    Locked text spreads masters frameworks are not affected.
    If you want to unblock, please add something like this:

    Unlock all items page of each document of spreads and master spreads (optional):
    myDocuments.pageItems.everyItem (.locked = false);

    var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem ().pageItems.everyItem ();

    Unlock the layers (optional)
    myLayers.locked = false;

    Lock all elements of page level first on normal spreads
    This leaves the elements on the page on unlocked master spreads:
    myPageItemsOnNormalSpreads.locked = true;

    Now for the GREP part:
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findGrepPreferences = changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = 'Washington DC';

    Research on "all open document" level
    Which returns an array of arrays:
    var myTarget = myDocuments.findGrep ();

    Flattening of myTarget Bay:
    var flattenedFoundArray = [];

    for (var n = 0; n < myTarget.length; n ++) {}
    flattenedFoundArray = flattenedFoundArray.concat (myTarget [n]);
    };

    Change the content of the texts found in flat table:
    for (var n = flattenedFoundArray.length - 1; n > = 0; n-) {}
    flattenedFoundArray [n] .silence = "Beijing."
    };

    Unlock all objects on normal spreads:
    myPageItemsOnNormalSpreads.locked = false;

    Reset search GREP and edit the prefs:
    app.findGrepPreferences = changeGrepPreferences = null;


    //===============================================================================

    only what I can do is to repeat and repeat again

    is this another perfect solution to do?

    Thank you

    Teetan

    Try this,

    findChange("USA", "CHINA");
    findChange("Washington DC", "Beijing");
    
    function findChange (findWhat, changeContent){
        var myDocuments = app.documents.everyItem();
        var myLayers = myDocuments.layers.everyItem();
        //Locked text frames on master spreads are not touched.
        //If you want to unlock them you have to add something like this:
        //Unlock ALL page items in every document on spreads and master spreads (optional):
        myDocuments.pageItems.everyItem().locked = false;
        var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem().pageItems.everyItem();
        //Unlock the layers (optional)
        myLayers.locked = false;
        //Lock all first level page items on normal spreads
        //That leaves the page items on master spreads unlocked:
        myPageItemsOnNormalSpreads.locked = true;
        //Now for the GREP part:
        app.findChangeGrepOptions.includeMasterPages = true;
        app.findGrepPreferences = changeGrepPreferences = null;
        if(findWhat)app.findGrepPreferences.findWhat = findWhat;
        //Do the search on "all open document" level
        //That will return an array of arrays:
        var myTarget = myDocuments.findGrep();
        //Flattening the myTarget array:
        var flattenedFoundArray = [];
        for(var n=0;n=0;n--){
            if(changeContent)flattenedFoundArray[n].contents = changeContent;
            };
        //Unlock all objects on normal spreads:
        myPageItemsOnNormalSpreads.locked = false;
        //Reset GREP find and change prefs:
        app.findGrepPreferences = changeGrepPreferences = null;
    }
    

    Vandy

  • Function call only the last Javascript API

    All,

    I have a function in my page header:

    function DisableANo() {}
    1
    $f_DisableOnValue ('P20_B', 'AAAA', 'P20_A');

    2
    $f_DisableOnValue ('P20_B', 'BBBB', 'P20_A');

    3
    $f_DisableOnValue ('P20_B', 'CCCC', 'P20_A');

    }

    I call this function onChange event of the B element.
    When I do this, only the last API //3 is called. If I delete //3 and have only //1 and / / 2, then I get //2 to work and if I remove //2 and I only / / 1, then I can get //1 to work.

    Can you please tell me where I'm wrong?

    Thank you!

    Spriya wrote:
    Hello

    I am trying to disable the P20_A element if the value of the P20_B element is "YYYY" or "BBBB" and "CCCC".

    Review of documentation:
    >
    $f_DisableOnValue (pThis, pValue, pThat)

    Checks the value (pValue) of an element (pThis). If it matches, this feature disables the element or the array of items (pThat). If it does not match, the item is enabled.
    >
    In this code (and code should always be validated using ------)

    ...\
    

    Tags :)

    function DisableANo(){
    //1
    $f_DisableOnValue('P20_B','AAAA','P20_A');
    
    //2
    $f_DisableOnValue('P20_B','BBBB','P20_A');
    
    //3
    $f_DisableOnValue('P20_B','CCCC','P20_A');
    
    }
    

    If P20_B is "YYYY" //1 will disable P20_A, then because P20_B is "YYYY", //2 will allow to P20_A because P20_B! = "BBBB"etc etc...

    Try $x_disableItem:

    $x_disableItem('P20_A', (($v('P20_B') === 'AAAA') || ($v('P20_B') === 'BBBB') || ($v('P20_B') === 'CCCC')))
    
  • How can I get the last 3 characters of the record

    Hello

    This statement [cdoe] select substr (password, 1, 3) to admin; Gets first 3 characters that I want to read the last 3 characters

    Best regards
    SQL> select substr('Raakh',-3) from dual;
    
    SUB
    ---
    akh
    
    1 row selected.
    

    Kind regards
    Rob.

  • Only the first 70 characters of an output string

    Hey this is probably an easy question for anyone to answer. I googled and could not find anything. I'm a value in a table, it's more than 70 characters long, but when I use DBMS_OUTPUT. Put_line I want only the first 70 characters of output. How can I do this?

    Thank you!

    SUBSTR

  • How to extract the last 5 characters of the column CLOB001?

    Hi all

    I've set up an external WS in the APEX and now I want to create a report with the following query:

    Select dbms_lob. Substr (CLOB001, 5, -5) 'Test '.

    of APEX_collections

    where collection_name = "P422_CHECKVAT_RESULTS";

    What I want to do is to retrireve the last 5 characters in the CLOB, has anyone any ideea how I can do this?

    Kind regards
    Ana-Maria
    SELECT dbms_lob.Substr(CLOB001,dbms_lob.getlength(CLOB001),dbms_lob.getlength(CLOB001)-5 ) test
      FROM HTMLDB_COLLECTIONS
     WHERE COLLECTION_NAME = 
    {code}
    
    Hope this helps...
    
    Tyson                                                                                                                                                                                                                                                                                                                                                                                                                            
    

Maybe you are looking for

  • 10 IOS connects with iTunes on Mac

    Hello After having updated my iPhone 6 to IOS10, do not access with iTunes (12.2.2.25) on MacBook (iTunes is not identify iPhone). Franco.

  • Satellite C850-B559: win 8 for Win 7 downgrade KMS server activation has failed

    Hello I have toshiba Satellite C850-B559 windows operating system 8I try to downgrade to Windows 8 for 64-bit Windows 7 Enterprize.It works well but faild KMS server activation! can you help me find the problem?

  • size of the hard drive

  • HOW TO SEE A CUT IN HALF IN 2 IMAGE

    THIS VI IS SUPPOSED TO HAVE A VIDEO INPUT, THEN CONVERT IT TO A TABLE TO, AND THEN DIVIDED THIS IMAGE IN 2. THE FIRST HALF IS SUPPOSED TO SHOW THE SIDE RIGHT AND THE OTHER HALF LEFT OF THE VIDEO. HOWEVER, I HAVE A PROBLEM OF DISPLAY OF BOTH AT THE SA

  • Use Direct wireless

    I can't understand the use and intention live wireless. I have the name of my HP7520 and in the manual it says to "seek and connect" on behalf of live wireless. How one search, and from a Smartphone, connect you to the printer? What tool or applicati