Oracle workaround to the STUFF() MSSQL Function?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff Lambert

    #1

    Oracle workaround to the STUFF() MSSQL Function?

    I have this function everywhere in our SQL server 2000 stored
    procedures. Has anyone written a workaround function for it? I would
    appreciate if you could share. As you can imagine, searching the
    groups for "stuff" returns a lot of, well... stuff. But not what I'm
    looking for!


    Using STUFF
    The STUFF function inserts a string into another string. It deletes a
    specified length of characters in the first string at the start
    position and then inserts the second string into the first string at
    the start position.

    If the start position or the length is negative, or if the starting
    position is larger than length of the first string, a null string is
    returned. If the length to delete is longer than the first string, it
    is deleted to the first character in the first string.

    This example puts in the character string of "xyz" starting at the
    second character of the "abc" character expression, and replaces a
    total of three characters.

    SELECT STUFF('abc', 2, 3, 'xyz')



    Here is the result set:

    ----

    axyz



    (1 row(s) affected)
  • al0

    #2
    Re: Oracle workaround to the STUFF() MSSQL Function?

    jeffl@hypershel l.com (Jeff Lambert) wrote in message news:<f17e7766. 0312191531.3d37 02d0@posting.go ogle.com>...
    I have this function everywhere in our SQL server 2000 stored
    procedures. Has anyone written a workaround function for it? I would
    appreciate if you could share. As you can imagine, searching the
    groups for "stuff" returns a lot of, well... stuff. But not what I'm
    looking for!
    There is no direct counterpart to this function in Oracle, you have
    write instead (if you want to replace in FirstStr m characters
    sstarting from n-tn character)

    substr(FirstStr ,1,n-1)||SecondStr|| Substr(FirstStr ,n+m)

    Take a look on Replace function as well, as it may be handy. It
    provides "context" replacement. Here is excerpt from documentation:

    REPLACE returns char with every occurrence of search_string replaced
    with replacement_str ing. If replacement_str ing is omitted or null,
    then all occurrences of search_string are removed. If search_string is
    null, then char is returned.

    The following example replaces occurrences of "J" with "BL":

    SELECT REPLACE('JACK and JUE','J','BL') "Changes"
    FROM DUAL;

    Changes
    --------------
    BLACK and BLUE

    Comment

    • Jeff Lambert

      #3
      Re: Oracle workaround to the STUFF() MSSQL Function?

      Thank you very much...

      Oleksandr_Alesi nskyy@rambler.r u (al0) wrote in message news:<42a985d2. 0312211312.41f1 8f79@posting.go ogle.com>...
      jeffl@hypershel l.com (Jeff Lambert) wrote in message news:<f17e7766. 0312191531.3d37 02d0@posting.go ogle.com>...
      I have this function everywhere in our SQL server 2000 stored
      procedures. Has anyone written a workaround function for it? I would
      appreciate if you could share. As you can imagine, searching the
      groups for "stuff" returns a lot of, well... stuff. But not what I'm
      looking for!
      >
      There is no direct counterpart to this function in Oracle, you have
      write instead (if you want to replace in FirstStr m characters
      sstarting from n-tn character)
      >
      substr(FirstStr ,1,n-1)||SecondStr|| Substr(FirstStr ,n+m)
      >
      Take a look on Replace function as well, as it may be handy. It
      provides "context" replacement. Here is excerpt from documentation:
      >
      REPLACE returns char with every occurrence of search_string replaced
      with replacement_str ing. If replacement_str ing is omitted or null,
      then all occurrences of search_string are removed. If search_string is
      null, then char is returned.
      >
      The following example replaces occurrences of "J" with "BL":
      >
      SELECT REPLACE('JACK and JUE','J','BL') "Changes"
      FROM DUAL;
      >
      Changes
      --------------
      BLACK and BLUE

      Comment

      Working...