Posted: Thu Aug 05, 2004 5:52 am Post subject: Dynamic access InputBody fields / structures to remove "
Disciple
Joined: 21 Jul 2004 Posts: 150 Location: South Africa, JHB
- I'm using WMQI 2.1 CSD 07 on Windows 2000.
Problem
- Some of the fields has double quotes around it as part of the data i.e. '"value"' instead of 'value'
- I'm trying to remove double qoutes from a message structure in one go
My current solution
/*********************************************************************
** FUNCTION RemoveDblQuotes
** Remove Double Quotes ("") around a field
**********************************************************************/
CREATE FUNCTION RemoveDblQuotes (value CHAR) RETURNS CHAR
BEGIN
Set value = TRIM(value);
Set value = TRIM('"' FROM value);
RETURN value;
END;
- I wrote the above function and use it as follows:
---> SET "OutputRoot"."MRM"."Product"."Action" = RemoveDblQuotes("InputBody"."Msg"."Action");
---> I'd need to do this for every element that I map to the OutputRoot individually
Ideal solution - id like to be able the take the "InputBody"."Msg".*[] in some way and apply the RemoveDblQuotes function to each field (and fields within sub-structures) in a loop or something
- Something along the lines of
declare numFields INTEGER;
declare cnt INTEGER;
Set numFields = CARDINALITY("InputBody"."Msg".*[]);
Set cnt = 1;
While cnt <= numFields Do
Set "InputBody"."Msg".*[cnt] = RemoveDblQuotes("InputBody"."Msg".*[cnt]);
Set cnt = cnt + 1;
End While;
Help - I know i'm on the wrong track with the way i access the fields and my cardinality (for the TOTAL fields) will be wrong anyway if there are substructres with its own child elements
- Any ideas on how I can achieve this in eSQL (I dont want to do it on the Message Set Level)
- Thx in advance for any assistance _________________ Applications Architect
Hi,
If your message only contains double quotes in this context. (ie. not other ones you want to keep.) then you could probably remove them much more efficiently in the BLOB domain treating you message as a single string of bytes and removing all the double quotes.
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