Unix Technical Forum

Re: STUFF command

This is a discussion on Re: STUFF command within the Oracle Database forums, part of the Database Server Software category; --> Lookup the REPLACE function in the Oracle docs. I believe this will do what you want. (Btw, STUFF in ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-23-2008, 08:31 AM
Dave Sisk
 
Posts: n/a
Default Re: STUFF command

Lookup the REPLACE function in the Oracle docs. I believe this will do what
you want. (Btw, STUFF in SQLServer is a function also...:-)

HTH,
Dave

<grille11@yahoo.com> wrote in message
news:c4e6ad$k1n$1@reader1.imaginet.fr...
> Hello,
>
> I am trying to find the equivalent of the STUFF command from SQL (deletes

a
> specified length of characters and inserts another set of characters at a
> specified starting point).
> Would someone knows this?
> thanks in advance
>
>
> This example returns a character string created by deleting three

characters
> from the first string (abcdef) starting at position 2 (at b) and inserting
> the second string at the deletion point.
>
> SELECT STUFF('abcdef', 2, 3, 'ijklmn')
> GO
> ---------
> aijklmnef
>
>
>
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-23-2008, 08:36 AM
Frank van Bortel
 
Posts: n/a
Default Re: STUFF command

Dave Sisk wrote:

> Lookup the REPLACE function in the Oracle docs. I believe this will do what
> you want. (Btw, STUFF in SQLServer is a function also...:-)
>
> HTH,
> Dave
>
> <grille11@yahoo.com> wrote in message
> news:c4e6ad$k1n$1@reader1.imaginet.fr...
>
>>Hello,
>>
>>I am trying to find the equivalent of the STUFF command from SQL (deletes

>
> a
>
>>specified length of characters and inserts another set of characters at a
>>specified starting point).
>>Would someone knows this?
>>thanks in advance
>>
>>
>>This example returns a character string created by deleting three

>
> characters
>
>>from the first string (abcdef) starting at position 2 (at b) and inserting
>>the second string at the deletion point.
>>
>>SELECT STUFF('abcdef', 2, 3, 'ijklmn')
>>GO
>>---------
>>aijklmnef
>>
>>
>>
>>
>>

>
>
>

CREATE OR REPLACE FUNCTION STUFF(strbase IN VARCHAR2,position IN
NUMBER,rmlength
IN NUMBER,strnew IN VARCHAR2)RETURN VARCHAR2
AS
strresult VARCHAR2(4000);
strbase_length INTEGER;
BEGIN
strbase_length:=LENGTH(strbase);
IF( (position < 0) OR (rmlength < 0) OR (position >strbase_length))THEN
strresult :=NULL;
RETURN strresult;
ELSE
strresult
:=SUBSTR(strbase,1,position-1)||strnew||SUBSTR(strbase,position + rmlength);
RETURN strresult;
END IF;
END;
/


dbo@O920.CSDB01.CS.NL> SELECT STUFF('abcdef', 2, 3, 'ijklmn') from dual;

STUFF('ABCDEF',2,3,'IJKLMN')
--------------------------------------------------------------------------
aijklmnef
--

Regards,
Frank van Bortel

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:48 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com