Friday, 9 November 2012

 Miscellaneous Functions in MB v7.0


CREATE COMPUTE MODULE miscellaneous_flow_Compute
    CREATE FUNCTION Main() RETURNS BOOLEAN
    BEGIN
    --CALL CopyMessageHeaders();
        --CALL CopyEntireMessage();
       
--------------COALESCE Function------------------
        --SET OutputRoot.XMLNSC.COALESCE = COALESCE(InputRoot.XMLNSC.input1,0);
        --SET OutputRoot.XMLNSC.COALESCE1 = COALESCE(InputRoot.XMLNSC.input12,0);
        --  <input1>12</input1>
        ----------------------------------------
        --SET OutputRoot.XMLNSC.employee.(XMLNSC.Attribute)id ='123';
    -------UUIDASCHAR,UUIDASBLOB-------------------
        --SET OutputRoot.XMLNSC.emp = UUIDASCHAR;
        --SET OutputRoot.XMLNSC.emp1 = UUIDASBLOB;
    ------------------------------------------------
    --DECLARE arg1,arg2 INTEGER;
    --SET arg1 = InputRoot.XMLNSC.args.arg1;
    --SET arg2 = InputRoot.XMLNSC.args.arg2;
--SET OutputRoot.XMLNSC.res.res1 = NULLIF(arg1,arg2);
--CASE WHEN arg1=arg2 THEN NULL ELSE arg1 END
    --<args><arg1>2</arg1><arg2>2</arg2></args>
-------------------------------------------------------


PASSTHRU 'CREATE TABLE customer (
  CustomerNumber INTEGER,
  FirstName      VARCHAR(256),
  LastName       VARCHAR(256),
  Street         VARCHAR(256),
  City           VARCHAR(256),
  Country        VARCHAR(256)
)' TO Database.sample;
--PASSTHRU 'DROP TABLE passthru' TO Database.sample;
    END;

 CREATE PROCEDURE CopyMessageHeaders() BEGIN
        DECLARE I INTEGER 1;
        DECLARE J INTEGER;
        SET J = CARDINALITY(InputRoot.*[]);
        WHILE I < J DO
            SET OutputRoot.*[I] = InputRoot.*[I];
            SET I = I + 1;
        END WHILE;
    END;

    CREATE PROCEDURE CopyEntireMessage() BEGIN
        SET OutputRoot = InputRoot;
    END;
END MODULE;

No comments: