Copy link to clipboard
Copied
I know that this is a pretty basic technique, but I'm having troubles finding the solution for it. Any help is appreciated...
I'm running a simple sql db query, and if I pull the following data: "A/P", then I need to use coldfusion to strip that slash out, so that I just have "AP".
So for example, let's say that "#GetData.LineCode#" = "A/P":
<cfquery name="InsertInventory" datasource="#Request.ds#" username="#Request.user#" password="#Request.pass#">
INSERT INTO Products
(LineCode)
VALUES
(
'#GetData.LineCode#'
)
</cfquery>
I need it to insert just "AP". How do I do that??
Also, there are some instances where I might have "APP", so I can't just remove the 2nd character every time. It has to recognize the slash and remove only it.
Thanks in advance everyone!
Something wrong with #replace(GetDate.LineCode,"/","","ALL")#?
Copy link to clipboard
Copied
Something wrong with #replace(GetDate.LineCode,"/","","ALL")#?
Copy link to clipboard
Copied
Nope... nothing wrong with that unless you don't know it!
Thanks!
Copy link to clipboard
Copied
I know that this is a pretty basic technique, but I'm having troubles finding the solution for it. Any help is appreciated...
I'm running a simple sql db query, and if I pull the following data: "A/P", then I need to use coldfusion to strip that slash out, so that I just have "AP".
You're right, it's a pretty basic question (there is nothing wrong with this, we all started by asking basic questions). The best way to try to work through this sort of thing by yourself - which is the best way to learn new stuff - is to read the docs!
The CFML reference is here:
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/index.html
The sort of operation you are wanting to do is most likely going to be performed by a function, so the function reference is here:
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7ff8.html
There's a link on that page to functions listed by category, and your situation is related to string manipulation, so it'll probably be in here:
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-6a3a.html
And you're wanting to replace one part of a string with something else, so I'd start looking at the functions with the word "replace" in their names...
There's no problem with asking any questions here you like, but quite often with a small amount of elbow-grease you can answer most question for yourself, just by having a look in the docs. This is not just advice for newbies: I've been doing CF for eight years, and I am still in Livedocs every day. It's a good first port of call.
--
Adam