Author |
Message
|
Kool-Aid |
Posted: Tue Dec 14, 2004 1:38 pm Post subject: Removing Commas out of a numeric Field |
|
|
 Novice
Joined: 22 Apr 2004 Posts: 22
|
Using WMQI version 2.1 is there a way to simply remove commas out of a numeric or string field. For example the value 345,008,763 is sent. I would like 345008763. How do I do this in ESQL? Or is there a node that supports this? |
|
Back to top |
|
 |
fcotait |
Posted: Tue Dec 14, 2004 7:31 pm Post subject: |
|
|
 Acolyte
Joined: 28 Feb 2002 Posts: 63 Location: Sao Paulo - Brazil
|
You can create a function to remove commas chars using functions POSITION and SUBSTRING
Try the function below (I didn't test the code)
Code: |
CREATE FUNCTION WHITOUTCHAR(S CHAR, CH CHAR) RETURNS CHAR
BEGIN
DECLARE P INTEGER;
SET P = 1;
WHILE P > 0 DO
SET P = POSITION(CH IN S);
IF P > 0 THEN
SET S = SUBSTRING(S FROM 1 FOR (P - 1)) || SUBSTRING(S FROM (P + 1));
END IF;
END WHILE;
RETURN S;
END; |
_________________ Filipe Cotait
IBM Certified System Administrator - WebSphere MQ
IBM Certified Specialist - MQSeries, WebSphere MQ Integrator |
|
Back to top |
|
 |
martinrydman |
Posted: Wed Dec 15, 2004 5:30 am Post subject: |
|
|
 Centurion
Joined: 30 Jan 2004 Posts: 139 Location: Gothenburg, Sweden
|
In WBIMB 5.0, there's a REPLACE function which greatly simplifies the task.
/Martin |
|
Back to top |
|
 |
kirani |
Posted: Wed Dec 15, 2004 10:27 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
martinrydman wrote: |
In WBIMB 5.0, there's a REPLACE function which greatly simplifies the task.
|
But he is using WMQI 2.1 _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
JT |
Posted: Wed Dec 15, 2004 12:17 pm Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
Quote: |
In WBIMB 5.0, there's a REPLACE function which greatly simplifies the task |
I'm curious, even if using the REPLACE function was an option, what would Kool-Aid replace the comma with? The comma needs to be removed, not replaced. |
|
Back to top |
|
 |
martinrydman |
Posted: Wed Dec 15, 2004 1:13 pm Post subject: |
|
|
 Centurion
Joined: 30 Jan 2004 Posts: 139 Location: Gothenburg, Sweden
|
Like this:
Code: |
SET X = REPLACE(X, ',');
|
To quote from the doc:
Quote: |
If you do not specify the replace string expression, the replace string defaults to an empty string and, therefore, the behavior of the function is to delete all occurences of the search string from the result.
|
/Martin |
|
Back to top |
|
 |
JT |
Posted: Wed Dec 15, 2004 1:27 pm Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
martinrydman,
Thanks, that'll come in handy some day.  |
|
Back to top |
|
 |
|