473,396 Members | 2,108 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,396 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 13828
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.