InPutMessage :
<Roots>
<Names>
<Name>Venkat</Name>
</Names>
<Names>
<Name>Krishna</Name>
</Names>
<Names>
<Name>Rathod</Name>
</Names>
</Roots>
ESQL LOGIC :
CREATE COMPUTE MODULE AlphabetSorting_MF_LogicTOSortAlphabet
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE Names INTEGER 1;
DECLARE rInputMessage REFERENCE TO InputRoot.XMLNSC.Roots.Names[1];
WHILE LASTMOVE(rInputMessage) DO
SET Environment.Variables.Names[Names] = rInputMessage.Name;
SET Names = Names +1;
MOVE rInputMessage NEXTSIBLING REPEAT TYPE NAME;
END WHILE;
DECLARE n INTEGER CARDINALITY(Environment.Variables.Names[]);
DECLARE i INTEGER 1;
DECLARE temp CHARACTER;
WHILE i < n DO
SET i = i +1;
DECLARE j INTEGER 1;
WHILE j < n DO
SET j = j + 1;
DECLARE IntName1 CHARACTER UPPER(Environment.Variables.Names[j-1]);
DECLARE IntName2 CHARACTER UPPER(Environment.Variables.Names[j]);
DECLARE NameConstatnt INTEGER;
IF IntName1 = IntName2 THEN
SET NameConstatnt = 0;
ELSEIF IntName1 > IntName2 THEN
SET NameConstatnt = 1;
ELSEIF IntName1 < IntName2 THEN
SET NameConstatnt = -1;
END IF;
IF (NameConstatnt > 0 ) THEN
SET temp = Environment.Variables.Names[j-1];
SET Environment.Variables.Names[j-1] = Environment.Variables.Names[j];
SET Environment.Variables.Names[j] = temp;
END IF;
END WHILE;
END WHILE;
END;
END MODULE;
<Roots>
<Names>
<Name>Venkat</Name>
</Names>
<Names>
<Name>Krishna</Name>
</Names>
<Names>
<Name>Rathod</Name>
</Names>
</Roots>
ESQL LOGIC :
CREATE COMPUTE MODULE AlphabetSorting_MF_LogicTOSortAlphabet
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE Names INTEGER 1;
DECLARE rInputMessage REFERENCE TO InputRoot.XMLNSC.Roots.Names[1];
WHILE LASTMOVE(rInputMessage) DO
SET Environment.Variables.Names[Names] = rInputMessage.Name;
SET Names = Names +1;
MOVE rInputMessage NEXTSIBLING REPEAT TYPE NAME;
END WHILE;
DECLARE n INTEGER CARDINALITY(Environment.Variables.Names[]);
DECLARE i INTEGER 1;
DECLARE temp CHARACTER;
WHILE i < n DO
SET i = i +1;
DECLARE j INTEGER 1;
WHILE j < n DO
SET j = j + 1;
DECLARE IntName1 CHARACTER UPPER(Environment.Variables.Names[j-1]);
DECLARE IntName2 CHARACTER UPPER(Environment.Variables.Names[j]);
DECLARE NameConstatnt INTEGER;
IF IntName1 = IntName2 THEN
SET NameConstatnt = 0;
ELSEIF IntName1 > IntName2 THEN
SET NameConstatnt = 1;
ELSEIF IntName1 < IntName2 THEN
SET NameConstatnt = -1;
END IF;
IF (NameConstatnt > 0 ) THEN
SET temp = Environment.Variables.Names[j-1];
SET Environment.Variables.Names[j-1] = Environment.Variables.Names[j];
SET Environment.Variables.Names[j] = temp;
END IF;
END WHILE;
END WHILE;
END;
END MODULE;
Great Explanation ....Keep posting more & try to cover all the concepts......
ReplyDeleteThanks you dear..!!