首页 > 解决方案 > 我如何知道 IIB 中的 LASTMOVE 何时返回 true 或 false?

问题描述

-- Shared row variable for caching config data. Declared at Global scope.
DECLARE S_ConfigSharedRow SHARED ROW;

CREATE COMPUTE MODULE TheFirstComputeNode
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
    CFGDATA_CACHE_LOCK: BEGIN ATOMIC
        -- If the configuration data is not available in the cache then load it from the CONFIG table
        DECLARE CfgDataRef REFERENCE TO S_ConfigSharedRow.CfgDataCache;
        IF NOT LASTMOVE(CfgDataRef) THEN
            -- Select all the relevant content from the actual database in one go.
            DECLARE DBResults ROW;
            DECLARE RetryCount INTEGER 5;
            SET DBResults.Row[] = PASSTHRU('SELECT * FROM CONFIG');

            -- Typically you would post process the content from the DB into a more amenable 
            -- structure but the following will get the data into the shared variable
            CREATE LASTCHILD OF S_ConfigSharedRow.CfgDataCache FROM DBResults;
        END IF;
    END CFGDATA_CACHE_LOCK;

    -- Config data is now available for use

    RETURN TRUE;
END;
END MODULE;

大家好,请问LASTMOVE在这种情况下返回true的情况是什么,哪种情况是false。谢谢大家。

标签: ibm-mqibm-integration-busextended-sql

解决方案


我对LASTMOVE的经验是它可以返回NULL,所以最好只检查TRUE

    DECLARE CfgDataRef REFERENCE TO S_ConfigSharedRow.CfgDataCache;
    IF LASTMOVE(CfgDataRef) THEN
        -- Nothing to do
    ELSE
        -- Select all the relevant content ...
    END IF;

推荐阅读