|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How to substitute <CR><LF> char in a CHAR eSQL v |
« View previous topic :: View next topic » |
Author |
Message
|
Testo |
Posted: Wed Dec 10, 2003 5:33 am Post subject: How to substitute <CR><LF> char in a CHAR eSQL v |
|
|
 Centurion
Joined: 26 Feb 2003 Posts: 120 Location: Italy - Milan
|
Probably this is an easy one for the most part of you but I have some pbs.
I have a char variable in my compute node derived from a SWIFT message; in this variable there are many <CR><LF> with hex value '0D0A'. How can I write an eSQL instruction to substitute those '0D0A' with an hex '20' (that is the equivalent for a blank)?
Thanks in advance,
Andrea Tedone |
|
Back to top |
|
 |
ghoose |
Posted: Wed Dec 10, 2003 6:17 am Post subject: |
|
|
Novice
Joined: 23 Apr 2002 Posts: 16
|
Ths shoud do the trick!
Goodluck
Ghoose
Code: |
DECLARE I INTEGER;
SET I = 1;
WHILE I < CARDINALITY(InputRoot.*[]) DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I=I+1;
END WHILE;
-- Enter SQL below this line. SQL above this line might be regenerated, causing any modifications to be lost.
DECLARE inputData BLOB;
DECLARE outputData BLOB;
DECLARE find BLOB;
DECLARE replace BLOB;
DECLARE pos INTEGER;
SET inputData = InputRoot."BLOB"."BLOB";
SET outputData = x'';
SET find = x'0D0A';
SET replace = x'20';
SET pos = POSITION(find IN inputData);
WHILE (pos <> 0 AND inputData IS NOT NULL) DO
SET outputData = outputData ||
SUBSTRING(inputData FROM 1 FOR (pos-1)) ||
replace;
SET inputData = SUBSTRING(inputData FROM pos + 1);
SET pos = POSITION(find IN inputData);
END WHILE;
SET OutputRoot."BLOB"."BLOB" = outputData || inputData; |
|
|
Back to top |
|
 |
Testo |
Posted: Wed Dec 10, 2003 6:56 am Post subject: Ok if InputRoot.BLOB.BLOB but.... |
|
|
 Centurion
Joined: 26 Feb 2003 Posts: 120 Location: Italy - Milan
|
First of all, ty Ghoose for your support.
Your code is fine, infact I was able to clean a whole message from every occurencies of '0D0A' BUT my problem is that my message is not a blob...
So I have adapted your trick-code like this:
Code: |
DECLARE C INTEGER;
SET C = CARDINALITY(InputRoot.*[]);
DECLARE I INTEGER;
SET I = 1;
WHILE I < C DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I=I+1;
END WHILE;
-- Enter SQL below this line. SQL above this line might be regenerated, causing any modifications to be lost.
DECLARE inputData, outputData, find, replace BLOB;
DECLARE tag72, post72 CHAR;
DECLARE pos, pos1 INTEGER;
SET pos = POSITION('72:' IN "InputBody"."BODY");
IF (pos > 0 ) THEN
SET post72 = SUBSTRING("InputBody"."BODY" FROM pos + 3);
SET pos1 = POSITION(':' IN post72);
SET tag72 = SUBSTRING(post72 FROM 1 FOR pos1 - 1);
END IF;
--SET inputData = InputRoot."BLOB"."BLOB";
[b]SET inputData = CAST(tag72 AS BLOB);[/b]
SET outputData = x'';
SET find = x'0D0A';
SET replace = x'20';
SET pos = POSITION(find IN inputData);
WHILE (pos <> 0 AND inputData IS NOT NULL) DO
SET outputData = outputData || SUBSTRING(inputData FROM 1 FOR (pos - 1)) || replace;
SET inputData = SUBSTRING(inputData FROM pos + 2);
SET pos = POSITION(find IN inputData);
END WHILE;
SET tag72 = CAST((outputData || inputData) AS CHAR);
--SET OutputRoot."BLOB"."BLOB" = outputData || inputData; |
but from the trace I can see that the eSQL instruction in bold is not fine....
Any further ideas?
Thanks
Andrea |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|