Posted: Sun Mar 16, 2003 7:28 am Post subject: Comparing fields problem
Master
Joined: 21 Nov 2002 Posts: 200
HI! I have a message flow that has to evaluate two tags. If the first tag has a "Y" in it then I need to evluate the second tag for not NULL and Greater than zero. My code does not work if the second tag has alphanumerics or spaces in it. I have tried casting to integer and this does not seem to work. Can someone look at the following code and see how I may be able to do this? Thanks!! LisaB
DECLARE TmpPremise INTEGER;
set TmpPremise = CAST
(InputRoot.XML.CreateJob.DataArea.Job.WorkCodeUDFS.WorkCodeUDF[12] AS INTEGER);
If (InputRoot.XML.CreateJob.DataArea.Job.WorkCodeUDFS.WorkCodeUDF[13] = 'Y') and
((TmpPremise > 0) and
(TmpPremise IS NOT NULL))
then
SET OutputRoot.XML.CreateJob = NULL;
CREATE FIELD OutputRoot.XML.ATLAS_XY_QUERY;
CREATE FIELD OutputRoot.XML.ATLAS_XY_QUERY.ApplicationArea;
CREATE FIELD OutputRoot.XML.ATLAS_XY_QUERY.ApplicationArea.Sender;
CREATE FIELD OutputRoot.XML.ATLAS_XY_QUERY.ApplicationArea.Sender.Component;
CREATE FIELD OutputRoot.XML.ATLAS_XY_QUERY.ApplicationArea.Sender.Confirmation;
CREATE FIELD OutputRoot.XML.ATLAS_XY_QUERY.ApplicationArea.Sender.AuthorizationId;
CREATE FIELD OutputRoot.XML.ATLAS_XY_QUERY.ApplicationArea.CreationDateTime;
CREATE FIELD OutputRoot.XML.ATLAS_XY_QUERY.ApplicationArea.BODId;
CREATE FIELD OutputRoot.XML.ATLAS_XY_QUERY.DataArea;
CREATE FIELD OutputRoot.XML.ATLAS_XY_QUERY.DataArea.REQ_TYPE;
CREATE FIELD OutputRoot.XML.ATLAS_XY_QUERY.DataArea.REQ_CODE;
CREATE FIELD OutputRoot.XML.ATLAS_XY_QUERY.DataArea.PREMISE_NO;
CREATE FIELD OutputRoot.XML.ATLAS_XY_QUERY.DataArea.RECORD_DATA;
CREATE FIELD OutputRoot.XML.ATLAS_XY_QUERY.DataArea.RECORD_DATA.EXTERNAL_ONE;
SET OutputRoot.XML.ATLAS_XY_QUERY.ApplicationArea.Sender.Component = 'MDS XY Query';
SET OutputRoot.XML.ATLAS_XY_QUERY.ApplicationArea.Sender.AuthorizationId =
'ODL Create Job';
SET OutputRoot.XML.ATLAS_XY_QUERY.ApplicationArea.CreationDateTime = CURRENT_TIMESTAMP;
SET OutputRoot.XML.ATLAS_XY_QUERY.ApplicationArea.BODId = UUIDASBLOB;
SET OutputRoot.XML.ATLAS_XY_QUERY.DataArea.REQ_TYPE = 'PREMISE';
SET OutputRoot.XML.ATLAS_XY_QUERY.DataArea.REQ_CODE = 'COORDINATES';
SET OutputRoot.XML.ATLAS_XY_QUERY.DataArea.PREMISE_NO =
InputRoot.XML.CreateJob.DataArea.Job.WorkCodeUDFS.UDF[13];
SET OutputRoot.XML.ATLAS_XY_QUERY.DataArea.RECORD_DATA.EXTERNAL_ONE =
InputRoot.XML.CreateJob.ApplicationArea.BODId;
ELSE return false;
End if;
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
I don't think this will work. If your second element contains CHAR data, it will throw and exception when you try to cast it to an INT.
Folowing code will not work if the incoming element contains any char data (A - Z). Can you control the input data so that it doesn't contain A-Z chars?
Code:
-- If the tag does not exist or contains null value
If (InputRoot.XML.CreateJob.DataArea.Job.WorkCodeUDFS.WorkCodeUDF[12] = '' OR
InputRoot.XML.CreateJob.DataArea.Job.WorkCodeUDFS.WorkCodeUDF[12] is NULL ) THEN
SET TempPremise = 0;
ELSE
-- If the tag is not null and contains SPACE char
IF (SUBSTRING(InputRoot.XML.CreateJob.DataArea.Job.WorkCodeUDFS.WorkCodeUDF[12] FROM 1 FOR 1) = ' ') THEN
SET TeMPPremise = 0;
ELSE
SET TeMPPremise = CAST(InputRoot.XML.CreateJob.DataArea.Job.WorkCodeUDFS.WorkCodeUDF[12] AS INT);
END IF;
END IF;
_________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
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