Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace all ## with ## and String 2

Status
Not open for further replies.

SgtPepps

IS-IT--Management
May 1, 2002
109
GB
I have a field called Part_No, i'd like to:

- Replace all Part_No with Part_No and TEXT

Which i hope will add the TEXT to the end of whatever the Part_No value is.

What would be the correct command for this??

Mike
 
assuming part_no = '1234' and Part_no field is a character field of width 10

Replace all Part_No with alltrim(Part_No)+"HELLO"
will give 1234HELLO




Pete Bloomfield
Down Under
 
If however Part_No is a numeric field then the following is what you want...

REPLACE ALL Part_No WITH ALLTRIM(STR(Part_no))+"sometext" IN "MyAlias"

Slighthaze = NULL
craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Sorry slighthaze, but if Part_No is a numeric field then you cannot replace the same numeric field with string data. If it were being placed into a separate character field then your example would certainly be fine.

Presumably though we're dealing with a character field so repete's code would work in this case.

dbMark
 
dbMark,

I stand corrected. [blush]

Slighthaze = NULL
craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Dear all:

I do not understand why you used alltrim() when trim() can do the trick. Can you correct me ?

Nasib Kalsi
 
TRIM() will remove Trailing blanks only where ALLTRIM() will remove both Preceeding and Trailing blanks.

Since data is input by humans we cannot always ensure the quality of the data (not all GET's have Valid functions nor do they typically catch ALL human errors) and where things like spaces may occur.

Therefore to be safe it is just as easy to utilize ALLTRIM() as it is TRIM() and it will better ensure the results.

Good Luck,


JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
Of course, but the data validation is done at the get level. Also the question, I think was to append the data at the end of the existing string not to validate and correct it. Which(validation) has already been done.

Nasib Kalsi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top