473,408 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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)
Jul 19 '05 #1
2 13829
al0
je***@hypershell.com (Jeff Lambert) wrote in message news:<f1**************************@posting.google. 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_string. If replacement_string 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
Jul 19 '05 #2
Thank you very much...

Ol******************@rambler.ru (al0) wrote in message news:<42**************************@posting.google. com>...
je***@hypershell.com (Jeff Lambert) wrote in message news:<f1**************************@posting.google. 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_string. If replacement_string 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

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Phil Hindmoor | last post by:
Hi, I am sure if anyone can help me, you guys can! I am an Informix Developer, moving to Oracle 8i and later databases. I am struggling to find the Oracle equivelant to many of the useful...
1
by: Philip Mette | last post by:
I am in a crunch and need to covert this Oracle statement to MSSQL. Is there any Oracle/MSSQL experts out there that can help me? I do not understand the syntax enough to modify this. Thanks so...
125
by: Rhino | last post by:
One of my friends, Scott, is a consultant who doesn't currently have newsgroup access so I am asking these questions for him. I'll be telling him how to monitor the answers via Google Newsgroup...
133
by: jonathan | last post by:
hey all, I realize that this question might pop up from time to time, but I haven't seen it a while and things might of changed, so - Right now (July 2004) how does mysql stand up in...
35
by: English Teacher | last post by:
Which would be a more useful relational database server to learn nowadays: MS SQL SERVER or ORACLE? Thanks!
2
by: James Alexander Starritt | last post by:
I also posted similarly in mailing.database.mysql I have created a rather large (60 table database) website dealio in PHP that works with MS SQL Server, Oracle, MySQL and presumably any other...
28
by: prunoki | last post by:
Hello, I am an SQL server newbie. Our company has a massive application written in PL/SQL. I need to port parts of it to SQL Server. - Which SQL server version should I choose, to have a...
5
by: NormaJean Sebastian via DBMonster.com | last post by:
Hi, I almost read all of the "DB2 vs Oracle" thread... The summary I got from that was all databases essentially do the same things, the decision of which one you use primarily depends on...
2
by: Jeff Lambert | last post by:
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.