CREATE COMPUTE MODULE app001_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- CALL CopyMessageHeaders();
CALL CopyEntireMessage();
-- DECLARE pattern CHAR 'IU';
DECLARE pattern CHAR 'YYYY-MM-dd''T''HH:mm:ssZZZZZ';
-- SET OutputRoot.JSON.Data.datechangeTZ = changeTimezoneToGMT(InputRoot.JSON.Data.date1,pattern);
BEGIN
DECLARE CONTINUE HANDLER FOR SQLSTATE LIKE'%' BEGIN
SET OutputRoot.JSON.Data.Exception = '例外発生';
-- THROW USER EXCEPTION CATALOG 'BIPmsgs' MESSAGE 2951 VALUES(1,2,3,4,5,6,7,8);
SET OutputRoot.JSON.Data.date1 = '例外発生:' || FIELDNAME(InputRoot.JSON.Data.date1) || ' ' || InputRoot.JSON.Data.date1 || 'は、フォーマット' || pattern || 'と一致しません。';
END;
SET OutputRoot.JSON.Data.date1 = CAST(CAST(InputRoot.JSON.Data.date1 AS GMTTIMESTAMP FORMAT pattern) AS CHARACTER FORMAT pattern);
END;
RETURN TRUE;
END;
CREATE FUNCTION changeTimezoneToGMT(IN varDatetime REFERENCE, IN pattern CHARACTER) RETURNS CHARACTER BEGIN
DECLARE CONTINUE HANDLER FOR SQLSTATE LIKE'%' BEGIN
SET OutputRoot.JSON.Data.Exception = '例外発生';
-- THROW USER EXCEPTION CATALOG 'BIPmsgs' MESSAGE 2951 VALUES(1,2,3,4,5,6,7,8);
RETURN '例外発生:' || FIELDNAME(varDatetime) || ' ' || varDatetime || 'は、フォーマット' || pattern || 'と一致しません。';
END;
RETURN CAST(CAST(varDatetime AS GMTTIMESTAMP FORMAT pattern) AS CHARACTER FORMAT pattern);
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;