WebSphere Message Broker バージョン 8.0.0.5 オペレーティング・システム: AIX、HP-Itanium、Linux、Solaris、Windows、z/OS

製品の最新バージョンについては、IBM Integration Bus バージョン 9.0 をご覧ください。

大きなフィールドからのサブフィールドの選択

区切り文字で区切られているサブフィールドが含まれるメッセージを、 処理するメッセージ・フローがある場合があります。 サブフィールドの区切り文字がわかっている場合、 ESQL をコーディングして、周囲の内容からサブフィールドを抽出することができます。

このタスク、または類似のタスクを実行する関数を作成する場合、ESQL モジュール (ComputeDatabaseDatabaseInput、および Filter ノード用) と、マッピング・ファイル (Mapping ノードによって使用される) の両方からその関数を呼び出すことができます。

以下の関数の例は、特定の文字で区切られたメッセージの特定のサブフィールドを抽出します。

CREATE FUNCTION SelectSubField 
       (SourceString CHAR, Delimiter CHAR, TargetStringPosition INT) 
d       RETURNS CHAR
-- This function returns a substring at parameter position TargetStringPosition within the      
-- passed parameter SourceString.  An example of use might be:
-- SelectSubField(MySourceField,' ',2) which will select the second subfield from the
-- field MySourceField delimited by a blank.  If MySourceField has the value
-- "First Second Third" the function will return the value "Second"
  BEGIN
    DECLARE DelimiterPosition INT;
    DECLARE CurrentFieldPosition INT 1;
    DECLARE StartNewString INT 1;
    DECLARE WorkingSource CHAR SourceString;
    SET DelimiterPosition = POSITION(Delimiter IN SourceString);
    WHILE CurrentFieldPosition < TargetStringPosition
     	DO
     		IF DelimiterPosition = 0  THEN
   			-- DelimiterPosition will be 0 if the delimiter is not found 
         -- exit the loop
     			SET CurrentFieldPosition = TargetStringPosition;
     		ELSE
     			SET StartNewString = DelimiterPosition + 1;
     			SET WorkingSource = SUBSTRING(WorkingSource FROM StartNewString);
     			SET DelimiterPosition = POSITION(Delimiter IN WorkingSource);
     			SET CurrentFieldPosition = CurrentFieldPosition + 1;
     		END IF;
    END WHILE;
    IF DelimiterPosition> 0 THEN
       -- Remove anything following the delimiter from the string
       SET WorkingSource = SUBSTRING(WorkingSource FROM 1 FOR DelimiterPosition);     	
       SET WorkingSource = TRIM(TRAILING Delimiter FROM WorkingSource);
    END  IF;  
    RETURN WorkingSource;
END;	
特記事項 | 商標 | ダウンロード | ライブラリー | サポート | フィードバック

Copyright IBM Corporation 1999, 2014Copyright IBM Corporation 1999, 2014.

        
        最終更新:
        
        最終更新: 2015-02-28 17:45:39


タスク・トピックタスク・トピック | バージョン 8.0.0.5 | ac20400_